PageSourceSearch

https://momentfactory.com/cdn/shop/t/107/assets/search-results-page.js?v=1958054381348656391784231520

js momentfactory.com collected 2026-10-02 03:19:36 UTC 7,246 bytes, 2 lines download raw bytes

1const SEARCH_PAGE_GROUPS=new Set(["projects","news","lab","collections","reels","articles"]),SEARCH_PAGE_SUBMIT_DELAY=400;function normalizeSearchPageGroup(hash=""){const group=String(hash).replace(/^#/,"").toLowerCase();return SEARCH_PAGE_GROUPS.has(group)?group:"all"}function normalizeSearchPageQuery(query=""){return String(query).trim().replace(/\s+/g," ").toLowerCase()}function appendSearchGroupHash(url,group){const normalizedGroup=normalizeSearchPageGroup(`#${group}`),cleanUrl=String(url).split("#")[0];return normalizedGroup==="all"?cleanUrl:`${cleanUrl}#${normalizedGroup}`}function getNextSearchPageResultIndex(currentIndex,direction,resultCount){return resultCount===0?-1:direction==="up"?currentIndex<=0?resultCount-1:currentIndex-1:currentIndex<0||currentIndex>=resultCount-1?0:currentIndex+1}class CommandSearchPage extends HTMLElement{constructor(){super(),this.searchSubmitTimer=null,this.handleHashChange=this.handleHashChange.bind(this),this.handleCompositionEnd=this.handleCompositionEnd.bind(this),this.handleInput=this.handleInput.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.handlePointerOver=this.handlePointerOver.bind(this),this.handleFocusIn=this.handleFocusIn.bind(this),this.handleSubmit=this.handleSubmit.bind(this)}connectedCallback(){this.input=this.querySelector("[data-search-page-input]"),this.clearButton=this.querySelector("[data-search-page-clear]"),this.form=this.querySelector("[data-search-page-form]"),this.initialQuery=normalizeSearchPageQuery(this.input?.defaultValue),window.addEventListener("hashchange",this.handleHashChange),this.input?.addEventListener("input",this.handleInput),this.input?.addEventListener("compositionend",this.handleCompositionEnd),this.form?.addEventListener("submit",this.handleSubmit),this.addEventListener("keydown",this.handleKeydown),this.addEventListener("pointerover",this.handlePointerOver),this.addEventListener("focusin",this.handleFocusIn),this.syncActiveGroup(),this.toggleClearButton()}disconnectedCallback(){this.cancelSearchSubmit(),window.removeEventListener("hashchange",this.handleHashChange),this.input?.removeEventListener("input",this.handleInput),this.input?.removeEventListener("compositionend",this.handleCompositionEnd),this.form?.removeEventListener("submit",this.handleSubmit),this.removeEventListener("keydown",this.handleKeydown),this.removeEventListener("pointerover",this.handlePointerOver),this.removeEventListener("focusin",this.handleFocusIn)}handleHashChange(){this.syncActiveGroup()}handleCompositionEnd(){this.handleInput()}handleInput(event){if(this.cancelSearchSubmit(),event?.isComposing)return;this.toggleClearButton();const query=normalizeSearchPageQuery(this.input?.value);if(query.length===0){this.dataset.searchPagePerformed==="true"&&this.resetToEmptyState();return}query!==this.initialQuery&&(this.searchSubmitTimer=window.setTimeout(()=>this.submitSearch(query),SEARCH_PAGE_SUBMIT_DELAY))}handleSubmit(){this.cancelSearchSubmit()}syncActiveGroup(){const requestedGroup=normalizeSearchPageGroup(window.location.hash),activeGroup=requestedGroup==="all"||this.querySelector(`[data-search-page-category="${requestedGroup}"]`)?requestedGroup:"all";this.dataset.activeGroup=activeGroup,this.clearSelection(),this.querySelectorAll("[data-search-page-content] section[data-search-page-group]").forEach(section=>{section.hidden=activeGroup!=="all"&&section.dataset.searchPageGroup!==activeGroup}),this.querySelectorAll("[data-search-page-category]").forEach(category=>{category.dataset.searchPageCategory===activeGroup?category.setAttribute("aria-current","page"):category.removeAttribute("aria-current")}),this.updatePagination(activeGroup),this.updateSummary(activeGroup)}handleKeydown(event){if(event.isComposing||event.keyCode===229)return;const category=event.target.closest?.("[data-search-page-category]");if(category&&(event.key==="ArrowLeft"||event.key==="ArrowRight")){const categories=[...this.querySelectorAll("[data-search-page-category]")],currentIndex2=categories.indexOf(category),direction=event.key==="ArrowLeft"?-1:1,nextCategory=categories[(currentIndex2+direction+categories.length)%categories.length];event.preventDefault(),nextCategory.focus(),nextCategory.click();return}if(event.key!=="ArrowDown"&&event.key!=="ArrowUp")return;const rows=this.getVisibleRows();if(!rows.length)return;event.preventDefault();const currentIndex=rows.indexOf(event.target.closest?.("[data-search-page-row]")),nextIndex=getNextSearchPageResultIndex(currentIndex,event.key==="ArrowUp"?"up":"down",rows.length);this.selectRow(rows[nextIndex],!0)}handlePointerOver(event){const row=event.target.closest?.("[data-search-page-row]");row&&this.getVisibleRows().includes(row)&&this.selectRow(row,!1)}handleFocusIn(event){const row=event.target.closest?.("[data-search-page-row]");row&&this.selectRow(row,!1)}getVisibleRows(){const activeGroup=this.dataset.activeGroup||"all";return[...this.querySelectorAll("[data-search-page-row]")].filter(row=>{const group=row.closest("[data-search-page-group]");return!(!group||group.hidden||activeGroup==="all"&&row.closest("[data-search-page-preview-extra]"))})}selectRow(row,focus){if(this.clearSelection(),row.classList.add("is-selected"),!focus)return;row.focus({preventScroll:!0});const prefersReducedMotion=window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches;row.scrollIntoView?.({block:"nearest",behavior:prefersReducedMotion?"auto":"smooth"})}clearSelection(){this.querySelectorAll("[data-search-page-row].is-selected").forEach(row=>{row.classList.remove("is-selected")})}cancelSearchSubmit(){this.searchSubmitTimer!==null&&(window.clearTimeout(this.searchSubmitTimer),this.searchSubmitTimer=null)}submitSearch(query){this.searchSubmitTimer=null,!(!this.form||!this.input||normalizeSearchPageQuery(this.input.value)!==query||query===this.initialQuery)&&(typeof this.form.requestSubmit=="function"?this.form.requestSubmit():this.form.submit())}resetToEmptyState(){this.form&&window.location.assign(this.form.action)}updatePagination(activeGroup){this.querySelectorAll("[data-search-page-pagination] a").forEach(link=>{const baseUrl=link.dataset.searchPageBaseUrl||link.getAttribute("href");baseUrl&&(link.dataset.searchPageBaseUrl=baseUrl.split("#")[0],link.setAttribute("href",appendSearchGroupHash(link.dataset.searchPageBaseUrl,activeGroup)))})}updateSummary(activeGroup){const summaries=[...this.querySelectorAll("[data-search-page-summary-copy]")];if(!summaries.length)return;const activeSummary=summaries.find(summary=>summary.dataset.searchPageSummaryCopy===activeGroup)||summaries.find(summary=>summary.dataset.searchPageSummaryCopy==="all");
1summaries.forEach(summary=>{summary.hidden=summary!==activeSummary})}toggleClearButton(){!this.input||!this.clearButton||(this.clearButton.hidden=this.input.value.length===0)}}typeof customElements<"u"&&(typeof customElements.get!="function"||!customElements.get("command-search-page"))&&customElements.define("command-search-page",CommandSearchPage),typeof module<"u"&&(module.exports={appendSearchGroupHash,CommandSearchPage,getNextSearchPageResultIndex,normalizeSearchPageGroup,normalizeSearchPageQuery});
2//# sourceMappingURL=/cdn/shop/t/107/assets/search-results-page.js.map?v=1958054381348656391784231520

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.