1class ProductGridContainer extends HTMLElement{constructor(){super(),this.selectors={container:"#ProductGridContainer",paginate:"[data-paginate]",btnLoadmore:"[data-load-more]",productGrid:"[data-products-grid]",columnSelector:".column-switcher button"}}connectedCallback(){this.init()}init=()=>{this.container=this.closest(this.selectors.container),this.sectionId=this.dataset.sectionId,this.domNodes=queryDomNodes(this.selectors,this),this.infiniteLoadingObserver=null,this.currentPage=1,this.save_key="foxtheme:grid-columns",this.initLoadMore(),this.columnSwitcher()};initLoadMore=()=>{const{paginate}=this.domNodes;if(!paginate||(this.paginateType=paginate.dataset?.paginate,this.totalPages=Number(paginate.dataset?.totalPages),this.paginateType==="number"||this.totalPages<=1))return;const{btnLoadmore}=this.domNodes;addEventDelegate({selector:this.selectors.btnLoadmore,handler:e=>{e.preventDefault(),this.loadMoreProducts()}}),this.paginateType==="infinite"&&(this.infiniteLoadingObserver=new IntersectionObserver(entries=>{entries.forEach(entry=>{entry.intersectionRatio===1&&this.loadMoreProducts()})},{threshold:1}),this.infiniteLoadingObserver.observe(btnLoadmore))};loadMoreProducts=()=>{const productGrid=document.querySelector(this.selectors.productGrid),btnLoadmore=document.querySelector(this.selectors.btnLoadmore),nextPage=this.currentPage+1;nextPage>this.totalPages||(this.toggleLoading(!0,btnLoadmore),fetchSection(this.sectionId,{fromCache:!0,params:{page:nextPage}}).then(html=>{html.querySelectorAll("[data-products-grid] .f-column").forEach(prodNode=>productGrid.appendChild(prodNode))}).catch(err=>console.error("Failed to load more products.",err)).finally(()=>{this.toggleLoading(!1,btnLoadmore),this.currentPage=nextPage,nextPage>=this.totalPages&&(btnLoadmore.parentNode.remove(),this.infiniteLoadingObserver&&this.infiniteLoadingObserver.unobserve(btnLoadmore))}))};toggleLoading=(loading,btnLoadmore)=>{if(btnLoadmore){const method=loading?"add":"remove";btnLoadmore.classList[method]("btn--loading")}};columnSwitcher=()=>{const data=localStorage.getItem(this.save_key);!window.FoxThemeSettings.designMode&&"1,2".includes(data)&&this.setColumn(data),addEventDelegate({selector:this.selectors.columnSelector,context:this,handler:(e,target)=>{e.preventDefault();const{column}=target.dataset;this.setColumn(column)}})};setColumn=column=>{const productGrid=document.querySelector(this.selectors.productGrid);if(!productGrid)return;const target=this.querySelector('.column-switcher button[data-column="'+column+'"]'),selected=this.querySelector('.column-switcher button[aria-selected="true"]');selected&&selected.removeAttribute("aria-selected"),target.setAttribute("aria-selected",!0);const method=column==="2"?"add":"remove";productGrid.classList[method]("f-grid-2-cols"),localStorage.setItem(this.save_key,column)}}customElements.define("product-grid-container",ProductGridContainer); 2//# sourceMappingURL=/cdn/shop/t/5/assets/product-grid-container.js.map?v=154666432700384239311746804008
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.