1$(document).ready(function (e) { 2 // const timeLimit = 700; 3 // let timer = []; 4 // let prevNavs = []; 5 6 $('.header .nav__a[href^="#"]').on("click", function (e) { 7 e.preventDefault(); 8 }); 9 10 $("#mobile_nav .nav").hide(); 11 12 // Hover toggle submenu 13 // Hover time limit is for accessibility purposes to benefit those with shaky motor-controls 14 // TODO: Fix time limit hover delay 15 $(".header__nav-wrapper--desk .nav").on("mouseleave", ".menu-item-has-children", function (e) { 16 // if (!$(this).hasClass("active")) { 17 // let $this = $(this); 18 // prevNavs.push($(this)[0]); 19 // timer = setTimeout(function () { 20 // $this.find(".nav--subnav").eq(0).hide(); 21 // }, timeLimit); 22 // } 23 $(this).find(".nav--subnav").eq(0).hide(); 24 }); 25 // Also prevents the specific behavior of hover out on a keyboard activated submenu 26 $(".header__nav-wrapper--desk .nav").on("mouseenter", ".menu-item-has-children", function (e) { 27 // let $this = $(this)[0]; 28 // if (prevNavs.includes($this)) { 29 // clearTimeout(timer); 30 // prevNavs = prevNavs.filter(function (item) { 31 // return item != $this; 32 // }); 33 // } 34 $(this).find(".nav--subnav").eq(0).show(); 35 }); 36 37 // Mobile menu toggle 38 $(".header__mobile-nav-toggle").on("click", function () { 39 var menuExpanded = $(this).attr("aria-expanded") == "false" ? "true" : "false"; 40 $(this).attr("aria-expanded", menuExpanded).toggleClass("is-active"); 41 $(this).siblings(".nav").slideToggle(); 42 }); 43 // Mobile Nav toggle submenu behavior 44 $("#header__nav--mobile .nav > .menu-item-has-children .subnav-button-wrapper > a .plus").on("click", function (e) { 45 e.preventDefault(); 46 var plusExpanded = $(this).attr("aria-expanded") == "false" ? "true" : "false"; 47 $(this).attr("aria-expanded", plusExpanded); 48 $(this).parents("li").toggleClass("active"); 49 $(this).parents(".subnav-button-wrapper").siblings(".nav--subnav").slideToggle(); 50 }); 51 // Accessible button toggle submenu behavior 52 $(".header__nav-wrapper .nav .menu-item-has-children > .subnav-button-wrapper > a .plus").on("keypress", function (e) { 53 e.preventDefault(); 54 if (e.key == "Enter" || e.key == " ") { 55 var plusExpanded = $(this).attr("aria-expanded") == "false" ? "true" : "false"; 56 $(this).attr("aria-expanded", plusExpanded); 57 $(this).parents("li").toggleClass("active"); 58 $(this).parents(".subnav-button-wrapper").siblings(".nav--subnav").slideToggle(); 59 } 60 }); 61 // Accessible Tab out of submenu behavior 62 $(".header__nav-wrapper--desk .nav__li").on("focusout", function (e) { 63 let parent = $(e.currentTarget)[0]; 64 let child = $(e.relatedTarget)[0]; 65 let parents = $(child).parents(".nav__li"); 66 if (!Object.values(parents).includes(parent)) { 67 let subnav = $(parent).find(".nav--subnav"); 68 let subnavButton = $(parent).find("button"); 69 $(subnavButton).attr("aria-expanded", "false"); 70 $(subnavButton).parents(".nav__li").eq(0).removeClass("active"); 71 $(subnav).slideUp(); 72 } 73 }); 74});
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.