1import{config}from"@archetype-themes/scripts/config";import HeaderCart from"@archetype-themes/scripts/modules/cart-drawer";import{debounce,sizeDrawer}from"@archetype-themes/scripts/helpers/utils";import{EVENTS,publish,subscribe}from"@archetype-themes/utils/pubsub";class HeaderSection extends HTMLElement{constructor(){super(),this.namespace=".header",this.headerFooter=this.querySelector("#MobileNavFooter"),this.footerMenus=document.querySelector("#FooterMenus"),this.sectionID=this.getAttribute("data-section-id"),this.detailsEl=this.querySelectorAll('[data-section-type="header"] details[data-hover="true"]'),this.openTrigger=this.querySelector(".mobile-nav-trigger"),this.isMobileNavOpen=!1,this.searchTrigger=this.querySelector(".js-search-header"),this.inlineSearchContainer=this.querySelector(".site-header__search-container"),this.boundDocumentClick=this.handleDocumentClick.bind(this),this.init(),document.dispatchEvent(new CustomEvent("header-section:loaded",{detail:{sectionID:this.sectionID},bubbles:!0}))}init(){this.openTrigger.addEventListener("click",()=>{this.isMobileNavOpen?(publish(EVENTS.mobileNavClose),this.openTrigger.classList.remove("is-active"),this.isMobileNavOpen=!1):(publish(EVENTS.mobileNavOpen),this.isMobileNavOpen=!0,this.openTrigger.classList.add("is-active"))}),subscribe(EVENTS.mobileNavClosed,()=>{this.openTrigger.classList.remove("is-active"),this.isMobileNavOpen=!1}),this.searchTrigger.addEventListener("click",this.openInlineSearch.bind(this)),Shopify&&Shopify.designMode&&setTimeout(function(){window.dispatchEvent(new Event("resize"))},500),this.hoverMenu(),document.body.classList.contains("template-cart")||new HeaderCart,config.bpSmall&&this.cloneFooter(),window.addEventListener("resize",debounce(300,sizeDrawer))}hoverMenu(){this.detailsEl.forEach(detail=>{const summary=detail.querySelector("summary"),summaryLink=summary.dataset.link;summary.addEventListener("click",e=>{e.preventDefault(),detail.hasAttribute("open")?window.location.href=summaryLink:(detail.setAttribute("open",""),detail.setAttribute("aria-expanded","true"))}),detail.addEventListener("focusout",e=>{detail.contains(e.relatedTarget)||(detail.removeAttribute("open"),detail.setAttribute("aria-expanded","false"))}),detail.addEventListener("keydown",e=>{e.key==="Escape"&&detail.hasAttribute("open")&&(detail.removeAttribute("open"),detail.setAttribute("aria-expanded","false"),summary.focus())}),detail.addEventListener("mouseover",()=>{detail.hasAttribute("open")||(detail.setAttribute("open",""),detail.setAttribute("aria-expanded","true"))}),detail.addEventListener("mouseleave",()=>{detail.hasAttribute("open")&&(detail.removeAttribute("open"),detail.setAttribute("aria-expanded","false"))})})}cloneFooter(){if(!this.headerFooter)return;const clone=this.footerMenus.cloneNode(!0);clone.id="",this.headerFooter.appendChild(clone);const localizationForm=this.headerFooter.querySelector(".multi-selectors");localizationForm&&localizationForm.querySelectorAll("[data-disclosure-toggle]").forEach(el=>{const controls=el.getAttribute("aria-controls"),describedby=el.getAttribute("aria-describedby");el.setAttribute("aria-controls",controls+"-header"),el.setAttribute("aria-describedby",describedby+"-header");const list=document.getElementById(controls);list&&(list.id=controls+"-header");const label=document.getElementById(describedby);label&&(label.id=describedby+"-header")})}openInlineSearch(evt){evt.preventDefault(),evt.stopImmediatePropagation(),this.querySelector(".site-header__search-container").classList.add("is-active"),publish(EVENTS.predictiveSearchOpen,{detail:{context:"header"}}),this.enableCloseListeners()}enableCloseListeners(){setTimeout(()=>{document.addEventListener("click",this.boundDocumentClick)},0),this.searchCloseAllUnsubscribe=subscribe(EVENTS.predictiveSearchCloseAll,()=>{this.searchCloseAllUnsubscribe(),this.close()})}handleDocumentClick(evt){this.close(evt)}close(evt){if(evt&&evt.target.closest){if(evt.target.closest(".site-header__element--sub"))return;if(evt.target.closest("#SearchResultsWrapper"))return;if(evt.target.closest(".site-header__search-container"))return}publish(EVENTS.predictiveSearchClose),document.activeElement.blur(),this.inlineSearchContainer&&this.inlineSearchContainer.classList.remove("is-active"),document.removeEventListener("click",this.boundDocumentClick)}}customElements.define("header-section",HeaderSection); 2//# sourceMappingURL=/cdn/shop/t/21/assets/section-header.js.map?v=18369522156731752591732193179
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.