1import{ThemeEvents,FiltersUpdatedEvent}from"@theme/events";class FilterAndSortComponent extends HTMLElement{constructor(){super(),this.filters=null,this.sorting=null,this.section=null,this.abortController=null}connectedCallback(){this.filters=this.querySelector("filter-component"),this.sorting=this.querySelector("sort-component"),this.section=this.closest(".shopify-section"),document.addEventListener(ThemeEvents.filtersChanged,this.#onFiltersChanged),this.section.addEventListener("click",this.#onPaginationClick),window.addEventListener("popstate",this.#onPopState)}disconnectedCallback(){document.removeEventListener(ThemeEvents.filtersChanged,this.#onFiltersChanged),this.section?.removeEventListener("click",this.#onPaginationClick),window.removeEventListener("popstate",this.#onPopState)}#onFiltersChanged=event=>{this.toggleLoading();const filterParams=event.detail.filter_params,sortingParams=event.detail.sorting_params,newUrl=this.#buildUrl(filterParams,sortingParams);this.#renderSection(newUrl),history.pushState({},"",newUrl)};#onPaginationClick=async event=>{const link=event.target.closest(".pagination a[href]");if(!link||link.hasAttribute("disabled"))return;event.preventDefault(),this.toggleLoading(),history.pushState({},"",link.href),await this.#renderSection(link.href)&&this.#scrollToSectionTop()};#onPopState=()=>{this.toggleLoading(),this.#renderSection(window.location.href)};#buildUrl(filterParams,sortingParams){return filterParams.length>0&&(filterParams="?"+filterParams),sortingParams.length>0&&(filterParams.length>0?sortingParams="&"+sortingParams:sortingParams="?"+sortingParams),`${window.location.pathname}${filterParams}${sortingParams}`}async#renderSection(requestUrl){this.abortController?.abort(),this.abortController=new AbortController;const{signal}=this.abortController;try{const responseText=await(await fetch(requestUrl,{signal})).text(),html=new DOMParser().parseFromString(responseText,"text/html"),newProducts=html.querySelector('[data-ref="main-collection-products"]');if(!newProducts)throw new Error("Aucune nouvelle source de page de collection trouv\xE9e");if(this.section.querySelector('[data-ref="main-collection-products"]').replaceWith(newProducts),this.filters){const ref=this.filters.getAttribute("data-ref"),newFiltersHtml=html.querySelector(`[data-ref="${ref}"]`);newFiltersHtml&&this.filters.renderFilters(newFiltersHtml)}return this.dispatchEvent(new FiltersUpdatedEvent),!0}catch(error){return error.name!=="AbortError"&&console.error(error),!1}finally{signal.aborted||this.toggleLoading()}}#scrollToSectionTop=()=>{if(!this.section)return;const headerHeight=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--header-height"))||0,targetY=this.section.getBoundingClientRect().top+window.scrollY-headerHeight;window.scrollTo({top:Math.max(0,targetY),behavior:"instant"})};toggleLoading(){this.classList.contains("filter-and-sort--loading")?this.classList.remove("filter-and-sort--loading"):this.classList.add("filter-and-sort--loading")}getCurrentFiltersParams(){return this.filters?.getFiltersParams()||""}getCurrentSortingParams(){return this.sorting?.getSortingParams()||""}}customElements.get("filter-and-sort-component")||customElements.define("filter-and-sort-component",FilterAndSortComponent); 2//# sourceMappingURL=/cdn/shop/t/66/assets/filter-and-sort.js.map?v=13655291104232041031788266116
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.