1(function () { 2 document.addEventListener("DOMContentLoaded", function () { 3 const $header = document.querySelector("#header"); 4 const $menuToggle = document.querySelector("#header .menu-toggle"); 5 $menuToggle.addEventListener("click", function (e) { 6 e.preventDefault(); 7 e.stopPropagation(); 8 $header.classList.toggle("open"); 9 }); 10 const $menu = document.querySelector("#nav ul.menu"); 11 12 const onFocus = function (e) { 13 $menu 14 .querySelectorAll(":scope li.menu-item-has-children:not(.open)") 15 .forEach(function ($li) { 16 const $ul = $li.lastElementChild; 17 const rect = $ul.getBoundingClientRect(); 18 if (rect.left + $ul.offsetWidth >= document.body.clientWidth) { 19 $ul.classList.add("left"); 20 } 21 }); 22 }; 23 const onFocusOut = function (e) { 24 $menu 25 .querySelectorAll( 26 ":scope li.menu-item-has-children:not(.open) > ul.left" 27 ) 28 .forEach(function ($ul) { 29 $ul.classList.remove("left"); 30 }); 31 }; 32 33 $menu.addEventListener("mouseenter", onFocus); 34 $menu.addEventListener("mouseleave", onFocusOut); 35 $menu.addEventListener("focusin", onFocus); 36 $menu.addEventListener("focusout", onFocusOut); 37 38 let subMenuId = 0; 39 $menu 40 .querySelectorAll(":scope li.menu-item-has-children") 41 .forEach(function ($li) { 42 const $ul = $li.lastElementChild; 43 const $a = $li.firstElementChild; 44 const $btn = document.createElement("button"); 45 46 $ul.setAttribute("id", "submenu" + subMenuId); 47 $btn.setAttribute("aria-expanded", "false"); 48 $btn.setAttribute("aria-haspopup", "true"); 49 $btn.setAttribute("aria-controls", "submenu" + subMenuId); 50 $btn.setAttribute("aria-label", "Expand menu"); 51 $btn.classList.add("dropdown-toggle"); 52 $btn.addEventListener("click", function (e) { 53 e.preventDefault(); 54 e.stopPropagation(); 55 const expanded = $btn.getAttribute("aria-expanded") === "true"; 56 $btn.setAttribute( 57 "aria-label", 58 expanded ? "Expand menu" : "Collapse menu" 59 ); 60 $btn.setAttribute("aria-expanded", expanded ? "false" : "true"); 61 $li.classList.toggle("open", !expanded); 62 }); 63 64 $a.after($btn); 65 subMenuId++; 66 }); 67 68 const $archiveFilters = document.querySelector("#archive-filters"); 69 if ($archiveFilters) { 70 $archiveFilters.querySelectorAll("select").forEach(function ($elm) { 71 $elm.addEventListener("change", function (e) { 72 $archiveFilters.dispatchEvent(new Event("submit")); 73 }); 74 }); 75 76 window.addEventListener("popstate", function (e) { 77 const params = new URLSearchParams(document.location.search); 78 console.log(params); 79 $archiveFilters.querySelectorAll("select").forEach(function ($elm) { 80 const param = params.get($elm.getAttribute("name")); 81 console.log($elm.getAttribute("name"), param); 82 if (param) { 83 $elm.value = param; 84 } else { 85 $elm.selectedIndex = 0; 86 } 87 }); 88 // $archiveFilters.dispatchEvent(new Event("submit")); 89 }); 90 91 const $archivePosts = document.querySelector("#archive-posts"); 92 if ($archivePosts) { 93 const $template = document.createElement("div"); 94 $archiveFilters.addEventListener("submit", function (e) { 95 e.preventDefault(); 96 const formData = new FormData($archiveFilters); 97 const params = new URLSearchParams(formData); 98 const url = 99 document.location.origin + 100 document.location.pathname + 101 "?" + 102 params.toString(); 103 window.history.pushState(null, null, url); 104 fetch(url) 105 .then((response) => response.text()) 106 .then(function (text) { 107 $template.innerHTML = text; 108 const $newText = $template.querySelector("#archive-posts"); 109 if ($newText) { 110 $archivePosts.innerHTML = $newText.innerHTML; 111 } 112 }); 113 return false;
114 }); 115 } 116 } 117 }); 118})();
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.