1class CollectionFiltersForm extends HTMLElement{constructor(){super(),this.filterData=[],this.onActiveFilterClick=this.onActiveFilterClick.bind(this),this.onActiveFilterPrice=this.onActiveFilterPrice.bind(this),this.debouncedOnSubmit=debounce(event=>{this.onSubmitHandler(event)},500),this.querySelector("form").addEventListener("input",this.debouncedOnSubmit.bind(this)),window.addEventListener("popstate",this.onHistoryChange.bind(this))}onSubmitHandler(event){event.preventDefault();const formData=new FormData(event.target.closest("form")),searchParams=new URLSearchParams(formData).toString();this.updateURLHash(searchParams)}onActiveFilterClick(event){event.preventDefault(),this.toggleActiveFacets(),this.renderPage(new URL(event.currentTarget.href).searchParams.toString())}onActiveFilterPrice(event){event.preventDefault();const formData=new FormData(event.target.closest("form")),searchParams=new URLSearchParams(formData).toString();this.updateURLHash(searchParams)}onHistoryChange(event){const searchParams=event.state.searchParams||"";this.renderPage(searchParams,null,!1)}toggleActiveFacets(disable=!0){document.querySelectorAll(".js-facet-remove").forEach(element=>{element.classList.toggle("disabled",disable)})}renderPage(searchParams,event,updateURLHash=!0){const sections=this.getSections();document.getElementById("CollectionProductGrid").querySelector(".collection").classList.add("loading"),sections.forEach(section=>{const url=`${window.location.pathname}?section_id=${section.section}&${searchParams}`,filterDataUrl=element=>element.url===url;this.filterData.some(filterDataUrl)?this.renderSectionFromCache(filterDataUrl,event):this.renderSectionFromFetch(url,event)}),updateURLHash&&this.updateURLHash(searchParams)}renderSectionFromFetch(url,event){fetch(url).then(response=>response.text()).then(responseText=>{const html=responseText;this.filterData=[...this.filterData,{html,url}],this.renderFilters(html,event),this.renderProductGrid(html)})}renderSectionFromCache(filterDataUrl,event){const html=this.filterData.find(filterDataUrl).html;this.renderFilters(html,event),this.renderProductGrid(html)}renderProductGrid(html){console.log(html),document.getElementById("CollectionProductGrid").innerHTML=new DOMParser().parseFromString(html,"text/html").getElementById("CollectionProductGrid").innerHTML}renderProductCount(html){const count=new DOMParser().parseFromString(html,"text/html").getElementById("CollectionProductCount").innerHTML,container=document.getElementById("CollectionProductCount"),containerDesktop=document.getElementById("CollectionProductCountDesktop");container.innerHTML=count,container.classList.remove("loading"),containerDesktop&&(containerDesktop.innerHTML=count,containerDesktop.classList.remove("loading"))}renderFilters(html,event){const parsedHTML=new DOMParser().parseFromString(html,"text/html"),facetDetailsElements=parsedHTML.querySelectorAll("#CollectionFiltersForm .js-filter"),matchesIndex=element=>element.dataset.index===event.target.closest(".js-filter").dataset.index,facetsToRender=Array.from(facetDetailsElements).filter(element=>!matchesIndex(element)),countsToRender=Array.from(facetDetailsElements).find(matchesIndex);facetsToRender.forEach(element=>{document.querySelector(`.js-filter[data-index="${element.dataset.index}"]`).innerHTML=element.innerHTML}),this.renderActiveFacets(parsedHTML),countsToRender&&this.renderCounts(countsToRender,event.target.closest(".js-filter"))}renderActiveFacets(html){[".active-facets-desktop"].forEach(selector=>{const activeFacetsElement=html.querySelector(selector);activeFacetsElement&&(document.querySelector(selector).innerHTML=activeFacetsElement.innerHTML)}),this.toggleActiveFacets(!1)}renderAdditionalElements(html){[".mobile-facets__open",".mobile-facets__count",".sorting"].forEach(selector=>{html.querySelector(selector)&&(document.querySelector(selector).innerHTML=html.querySelector(selector).innerHTML)}),document.getElementById("CollectionFiltersFormMobile").closest("menu-drawer").bindEvents()}renderCounts(source,target){[".count-bubble",".facets__selected"].forEach(selector=>{const targetElement=target.querySelector(selector);source.querySelector(selector)&&targetElement&&(target.querySelector(selector).outerHTML=source.querySelector(selector).outerHTML)})}updateURLHash(searchParams){history.pushState({searchParams},"",`${window.location.pathname}${searchParams&&"?".concat(searchParams)}`),window.location.href=`${window.location.pathname}${searchParams&&"?".concat(searchParams)}`}
1getSections(){return[{id:"main-collection-product-grid",section:document.getElementById("main-collection-product-grid").dataset.id}]}}customElements.define("collection-filters-form",CollectionFiltersForm);class FacetRemove extends HTMLElement{constructor(){super(),this.querySelector("a").addEventListener("click",event=>{event.preventDefault(),(this.closest("collection-filters-form")||document.querySelector("collection-filters-form")).onActiveFilterClick(event)})}}customElements.define("facet-remove",FacetRemove);class FilterPrice extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{if(event.preventDefault(),event.target.classList.contains("active")==!1){document.querySelectorAll(".js-filter-price-trigger.active").length>0&&document.querySelector(".js-filter-price-trigger.active").classList.remove("active"),event.target.classList.add("active");const priceMin=event.target.getAttribute("data-min"),priceMax=event.target.getAttribute("data-max");document.getElementById("FilterPrice-Min").value=priceMin,document.getElementById("FilterPrice-Max").value=priceMax}else event.target.classList.remove("active"),document.getElementById("FilterPrice-Min").value="",document.getElementById("FilterPrice-Max").value="";(this.closest("collection-filters-form")||document.querySelector("collection-filters-form")).onActiveFilterPrice(event)})}}customElements.define("filter-price",FilterPrice);class FilterBrand extends HTMLElement{constructor(){super();var isMobile=/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent);isMobile||this.slide(),this.triggerFilter(),this.clearBrand()}slide(){const swiperHtml=this.querySelector(".swiper"),brandSwiper=new Swiper(swiperHtml,{slidesPerView:"auto",allowTouchMove:!0,navigation:{nextEl:"#Next-filter",prevEl:"#Prev-filter"}})}triggerFilter(){document.querySelectorAll(".js-trigger-filter-brand").forEach(brandButton=>brandButton.addEventListener("click",function(){const dataValue=this.getAttribute("data-value");document.querySelector('.js-label-brand[data-value="'+dataValue+'"]').click()}))}clearBrand(){document.querySelectorAll(".js-trigger-clear-brand").length>0&&document.querySelector(".js-trigger-clear-brand").addEventListener("click",function(){document.querySelector(".js-clear-brand a").click()})}}customElements.define("filter-brand",FilterBrand);class InfinitePagination extends HTMLElement{constructor(){super();const paginationBtn=this,paginationPosition=paginationBtn.offsetTop-window.innerHeight,url=paginationBtn.getAttribute("data-url");window.addEventListener("scroll",function(){if(document.querySelectorAll("infinite-pagination.loading").length==0){var bodyScroll=document.body.scrollTop,htmlScroll=document.documentElement.scrollTop;(bodyScroll>paginationPosition||htmlScroll>paginationPosition)&&paginationBtn.classList.contains("loading")==!1&&(paginationBtn.classList.add("loading"),fetch(url).then(response=>response.text()).then(responseText=>{const html=responseText;paginationBtn.classList.add("hidden"),paginationBtn.remove(),document.querySelector("#FilterPagination > ul").innerHTML+=new DOMParser().parseFromString(html,"text/html").getElementById("main-collection-product-grid").innerHTML}))}})}}customElements.define("infinite-pagination",InfinitePagination);class OpenFilter extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{document.querySelector("body").classList.add("open-filter")}),this.closeFilter()}closeFilter(){document.querySelectorAll(".js-close-filter").forEach(closeFilterBtn=>closeFilterBtn.addEventListener("click",()=>{document.querySelector("body").classList.remove("open-filter")}))}}customElements.define("open-filter",OpenFilter); 2//# sourceMappingURL=/cdn/shop/t/147/assets/collection-filters-form.js.map?v=158987160205456970291788402791
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.