1(function ($) { 2 $(function () { 3 4 // Select all links with hashes 5 $('a[data-smooth-scroll]') 6 // Remove links that don't actually link to anything 7 .not('[href="#"]') 8 .not('[href="#0"]') 9 .click(function(event) { 10 // On-page links 11 if ( 12 location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') 13 && 14 location.hostname === this.hostname 15 ) { 16 // Figure out element to scroll to 17 var target = $(this.hash); 18 target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); 19 // Does a scroll target exist? 20 if (target.length) { 21 // Only prevent default if animation is actually gonna happen 22 event.preventDefault(); 23 $('html, body').animate({ 24 scrollTop: target.offset().top 25 }, 1000, function() { 26 // Callback after animation 27 // Must change focus! 28 var $target = $(target); 29 $target.focus(); 30 if ($target.is(":focus")) { // Checking if the target was focused 31 return false; 32 } else { 33 $target.attr('tabindex','-1'); // Adding tabindex for elements not focusable 34 $target.focus(); // Set focus again 35 }; 36 }); 37 } 38 } 39 }); 40 41 }) 42})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.