-
Notifications
You must be signed in to change notification settings - Fork 0
/
site-min.js
1 lines (1 loc) · 1.78 KB
/
site-min.js
1
var html=document.documentElement;html.className+=" js";const hasSubmenu=document.querySelectorAll("li.main-nav__menu-item--has-submenu");var timerSubmenu;Array.prototype.forEach.call(hasSubmenu,(function(e){e.addEventListener("mouseover",(function(){document.querySelector("li.main-nav__menu-item--has-submenu").classList.add("focus"),clearTimeout(timerSubmenu)})),e.addEventListener("mouseout",(function(){timerSubmenu=setTimeout((function(){document.querySelector(".focus").classList.remove("focus")}),1e3)}))}));var submenuItems=document.querySelectorAll("li.main-nav__menu-item--has-submenu");Array.prototype.forEach.call(submenuItems,(function(e){e.querySelector("a").addEventListener("click",(function(e){return"main-nav__menu-item--has-submenu"==this.parentNode.className?(this.parentNode.className="main-nav__menu-item--has-submenu open",this.setAttribute("aria-expanded","true")):(this.parentNode.className="main-nav__menu-item--has-submenu",this.setAttribute("aria-expanded","false")),e.preventDefault(),!1}))}));const submenuLinks=document.querySelectorAll(".main-nav__menu-item-link, .main-nav__submenu-item-link");submenuLinks.forEach((e=>{if(e.nextElementSibling){e.addEventListener("focus",(function(){this.parentElement.classList.add("focus"),this.setAttribute("aria-expanded","true")}));const t=e.nextElementSibling.querySelectorAll("a");t[t.length-1].addEventListener("blur",(function(){e.parentElement.classList.remove("focus"),e.setAttribute("aria-expanded","false")}))}}));var toggle=document.querySelector("#nav-toggle"),menu=document.querySelector("#menu");toggle.addEventListener("click",(function(){menu.classList.contains("js-is-active")?(menu.classList.remove("js-is-active"),toggle.classList.remove("js-is-active")):(menu.classList.add("js-is-active"),toggle.classList.add("js-is-active"))}));