1jQuery(document).ready(function ($) { 2 3 /************* Toggle open search ********************/ 4 $('.header-toggle-search, #header-search-modal').click(function () { 5 var search = $('#header-search'); 6 if ($(search).hasClass('show')) { 7 $(search).removeClass('show'); 8 $('#header-search-modal').removeClass('show'); 9 $(document).off('keyup'); 10 $("#aria-alert").remove(); 11 } else { 12 $(search).addClass('show'); 13 $(search).find('.search-field').focus(); 14 $('#header-search-modal').addClass('show'); 15 $( "<p id=\"aria-alert\" role=\"alert\" class=\"screen-reader-text\">Use Escape Key to hide Search Box and return to page.</p>" ).appendTo( document.body ); 16 17 //add escape key to close header search 18 $(document).on('keyup', function(event) { 19 if(event.key == "Escape") { 20 $(search).removeClass('show'); 21 $('#header-search-modal').removeClass('show'); 22 $(document).off('keyup'); 23 $("#aria-alert").remove(); 24 } 25 }); 26 } 27 }); 28 29 $('#close-search').click(function () { 30 $('#header-search, #header-search-modal').removeClass('show'); 31 $(document).off('keyup'); 32 $("#aria-alert").remove(); 33 }); 34 35 //keep focus within search box 36 $('#header-search .search-field').on('keydown', function (event) { 37 if (event.key == "Tab") { 38 event.preventDefault(); 39 if (event.shiftKey) { 40 $('#header-search #close-search').focus(); 41 } else { 42 $('#header-search .search-submit').focus(); 43 } 44 } 45 }); 46 $('#header-search #close-search').on('keydown', function (event) { 47 if (event.key == "Tab") { 48 event.preventDefault(); 49 if (event.shiftKey) { 50 $('#header-search .search-submit').focus(); 51 } else { 52 $('#header-search .search-field').focus(); 53 } 54 } 55 }); 56 //END: keep focus within search box 57
58 /************* END: Toggle open search ********************/ 59 60 61 /*** Catch empty searches -- works for any search forms, even if more than one on page ***/ 62 $(".search-form").submit(function () { 63 64 var $input = $(this).find('.search-field'); 65 if ($input.val() == "") { 66 $input.val(""); //in case a blank space is entered, this allows placeholder to be set. 67 $input.attr("placeholder", "* required"); 68 $input.addClass("error"); 69 $(this).blur(); 70 return false; 71 } 72 }); 73 /*** END: Catch empty searches -- works for any search forms, even if more than one on page ***/ 74 75 /**************** scrolling hide/show header for mobile *****************/ 76 var didScroll; 77 var lastScrollTop = 0; 78 var delta = 10; 79 var navbarHeight = $('header#masthead').outerHeight(); 80 81 82 // on scroll, let the interval function know the user has scrolled 83 $(window).scroll(function (event) { 84 didScroll = true; 85 }); 86 // run hasScrolled() and reset didScroll status 87 setInterval(function () { 88 if (didScroll) { 89 hasScrolled(); 90 didScroll = false; 91 } 92 }, 250); 93 94 function hasScrolled() { 95 var st = $(this).scrollTop(); //how far from top 96 97 98 if (Math.abs(lastScrollTop - st) <= delta) { //only change if scrolled more than delta of 5 px 99 return; 100 } 101 102 // If current position > last position AND scrolled past navbar... 103 if (st > lastScrollTop && st > navbarHeight) { 104 // Scroll Down 105 $('body').removeClass("scrolled-up").addClass("scrolled-down"); 106 } else { 107 // Scroll Up 108 // If did not scroll past the document (possible on mac)... 109 if (st + $(window).height() < $(document).height()) { 110 $('body').removeClass("scrolled-down").addClass("scrolled-up"); 111 if (st < navbarHeight) { 112 $('body').removeClass('scrolled-up'); //at top so desktop header should expand. 113 } 114 } 115 } 116 lastScrollTop = st; 117 } 118 119 /**************** END: scrolling hide/show header for mobile *****************/ 120});
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.