1(function() { 2 var SOURCES = window.TEXT_VARIABLES.sources; 3 var TOC_SELECTOR = window.TEXT_VARIABLES.site.toc.selectors; 4 window.Lazyload.js(SOURCES.jquery, function() { 5 var $window = $(window); 6 var $articleContent = $('.js-article-content'); 7 var $tocRoot = $('.js-toc-root'), $col2 = $('.js-col-aside'); 8 var toc; 9 var tocDisabled = false; 10 var hasSidebar = $('.js-page-root').hasClass('layout--page--sidebar'); 11 var hasToc = $articleContent.find(TOC_SELECTOR).length > 0; 12 13 function disabled() { 14 return $col2.css('display') === 'none' || !hasToc; 15 } 16 17 tocDisabled = disabled(); 18 19 toc = $tocRoot.toc({ 20 selectors: TOC_SELECTOR, 21 container: $articleContent, 22 scrollTarget: hasSidebar ? '.js-page-main' : null, 23 scroller: hasSidebar ? '.js-page-main' : null, 24 disabled: tocDisabled 25 }); 26 27 $window.on('resize', window.throttle(function() { 28 tocDisabled = disabled(); 29 toc && toc.setOptions({ 30 disabled: tocDisabled 31 }); 32 }, 100)); 33 34 }); 35})();