1(function() { 2 var SOURCES = window.TEXT_VARIABLES.sources; 3 window.Lazyload.js(SOURCES.jquery, function() { 4 $(function() { 5 var $this ,$scroll; 6 var $articleContent = $('.js-article-content'); 7 var hasSidebar = $('.js-page-root').hasClass('layout--page--sidebar'); 8 var scroll = hasSidebar ? '.js-page-main' : 'html, body'; 9 $scroll = $(scroll); 10 11 $articleContent.find('.highlight').each(function() { 12 $this = $(this); 13 $this.attr('data-lang', $this.find('code').attr('data-lang')); 14 }); 15 $articleContent.find('h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]').each(function() { 16 $this = $(this); 17 $this.append($('<a class="anchor d-print-none" aria-hidden="true"></a>').html('<i class="fas fa-anchor"></i>')); 18 }); 19 $articleContent.on('click', '.anchor', function() { 20 $scroll.scrollToAnchor('#' + $(this).parent().attr('id'), 400); 21 }); 22 }); 23 }); 24})();