1(() => { 2 // hamburger/src/view.ts 3 document.body.addEventListener("click", (e) => { 4 const target = e.target; 5 if (target && target instanceof HTMLElement && target.matches(".mytheme-hamburger")) { 6 let parent = target.parentElement; 7 while (parent && !parent.matches(".wp-block-mytheme-navigation")) { 8 parent = parent.parentElement; 9 } 10 if (parent) { 11 parent.classList.toggle("mytheme-open-navigation"); 12 const isOpen = parent.classList.contains("mytheme-open-navigation"); 13 if (isOpen) { 14 target.setAttribute("aria-expanded", "true"); 15 document.documentElement.classList.add("mytheme-has-open-navigation"); 16 } else { 17 target.setAttribute("aria-expanded", "false"); 18 document.documentElement.classList.remove("mytheme-has-open-navigation"); 19 } 20 parent.dispatchEvent( 21 new CustomEvent("mytheme-open-navigation", { 22 bubbles: true, 23 detail: { 24 reason: "hamburger", 25 navigation: parent, 26 isOpen 27 } 28 }) 29 ); 30 } 31 } 32 if (target && target instanceof HTMLElement && target.matches(".wp-block-mytheme-navtarget a")) { 33 const link = target.closest("a"); 34 if (link?.pathname !== window.location.pathname) { 35 return; 36 } 37 let parent = target.parentElement; 38 while (parent && !parent.matches(".wp-block-mytheme-navigation")) { 39 parent = parent.parentElement; 40 } 41 if (parent) { 42 parent.classList.remove("mytheme-open-navigation"); 43 parent.setAttribute("aria-expanded", "false"); 44 document.documentElement.classList.remove("mytheme-has-open-navigation"); 45 parent.dispatchEvent( 46 new CustomEvent("mytheme-open-navigation", { 47 bubbles: true, 48 detail: { 49 reason: "hash", 50 navigation: parent, 51 isOpen: false 52 } 53 }) 54 ); 55 } 56 } 57 }); 58})();
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.