PageSourceSearch

https://www.tapsuk.com/cdn/shop/t/51/assets/search-ajax.js?v=140036231623735537041775109673

js tapsuk.com collected 2026-09-28 11:01:40 UTC 6,671 bytes, 2 lines download raw bytes

1class AjaxSearch extends ajaxSearchForm{constructor(){super(),this.cachedResults={},this.ajaxSearchResults=this.querySelector("[data-search-ajax]"),this.allajaxSearchInstances=document.querySelectorAll("search-ajax"),this.isOpen=!1,this.abortController=new AbortController,this.searchCond="",this.ajaxEventListeners()}ajaxEventListeners(){this.input.form.addEventListener("submit",this.ajaxFormSubmit.bind(this)),this.input.addEventListener("focus",this.inputFocus.bind(this)),this.addEventListener("focusout",this.inputFocusOut.bind(this)),this.addEventListener("keyup",this.inputKeyup.bind(this)),this.addEventListener("keydown",this.inputKeydown.bind(this))}ajaxgetInquiry(){return this.input.value.trim()}triggerChange(){super.triggerChange();const searchCondNew=this.ajaxgetInquiry();if((!this.searchCond||!searchCondNew.startsWith(this.searchCond))&&this.querySelector("#search-ajax-block")?.remove(),this.updateForCond(this.searchCond,searchCondNew),this.searchCond=searchCondNew,!this.searchCond.length){this.close(!0);return}this.getAjaxResults(this.searchCond)}ajaxFormSubmit(event){(!this.ajaxgetInquiry().length||this.querySelector('[aria-selected="true"] a'))&&event.preventDefault()}ajaxFormReset(event){super.ajaxFormReset(event),super.shouldResetForm()&&(this.searchCond="",this.abortController.abort(),this.abortController=new AbortController,this.clearInput(!0))}inputFocus(){const currentSearchTerm=this.ajaxgetInquiry();currentSearchTerm.length&&(this.searchCond!==currentSearchTerm?this.triggerChange():this.getAttribute("results")==="true"?this.ajaxOpen():this.getAjaxResults(this.searchCond))}inputFocusOut(){setTimeout(()=>{this.contains(document.activeElement)||this.close()})}inputKeyup(event){switch(this.ajaxgetInquiry().length||this.close(!0),event.preventDefault(),event.code){case"ArrowUp":this.checkOption("up");break;case"ArrowDown":this.checkOption("down");break;case"Enter":this.menuOption();break}}inputKeydown(event){(event.code==="ArrowUp"||event.code==="ArrowDown")&&event.preventDefault()}updateForCond(previousTerm,newTerm){const searchForTextElement=this.querySelector("[data-search-ajax-search-for-text]"),currentButtonText=searchForTextElement?.innerText;if(currentButtonText){if(currentButtonText.match(new RegExp(previousTerm,"g")).length>1)return;const newButtonText=currentButtonText.replace(previousTerm,newTerm);searchForTextElement.innerText=newButtonText}}checkOption(direction){if(!this.getAttribute("open"))return;const moveUp=direction==="up",selectedElement=this.querySelector('[aria-selected="true"]'),allVisibleElements=Array.from(this.querySelectorAll("li, button.search-ajax__item")).filter(element=>element.offsetParent!==null);let activeElementIndex=0;if(moveUp&&!selectedElement)return;let selectedElementIndex=-1,i=0;for(;selectedElementIndex===-1&&i<=allVisibleElements.length;)allVisibleElements[i]===selectedElement&&(selectedElementIndex=i),i++;if(this.statusElement.textContent="",!moveUp&&selectedElement?activeElementIndex=selectedElementIndex===allVisibleElements.length-1?0:selectedElementIndex+1:moveUp&&(activeElementIndex=selectedElementIndex===0?allVisibleElements.length-1:selectedElementIndex-1),activeElementIndex===selectedElementIndex)return;const activeElement=allVisibleElements[activeElementIndex];activeElement.setAttribute("aria-selected",!0),selectedElement&&selectedElement.setAttribute("aria-selected",!1),this.input.setAttribute("aria-activedescendant",activeElement.id)}menuOption(){const selectedOption=this.querySelector('[aria-selected="true"] a, button[aria-selected="true"]');selectedOption&&selectedOption.click()}getAjaxResults(searchCond){const queryKey=searchCond.replace(" ","-").toLowerCase();if(this.ajaxLoader(),this.cachedResults[queryKey]){this.ajaxSendresult(this.cachedResults[queryKey]);return}fetch(`${routes.ajax_search_url}?q=${encodeURIComponent(searchCond)}&section_id=search-ajax`,{signal:this.abortController.signal}).then(response=>{if(!response.ok){var error=new Error(response.status);throw this.close(),error}return response.text()}).then(text=>{const resultsMarkup=new DOMParser().parseFromString(text,"text/html").querySelector("#shopify-section-search-ajax").innerHTML;
1this.allajaxSearchInstances.forEach(predictiveSearchInstance=>{predictiveSearchInstance.cachedResults[queryKey]=resultsMarkup}),this.ajaxSendresult(resultsMarkup),$(".item-data").on("click",function(){$(this).parents(".option-block").find(".variant-option").removeClass("active-variant"),$(this).closest("form-wrap").addClass("active-variant");var it_img=$(this).attr("dataimg");$(this).parents(".single-product-wrap").find(".product-image .img1 img").attr("src",it_img),$(this).parents(".single-product-wrap").find(".product-image .img1 img").attr("srcset",it_img);var price=$(this).attr("dataprice"),compareprice=$(this).attr("datacompare"),stocks=$(this).attr("dataavailable");$(this).parents(".single-product-wrap").find(".price-box .new-price").text(Shopify.formatMoney(price,window.money_format)),compareprice>price?($(this).parents(".single-product-wrap").find(".price-box .old-price").show(),$(this).parents(".single-product-wrap").find(".price-box .old-price").html(Shopify.formatMoney(compareprice,window.money_format))):$(this).parents(".single-product-wrap").find(".price-box .old-price").hide()})}).catch(error=>{if(error?.code!==20)throw this.close(),error})}ajaxLoader(){this.statusElement=this.statusElement||this.querySelector(".search-ajax-status"),this.setAttribute("loading",!0)}ajaxInputText(statusText){this.statusElement.setAttribute("aria-hidden","false"),this.statusElement.textContent=statusText,setTimeout(()=>{this.statusElement.setAttribute("aria-hidden","true")},1e3)}ajaxSendresult(resultsMarkup){this.ajaxSearchResults.innerHTML=resultsMarkup,this.setAttribute("results",!0),this.sendInputresult(),this.ajaxOpen()}sendInputresult(){this.removeAttribute("loading"),this.ajaxInputText(this.querySelector("[data-search-ajax-live-region-count-value]").textContent)}ajaxOpen(){this.setAttribute("open",!0),this.input.setAttribute("aria-expanded",!0),this.isOpen=!0}close(ajaxCondRemove=!1){this.clearInput(ajaxCondRemove),this.isOpen=!1}clearInput(ajaxCondRemove=!1){ajaxCondRemove&&(this.input.value="",this.removeAttribute("results"));const selected=this.querySelector('[aria-selected="true"]');selected&&selected.setAttribute("aria-selected",!1),this.input.setAttribute("aria-activedescendant",""),this.removeAttribute("loading"),this.removeAttribute("open"),this.input.setAttribute("aria-expanded",!1)}}customElements.define("search-ajax",AjaxSearch);
2//# sourceMappingURL=/cdn/shop/t/51/assets/search-ajax.js.map?v=140036231623735537041775109673

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.