1$( document ).ready(function() { 2// Select all links with hashes 3$('a[href*="#"]') 4 // Remove links that don't actually link to anything 5 .not('[href="#"]') 6 .not('[href="#0"]') 7 .click(function(event) { 8 // On-page links 9 if ( 10 location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') 11 && 12 location.hostname == this.hostname 13 ) { 14 // Figure out element to scroll to 15 var target = $(this.hash); 16 target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); 17 // Does a scroll target exist? 18 if (target.length) { 19 // Only prevent default if animation is actually gonna happen 20 event.preventDefault(); 21 $('html, body').animate({ 22 scrollTop: target.offset().top 23 }, 1000, function() { 24 // Callback after animation 25 // Must change focus! 26 var $target = $(target); 27 $target.focus(); 28 if ($target.is(":focus")) { // Checking if the target was focused 29 return false; 30 } else { 31 $target.attr('tabindex','-1'); // Adding tabindex for elements not focusable 32 $target.focus(); // Set focus again 33 }; 34 }); 35 } 36 } 37 }); 38});
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.