1import AjaxRenderer from"util.ajax-renderer";import{debounce,executeJSmodules}from"util.misc";import{EVENTS}from"util.events";class ItemGrid extends HTMLElement{constructor(){super(),this.isAnimating=!1,this.abortController=new AbortController,this.selectors={productGrid:".product-grid",collectionGrid:".collection-grid__wrapper",sidebar:"#CollectionSidebar",filterBar:".collection-filter",toggle:"accordion-toggle"},this.sectionId=this.getAttribute("data-section-id"),this.enableScrollToTop=this.getAttribute("scroll-to-top")!=="false",this.ajaxRenderer=new AjaxRenderer({sections:[{sectionId:this.sectionId,nodeId:"AjaxContent"}],onReplace:this.onReplaceAjaxContent.bind(this)}),this.isStickyHeader=!1,this.resizeObserver=null,this.siteHeader=null}connectedCallback(){this.abortController=new AbortController,this.init(),this.siteHeader=document.querySelector(".site-header"),this.initResizeObserver(),document.querySelector('header[data-sticky="true"]')&&this.setFilterStickyPosition(),document.addEventListener(EVENTS.stickyHeaderChange,this.handleStickyHeaderChange.bind(this),{signal:this.abortController.signal}),document.addEventListener(EVENTS.toggleMobileFilters,this.handleToggleMobileFilters.bind(this),{signal:this.abortController.signal})}disconnectedCallback(){this.abortController.abort(),this.headerStickyChangeListener&&document.removeEventListener("headerStickyChange",this.headerStickyChangeListener),this.resizeObserver?.disconnect()}initResizeObserver(){!this.resizeObserver&&this.siteHeader&&(this.resizeObserver=new ResizeObserver(()=>{this.isStickyHeader&&this.setFilterStickyPosition()}),this.resizeObserver.observe(this.siteHeader))}handleToggleMobileFilters(evt){const{isOpen}=evt.detail;if(isOpen){document.dispatchEvent(new CustomEvent(EVENTS.sizeDrawer,{detail:{heights:[document.querySelector(this.selectors.filterBar).offsetHeight]}}));let scrollTo=this.getScrollFilterTop();window.scrollTo({top:scrollTo,behavior:"smooth"})}}init(){this.initSort(),this.initFilters(),this.initPriceRange(),this.initGridOptions()}handleStickyHeaderChange(evt){this.isStickyHeader=evt.detail.isSticky,this.isStickyHeader&&this.setFilterStickyPosition()}initSort(){this.queryParams=new URLSearchParams(window.location.search),document.addEventListener(EVENTS.sortSelected,evt=>{this.onSortChange(evt.detail.sortValue)})}onSortChange(sortValue=null){this.queryParams=new URLSearchParams(window.location.search),sortValue&&this.queryParams.set("sort_by",sortValue),this.queryParams.delete("page"),window.location.search=this.queryParams.toString()}initGridOptions(){this.grid=this.querySelector(this.selectors.productGrid),document.addEventListener(EVENTS.viewChange,this.handleViewChange.bind(this),{signal:this.abortController.signal})}handleViewChange(evt){this.grid.dataset.view=evt.detail.newView}initFilters(){document.querySelectorAll(this.selectors.filterBar).length&&(this.bindBackButton(),this.dispatchEvent(new CustomEvent(EVENTS.headerStickyCheck),{bubbles:!0}),this.isStickyHeader&&(this.setFilterStickyPosition(),document.addEventListener("headerStickyChange",debounce(500,this.setFilterStickyPosition.bind(this)),{signal:this.abortController.signal})),document.addEventListener(EVENTS.ajaxCollectionRender,this.handleAjaxCollectionRender.bind(this),{signal:this.abortController.signal}))}initPriceRange(){document.addEventListener("price-range:change",this.onPriceRangeChange.bind(this),{once:!0,signal:this.abortController.signal})}onPriceRangeChange(event){this.renderFromFormData(event.detail)}handleAjaxCollectionRender(evt){this.isAnimating||(this.isAnimating=!0,this.updateScroll(!0),this.startLoading(),evt.detail?.formData instanceof FormData&&this.renderFromFormData(evt.detail.formData),evt.detail?.newUrl instanceof URL&&this.renderCollectionPage(evt.detail.newUrl.searchParams))}onReplaceAjaxContent(newDom,section){this.fetchOpenCollapsibleFilters().forEach(selector=>{newDom.querySelectorAll(`[data-collapsible-id=${selector}] > details`).forEach(el=>el.open=!0)});const newContentEl=newDom.getElementById(section.nodeId);if(!newContentEl)return;document.getElementById(section.nodeId).innerHTML=newContentEl.innerHTML;const countEl=document.getElementById(section.nodeId).querySelector(".collection-filter__item--count");if(countEl){const count=countEl.innerText;document.querySelectorAll("[data-collection-count]").forEach(el=>{el.innerText=count})}const scripts=this.querySelectorAll(`#${section.nodeId} script[type="module"]`);executeJSmodules(scripts)}renderFromFormData(formData){const searchParams=new URLSearchParams(formData);this.renderCollectionPage(searchParams)}renderCollectionPage(searchParams,updateURLHash=!0){this.ajaxRenderer.renderPage(window.location.pathname,searchParams,updateURLHash).then(()=>{this.init(),this.updateScroll(!1),this.dispatchEvent(new CustomEvent("collection:reloaded",{bubbles:!0})),this.isAnimating=!1})}updateScroll(animate){if(!this.enableScrollToTop)return;let scrollTo=document.getElementById("AjaxContent").offsetTop;this.isStickyHeader&&this.siteHeader&&(scrollTo=scrollTo-this.siteHeader.offsetHeight),matchMedia("(max-width: 768px)").matches||(scrollTo-=10),animate?window.scrollTo({top:scrollTo,behavior:"smooth"}):window.scrollTo({top:scrollTo})}bindBackButton(){window.removeEventListener("popstate",this._popStateHandler),this._popStateHandler=state=>{if(state){const newUrl=new URL(window.location.href);this.renderCollectionPage(newUrl.searchParams,!1)}},window.addEventListener("popstate",this._popStateHandler,{signal:this.abortController.signal})}fetchOpenCollapsibleFilters(){const openDesktopCollapsible=Array.from(document.querySelectorAll(`${this.selectors.sidebar} ${this.selectors.toggle} > details[open]`)),openMobileCollapsible=Array.from(document.querySelectorAll(`${this.selectors.sidebar} ${this.selectors.toggle} > details[open]`));return[...openDesktopCollapsible,...openMobileCollapsible].map(toggle=>toggle.closest(this.selectors.toggle).getAttribute("data-collapsible-id"))}setFilterStickyPosition(){const headerHeight=this.siteHeader?this.siteHeader.offsetHeight-1:0;document.querySelector(this.selectors.filterBar).style.top=headerHeight+"px";const stickySidebar=this.querySelector("[data-sticky-sidebar]");stickySidebar&&(stickySidebar.style.top=headerHeight+30+"px")}startLoading(){this.querySelector(this.selectors.collectionGrid).classList.add("unload")}forceReload(){this.init()}getScrollFilterTop(){let scrollTop=window.pageYOffset||document.documentElement.scrollTop;return document.querySelector(this.selectors.filterBar).getBoundingClientRect().top+scrollTop}}customElements.define("item-grid",ItemGrid); 2//# sourceMappingURL=/cdn/shop/t/297/assets/list.filter-grid.js.map?v=101890920840529502621790816555
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.