PageSourceSearch

https://beyondyoga.com/cdn/shop/t/2162/assets/components-filter-sort.js?v=125273694945096604151789405379

js beyondyoga.com collected 2026-09-24 20:00:02 UTC 4,010 bytes, 1 lines download raw bytes

1import{debounce,refreshElements}from"@theme/global-utilities";export class FilterSort extends HTMLElement{constructor(){super(),this._selectors={container:"filter-sort",form:"[js-filter-form]",filter:"[js-filter]",filterInput:"[js-filter-input]",filterStatus:"[js-filter-status]",clearAll:"[js-clear-all]",loader:"loading-spinner"},this._refresh=["[js-filter]","[js-sort]"],this._events={change:"filter:change"},this._cache=[],this._debouncedOnSubmit=debounce(t=>{this._onSubmitHandler(t)},500)}connectedCallback(){if(this._scope=this.dataset.scope,this._form=this.querySelector(this._selectors.form),this._clearAll=this.querySelector(this._selectors.clearAll),this._loader=this.querySelector(this._selectors.loader),this._filterStatus=this.querySelector(this._selectors.filterStatus),this._setListeners(),!this._scope)throw new Error("filter-sort must have scope set. See file for docs.")}_setListeners(){window.addEventListener("popstate",this._onHistoryChange),this._form.addEventListener("input",this._debouncedOnSubmit),this._clearAll&&this._clearAll.addEventListener("click",this._onClearAllHandler),document.addEventListener("filter:change",this._onFilterChange),document.addEventListener("filter:clearAll",this._onClearAllHandler)}_renderComponent(t){const e=t.querySelector(`${this._selectors.container}[data-scope="${this._scope}"]`)||t.querySelector(this._selectors.container);refreshElements(this._refresh,e,this),this.querySelectorAll("s-accordion").forEach(t=>{t.connectedCallback()}),this._filterStatus=this.querySelector(this._selectors.filterStatus),this._updateFilterStatus()}_onSubmitHandler=t=>{t.preventDefault();const e=new FormData(this._form),r=new URLSearchParams(e).toString();this._updateFilterStatus(),this._propagateChange(r)};_updateFilterStatus=()=>{if(!this._filterStatus)return;const t=this._form.querySelectorAll(`${this._selectors.filterInput}:checked`);if(0===t.length)return void(this._filterStatus.textContent="");const e=[];t.forEach(t=>{const r=this._form.querySelector(`label[for="${t.id}"]`);if(!r)return;const s=r.querySelector(".filter-value-label__text"),i=s?s.textContent.trim():r.getAttribute("aria-label")||t.value,l=t.closest("fieldset"),a=l?l.querySelector("legend"):null,o=a?a.textContent.trim():"";o&&i?e.push(`${o}: ${i}`):i&&e.push(i)}),this._filterStatus.textContent=e.length>0?`${e.join(", ")} applied successfully`:`${t.length} filter${1===t.length?"":"s"} applied successfully`};_onClearAllHandler=t=>{t.preventDefault(),this._form&&this._form.querySelectorAll("[js-filter]").forEach(t=>{"checkbox"===t.type||"radio"===t.type?t.checked=!1:"SELECT"===t.tagName?t.selectedIndex=0:"INPUT"===t.tagName&&"text"===t.type&&(t.value="")}
1),this._filterStatus&&(this._filterStatus.textContent="");this._propagateChange("")};_onFilterChange=t=>{const{parsedHTML:e,scope:r}=t.detail;r!==this._scope&&this._renderComponent(e)};_onHistoryChange=t=>{const e=t.state?t.state.searchParams:FilterSort.searchParamsInitial;e!==FilterSort.searchParamsPrev&&(this._propagateChange(e,!1),this._onSubmitHandlerEvent=null)};async _propagateChange(t,e=!0){this._loader.setAttribute("loading","");const r=`${window.location.pathname}?${t}`,s=t=>t.url===r,i=this._cache.some(s)?this._markupFromCache(s):await this._markupFromFetch(r);document.dispatchEvent(new CustomEvent("filter:change",{detail:{parsedHTML:i,scope:this._scope}})),this._renderComponent(i),e&&history.pushState({searchParams:t},"",`${window.location.pathname}${t&&"?".concat(t)}`),this._loader.removeAttribute("loading","")}_markupFromCache(t){const e=this._cache.find(t).html;return(new DOMParser).parseFromString(e,"text/html")}_markupFromFetch(t){let e=this._cache;return fetch(t).then(t=>t.text()).then(r=>{const s=r,i=(new DOMParser).parseFromString(s,"text/html");return e=[...e,{html:s,url:t}],i})}}FilterSort.searchParamsInitial=window.location.search.slice(1),FilterSort.searchParamsPrev=window.location.search.slice(1),customElements.get("filter-sort")||customElements.define("filter-sort",FilterSort);

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.