PageSourceSearch

https://theclosetonlineshop.com/cdn/shop/t/50/assets/component-pro…?v=90919270725362535291764912134

js theclosetonlineshop.com collected 2026-09-24 20:13:01 UTC 10,774 bytes, 2 lines download raw bytes

1customElements.get("product-information")||customElements.define("product-information",class extends HTMLElement{constructor(){super(),this.dataCache=new Map,this.init()}init(){this.cacheDOMElements(),this.bindEventHandlers()}cacheDOMElements(){this.sectionId=this.getAttribute("data-section-id"),this.originalSectionId=this.getAttribute("data-original-section-id"),this.isQuickView=this.dataset.quickView==="true",this.productForm=this.querySelector("product-form"),this.stickyContainer=this.classList.contains("product-sticky")?this:null,this.stickyHeader=document.querySelector(".header-section:has(.header-is-sticky)"),this.enableURLUpdate=this.dataset.enableUrlUpdate==="true",this.mainProductURL=this.dataset.url,this.showOnlyVariantMedia=this.dataset.showOnlyVariantMedia==="true"}connectedCallback(){this.setStickyOffset(),this.attachEventListeners(),this.prefetchVariantData(),this.isCombinedListing=this.dataset.isCombinedListing==="true"}disconnectedCallback(){this.removeEventListeners()}bindEventHandlers(){this.resizeHandler=this.handleResize.bind(this),this.onQuantityChange=this.handleQuantityChange.bind(this),this.onVariantChange=this.handleVariantChange.bind(this),this.onCartAdded=this.handleCartAdded.bind(this),this.resetQuantityInput=this.resetQuantityInput.bind(this),this.prefetchVariantData=this.prefetchVariantData.bind(this),this.resetQuantityInput=this.resetQuantityInput.bind(this)}attachEventListeners(){window.addEventListener("resize",this.resizeHandler),eventBus.on("qty:change",this.onQuantityChange),eventBus.on("variant:change",this.onVariantChange),eventBus.on("cart:added",this.onCartAdded)}removeEventListeners(){window.removeEventListener("resize",this.resizeHandler),eventBus.off("qty:change",this.onQuantityChange),eventBus.off("variant:change",this.onVariantChange),eventBus.off("cart:added",this.onCartAdded)}prefetchVariantData(){const variants=this.querySelectorAll("[data-product-variant]");
1variants.length&&variants.forEach(variant=>{const productFetchUrl=variant.getAttribute("data-product-fetch-url");productFetchUrl&&!this.dataCache.has(productFetchUrl)&&this.fetchProductData(productFetchUrl).catch(error=>{console.error(`Failed to fetch data for ${productFetchUrl}:`,error)})})}async fetchProductData(productFetchUrl){try{const response=await fetch(`${productFetchUrl}&section_id=${this.originalSectionId}`);if(!response.ok)throw new Error(`Network response was not ok for ${productFetchUrl}`);const data=await response.text(),productData=this.extractProductData(data);this.dataCache.set(productFetchUrl,productData)}catch(error){console.error(`Failed to fetch product data from ${productFetchUrl}:`,error)}}async fetchVariantData(productFetchUrl,context){(!this.dataCache.has(productFetchUrl)||window.Shopify.designMode)&&await this.fetchProductData(productFetchUrl),this.updateDOMWithData(context)}extractProductData(data){const htmlDocument=new DOMParser().parseFromString(data,"text/html"),productInformation=htmlDocument.querySelector("product-information"),quickViewContent=htmlDocument.querySelector("template[data-quick-view-product]")?.content,quickViewContentInformation=quickViewContent?.querySelector("product-information"),productDataElement=this.isQuickView&&quickViewContentInformation?quickViewContentInformation:productInformation,productMedia=htmlDocument.querySelector("[data-product-media-wrapper]"),quickViewMedia=quickViewContent?.querySelector("[data-product-media-wrapper]"),productBadges=this.isQuickView&&quickViewMedia?quickViewMedia.querySelectorAll("[data-product-badge]"):productMedia?.querySelectorAll("[data-product-badge]");if(this.isCombinedListing||productBadges.length){const productMediaElement=this.isQuickView&&quickViewMedia?quickViewMedia:productMedia,productDiv=document.createElement("div");return productDiv.setAttribute("data-url",productInformation?.getAttribute("data-url")),productDiv.appendChild(productMediaElement),productDiv.appendChild(productDataElement),productDiv.outerHTML}return productDataElement.outerHTML}handleResize(){window.Shopify.designMode&&this.setStickyOffset()}handleQuantityChange(event){if(this.productForm=this.querySelector("product-form"),this.formQuantityInput=this.productForm?.querySelector('[name="quantity"]'),this.formQuantityInput&&event.value){if(event.sectionId&&event.sectionId!==this.sectionId)return;this.formQuantityInput.value=event.value}}setStickyOffset(){this.stickyContainer&&this.stickyHeader&&(this.stickyContainer.style.top=`${this.stickyHeader.offsetHeight+30}px`)}async handleVariantChange(context){if(context.sectionId&&context.sectionId!==this.sectionId)return;if(this.currentVariant=context.variant,this.productFetchUrl=context.fetchURL,this.productUrl=context.productURL,!this.currentVariant){this.handleInvalidVariant();return}if(!this.productFetchUrl||!this.productUrl)return;this.toggleAddButton(this.currentVariant.available),this.dataCache.has(this.productFetchUrl)&&!window.Shopify.designMode?this.updateDOMWithData(context):await this.fetchVariantData(this.productFetchUrl,context),this.resetQuantityInput();const activeRadioInput=this.querySelector('input[type="radio"][name^="option-"]:checked');activeRadioInput&&!context.fromSlideChange&&activeRadioInput.focus()}handleInvalidVariant(){const productFetchUrl=this.buildRequestUrlWithParams();this.fetchNullVariantData(productFetchUrl),this.toggleAddButton(!1);const addButton=this.productForm?.querySelector('[name="add"]');if(!addButton)return;const addButtonSpan=addButton.querySelector("[data-add-to-cart-text]");if(!addButtonSpan)return;addButtonSpan.textContent=addButtonSpan.getAttribute("data-unavailable-text");const priceElement=this.querySelector("[data-product-price]");if(!priceElement)return;const priceElementSpan=priceElement.querySelector("span[data-price-text]");priceElementSpan&&(priceElementSpan.textContent=priceElementSpan.getAttribute("data-unavailable-text"))}handleCartAdded(event){event.sectionId&&event.sectionId!==this.sectionId||this.resetQuantityInput()}resetQuantityInput(){const quantityInput=this.productForm?.querySelector('[name="quantity"]');quantityInput&&(quantityInput.value="1")}buildRequestUrlWithParams(shouldFetchFullPage=!1){const params=[],optionValues=this.selectedOptionValues;return!shouldFetchFullPage&&params.push(`section_id=${this.sectionId}`),optionValues.length&&params.push(`option_values=${optionValues.join(",")}`),`${this.mainProductURL}?${params.join("&")}`}get selectedOptionValues(){return Array.from(this.querySelectorAll("li[data-product-variant][selected], input[data-product-variant]:checked")).map(({dataset})=>dataset.optionValueId)}async fetchNullVariantData(productFetchUrl){try{const response=await fetch(`${productFetchUrl}`);if(!response.ok)throw new Error(`Network response was not ok for ${productFetchUrl}`);const data=await response.text(),productData=this.extractProductData(data);this.dataCache.set(productFetchUrl,productData),this.updateNullVariant(data)}catch(error){console.error(`Failed to fetch product data from ${productFetchUrl}:`,error)}}updateNullVariant(data){const html=this.parseHTML(data),productInformation=html.querySelector("product-information");this.updateOptions(html,{productURL:productInformation?.getAttribute("data-url")})}updateDOMWithData(context){this.enableURLUpdate&&this.updateURL();const data=this.dataCache.get(context.fetchURL),html=this.parseHTML(data);this.updateDOM(html,context)}parseHTML(data){return new DOMParser().parseFromString(data,"text/html")}updateDOM(html,context={}){this.replaceElements(html,context),!context.fromSlideChange&&eventBus.emit("variant:updated",{variant:this.currentVariant,sectionId:this.sectionId,isCombinedListing:context.isCombinedListing})}toggleAddButton(enable){const addButton=this.productForm?.querySelector('[name="add"]');addButton&&addButton.toggleAttribute("disabled",!enable)}updateURL(){this.currentVariant&&window.history.replaceState({},"",`${this.productFetchUrl}`)}updateOptions(html,context={}){if(!html)return;const productInformation=html.querySelector(`product-information[data-url="${context.productURL}"]`);if(!productInformation)return;Array.from(this.querySelectorAll("[data-product-options]")).forEac
1h(currentElement=>{const currentUpdateId=currentElement.getAttribute("data-update-id"),newElement=productInformation.querySelector(`[data-update-id="${currentUpdateId}"]`);newElement&&currentElement.replaceWith(newElement)})}replaceElements(html,context={}){if(!html)return;const productInformation=html.querySelector(`product-information[data-url="${context.productURL}"]`);if(!productInformation)return;const currentElements=Array.from(this.querySelectorAll("[data-update-id]")),newElements=Array.from(productInformation.querySelectorAll("[data-update-id]"));currentElements.forEach(currentElement=>{const currentUpdateId=currentElement.getAttribute("data-update-id"),newElement=productInformation.querySelector(`[data-update-id="${currentUpdateId}"]`);newElement&&(newElement.hasAttribute("data-replace-content")?currentElement.replaceWith(newElement):currentElement.innerHTML=newElement.innerHTML)}),newElements.forEach(newElement=>{const newUpdateId=newElement.getAttribute("data-update-id");if(!this.querySelector(`[data-update-id="${newUpdateId}"]`)){let inserted=!1;for(let i=0;i<currentElements.length;i++){const currentElement=currentElements[i];if(currentElement.getAttribute("data-update-id")>newUpdateId){currentElement.insertAdjacentElement("beforebegin",newElement.cloneNode(!0)),inserted=!0;break}}inserted||this.appendChild(newElement.cloneNode(!0))}});const productMedia=html.querySelector("[data-product-media-wrapper]"),currentProductMedia=this.closest("[data-product-content-wrapper]")?.querySelector("[data-product-media-wrapper]"),currentBadges=currentProductMedia?currentProductMedia.querySelectorAll("[data-product-badge]"):null,newBadges=productMedia?productMedia.querySelectorAll("[data-product-badge]"):null;if(currentBadges&&newBadges&&!this.showOnlyVariantMedia&&currentBadges.forEach((badge,index)=>{const newBadge=newBadges[index];newBadge&&badge.replaceWith(newBadge)}),this.isCombinedListing&&context.isCombinedListing||this.showOnlyVariantMedia){const mediaSources=productMedia?.getAttribute("data-media-sources"),currentMediaSources=currentProductMedia?.getAttribute("data-media-sources");if(mediaSources===currentMediaSources)return;productMedia&&currentProductMedia&&currentProductMedia.replaceWith(productMedia),eventBus.emit("product:media:updated",{variant:this.currentVariant,sectionId:this.sectionId,isCombinedListing:context.isCombinedListing})}window.Shopify&&window.Shopify.PaymentButton&&window.Shopify.PaymentButton.init()}});
2//# sourceMappingURL=/cdn/shop/t/50/assets/component-product-information.js.map?v=90919270725362535291764912134

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.