File "navigation.min.js"

Full Path: /home/warrior1/public_html/themes/storefront/assets/js/navigation.min.js
File size: 2.97 KB
MIME-type: text/plain
Charset: utf-8

document.addEventListener("DOMContentLoaded",function(){const t=document.getElementById("site-navigation");if(t){const n=t.querySelector("button");if(n){const a=t.querySelector("ul");if(a){n.setAttribute("aria-expanded","false"),a.setAttribute("aria-expanded","false"),a.classList.add("nav-menu"),n.addEventListener("click",function(){t.classList.toggle("toggled");var e=t.classList.contains("toggled")?"true":"false";n.setAttribute("aria-expanded",e),a.setAttribute("aria-expanded",e)});const e=document.getElementsByClassName("handheld-navigation");if(0<e.length&&[].forEach.call(e[0].querySelectorAll(".menu-item-has-children > a, .page_item_has_children > a"),function(e){const t=document.createElement("button"),n=(t.setAttribute("aria-expanded","false"),t.classList.add("dropdown-toggle"),document.createElement("span"));n.classList.add("screen-reader-text"),n.appendChild(document.createTextNode(storefrontScreenReaderText.expand)),t.appendChild(n),e.parentNode.insertBefore(t,e.nextSibling),e.parentNode.classList.contains("current-menu-ancestor")&&(t.setAttribute("aria-expanded","true"),t.classList.add("toggled-on"),t.nextElementSibling.classList.add("toggled-on")),t.addEventListener("click",function(){for(t.classList.toggle("toggled-on");n.firstChild;)n.removeChild(n.firstChild);var e=t.classList.contains("toggled-on");t.setAttribute("aria-expanded",e),n.appendChild(document.createTextNode(e?storefrontScreenReaderText.collapse:storefrontScreenReaderText.expand)),t.nextElementSibling.classList.toggle("toggled-on")})}),[].forEach.call(document.querySelectorAll(".site-header .menu-item > a, .site-header .page_item > a, .site-header-cart a"),function(n){n.addEventListener("focus",function(){var e=document.querySelectorAll(".focus");[].forEach.call(e,function(e){e.contains(n)||(e.classList.remove("focus"),e.firstChild&&e.firstChild.classList&&e.firstChild.classList.remove("blocked"))});const t=n.parentNode;t.classList.add("focus")})}),[].forEach.call(document.querySelectorAll("body #page > :not( .site-header )"),function(e){e.addEventListener("click",function(){[].forEach.call(document.querySelectorAll(".focus, .blocked"),function(e){e.classList.remove("focus"),e.classList.remove("blocked")})})}),("ontouchstart"in window||window.navigator.maxTouchPoints)&&767<window.innerWidth){[].forEach.call(document.querySelectorAll(".site-header ul ul, .site-header-cart .widget_shopping_cart"),function(e){e.classList.add("sub-menu--is-touch-device")});let n=!1;[].forEach.call(document.querySelectorAll(".site-header .menu-item > a, .site-header .page_item > a, .site-header-cart a"),function(t){t.addEventListener("click",function(e){t.classList.contains("blocked")&&!1===n&&e.preventDefault(),n=!1}),t.addEventListener("pointerup",function(e){!t.classList.contains("blocked")&&"mouse"!==e.pointerType&&("cart-contents"===t.className&&t.parentNode.nextElementSibling&&""!==t.parentNode.nextElementSibling.textContent.trim()||t.nextElementSibling)?t.classList.add("blocked"):n=!0})})}}else n.style.display="none"}}});