https://www.schwinnfitness.com/cdn/shop/t/18/assets/product-info.js?v=166249574777008410211770743869
1customElements.get("product-info")||customElements.define("product-info",class extends HTMLElement{abortController=void 0;onVariantChangeUnsubscriber=void 0;pendingRequestUrl=null;preProcessHtmlCallbacks=[];postProcessHtmlCallbacks=[];cartUpdateUnsubscriber=void 0;constructor(){super()}get variantSelectors(){return this.querySelector("variant-selects")}get productId(){return this.getAttribute("data-product-id")}get sectionId(){return this.dataset.originalSection||this.dataset.section}get pickupAvailability(){return this.querySelector("pickup-availability")}get productForm(){return this.querySelector('form[is="product-form"]')}get quantityInput(){return this.querySelector("quantity-input input")}connectedCallback(){this.initializeProductSwapUtility(),this.onVariantChangeUnsubscriber=FoxTheme.pubsub.subscribe(FoxTheme.pubsub.PUB_SUB_EVENTS.optionValueSelectionChange,this.handleOptionValueChange.bind(this)),this.initQuantityHandlers(),this.currentVariant=this.getSelectedVariant(this),this.currentVariant&&this.updateMedia(this.currentVariant)}disconnectedCallback(){this.onVariantChangeUnsubscriber(),this.cartUpdateUnsubscriber?.()}initializeProductSwapUtility(){this.postProcessHtmlCallbacks.push(newNode=>{window?.Shopify?.PaymentButton?.init(),window?.ProductModel?.loadShopifyXR()})}handleOptionValueChange({data:{event,target,selectedOptionValues}}){if(!this.contains(event.target))return;this.disableButtons();const productUrl=target.dataset.productUrl||this.pendingRequestUrl||this.dataset.url,shouldSwapProduct=this.dataset.url!==productUrl,shouldFetchFullPage=this.dataset.updateUrl==="true"&&shouldSwapProduct,viewMode=this.dataset.viewMode||"main-product";this.renderProductInfo({requestUrl:this.buildRequestUrlWithParams(productUrl,selectedOptionValues,shouldFetchFullPage),targetId:target.id,callback:shouldSwapProduct?this.handleSwapProduct(productUrl,shouldFetchFullPage,viewMode):this.handleUpdateProductInfo(productUrl,viewMode)})}handleSwapProduct(productUrl,updateFullPage,viewMode){return html=>{const quickView=html.querySelector("#MainProduct-quick-view__content");quickView&&viewMode==="quick-view"&&(html=quickView.content.cloneNode(!0));const selector=updateFullPage?"product-info[id^='MainProduct']":"product-info",variant=this.getSelectedVariant(html.querySelector(selector));if(this.updateURL(productUrl,variant?.id),updateFullPage){if(document.querySelector("head title").innerHTML=html.querySelector("head title").innerHTML,HTMLUpdateUtility.viewTransition(document.querySelector("main"),html.querySelector("main"),this.preProcessHtmlCallbacks,this.postProcessHtmlCallbacks),HTMLUpdateUtility.viewTransition(document.getElementById("shopify-section-sticky-atc-bar"),html.getElementById("shopify-section-sticky-atc-bar"),this.preProcessHtmlCallbacks,this.postProcessHtmlCallbacks),!variant){this.setUnavailable();return}}else HTMLUpdateUtility.viewTransition(this,html.querySelector("product-info"),this.preProcessHtmlCallbacks,this.postProcessHtmlCallbacks);this.currentVariant=variant}}handleUpdateProductInfo(productUrl,viewMode){return html=>{const quickView=html.querySelector("#MainProduct-quick-view__content");quickView&&viewMode==="quick-view"&&(html=quickView.content.cloneNode(!0));const variant=this.getSelectedVariant(html);if(this.pickupAvailability?.update(variant),this.updateOptionValues(html),this.updateURL(productUrl,variant?.id),this.updateShareUrl(variant?.id),this.updateVariantInputs(variant?.id),!variant){this.setUnavailable();return}this.updateMedia(variant);const updateSourceFromDestination=(id,shouldHide=source=>!1)=>{const source=html.getElementById(`${id}-${this.sectionId}`),destination=this.querySelector(`#${id}-${this.dataset.section}`);source&&destination&&(destination.innerHTML=source.innerHTML,destination.classList.toggle("hidden",shouldHide(source)))};updateSourceFromDestination("price"),updateSourceFromDestination("Sku"),updateSourceFromDestination("Inventory"),updateSourceFromDestination("Badges"),updateSourceFromDestination("PricePerItem"),updateSourceFromDestination("Volume"),this.updateQuantityRules(this.sectionId,this.productId,html),updateSourceFromDestination("QuantityRules"),updateSourceFromDestination("VolumeNote"),HTMLUpdateUtility.viewTransition(document.querySelector(`#SizeChart-${this.sectionId}`),html.querySelector(`#SizeChart-${this.sectionId}`),this.preProcessHtmlCallbacks,this.postProcessHtmlCallbacks);const stickyAtcBar=document.getElementById("shopify-section-sticky-atc-bar");stickyAtcBar&&stickyAtcBar.classList.remove("hidden");const newAddButton=html.getElementById(`ProductSubmitButton-${this.sectionId}`),isDisabled=!newAddButton||newAddButton.hasAttribute("disabled");this.updateButtonsState(isDisabled,{updateText:!0,text:isDisabled?FoxTheme.variantStrings.soldOut:null}),FoxTheme.pubsub.publish(FoxTheme.pubsub.PUB_SUB_EVENTS.variantChange,{data:{sectionId:this.sectionId,html,variant}}
1),document.dispatchEvent(new CustomEvent("variant:changed",{detail:{variant}}))}}buildRequestUrlWithParams(url,optionValues,shouldFetchFullPage=!1){const params=[];return!shouldFetchFullPage&¶ms.push(`section_id=${this.sectionId}`),optionValues.length&¶ms.push(`option_values=${optionValues.join(",")}`),`${url}?${params.join("&")}`}getSelectedVariant(productInfoNode){const selectedVariant=productInfoNode.querySelector("variant-selects [data-selected-variant]")?.innerHTML;return selectedVariant?JSON.parse(selectedVariant):null}renderProductInfo({requestUrl,targetId,callback}){this.abortController?.abort(),this.abortController=new AbortController,fetch(requestUrl,{signal:this.abortController.signal}).then(response=>response.text()).then(responseText=>{this.pendingRequestUrl=null;const html=new DOMParser().parseFromString(responseText,"text/html");callback(html)}).then(()=>{document.querySelector(`#${targetId}`)?.focus()}).catch(error=>{error.name==="AbortError"?console.log("Fetch aborted by user"):console.error(error)})}updateOptionValues(html){const variantSelects=html.querySelector("variant-selects");variantSelects&&HTMLUpdateUtility.viewTransition(this.variantSelectors,variantSelects,this.preProcessHtmlCallbacks)}updateURL(url,variantId){this.dataset.updateUrl!=="false"&&window.history.replaceState({},"",`${url}${variantId?`?variant=${variantId}`:""}`)}updateVariantInputs(variantId){document.querySelectorAll(`#product-form-${this.dataset.section}, #product-form-installment-${this.dataset.section}`).forEach(productForm=>{const input=productForm.querySelector('input[name="id"]');input.value=variantId??"",input.dispatchEvent(new Event("change",{bubbles:!0}))})}updateMedia(variant){const productMedia=this.querySelector(`[id^="MediaGallery-${this.dataset.section}"]`);if(!productMedia)return;const setActiveMedia=()=>typeof productMedia.setActiveMedia=="function"?(productMedia.init(),productMedia.setActiveMedia(variant),!0):!1;setActiveMedia()||(this.timer=setInterval(()=>{setActiveMedia()&&clearInterval(this.timer)},100))}updateShareUrl(variantId){if(!variantId)return;const shareButton=document.getElementById(`ProductShare-${this.dataset.section}`);!shareButton||!shareButton.updateUrl||shareButton.updateUrl(`${window.shopUrl}${this.dataset.url}?variant=${variantId}`)}updateButtonsState(disabled,options={}){const{updateText=!1,text=null,updateStyles=!0}=options,productForm=document.getElementById(`product-form-${this.dataset.section}`);if(productForm){const addButton=productForm.querySelector('[name="add"]'),addButtonText=productForm.querySelector('[name="add"] > span');addButton&&(disabled?(addButton.setAttribute("disabled","disabled"),updateText&&text&&addButtonText&&(addButtonText.textContent=this.decoded(text))):productForm.querySelector('[name="id"]')?.value&&(addButton.removeAttribute("disabled"),updateText&&addButtonText&&(addButtonText.textContent=this.decoded(FoxTheme.variantStrings.addToCart))),updateStyles&&(addButton.style.pointerEvents=disabled?"none":"",addButton.style.opacity=disabled?"0.6":""))}['.sticky-atc-bar [name="add"]'].forEach(selector=>{document.querySelectorAll(selector).forEach(button=>{disabled?(button.setAttribute("disabled","disabled"),updateStyles&&(button.style.pointerEvents="none",button.style.opacity="0.6")):(button.removeAttribute("disabled"),updateStyles&&(button.style.pointerEvents="",button.style.opacity=""))})})}decoded(text){const tempDiv=document.createElement("div");return tempDiv.innerHTML=text,tempDiv.textContent}setUnavailable(){this.updateButtonsState(!0,{updateText:!0,text:FoxTheme.variantStrings.unavailable});const price=document.getElementById(`price-${this.dataset.section}`),inventory=document.getElementById(`Inventory-${this.dataset.section}`),sku=document.getElementById(`Sku-${this.dataset.section}`),volumePricing=document.getElementById(`Volume-${this.dataset.section}`),stickyAtcBar=document.getElementById("shopify-section-sticky-atc-bar");price&&price.classList.add("hidden"),inventory&&inventory.classList.add("hidden"),sku&&sku.classList.add("hidden"),volumePricing&&volumePricing.classList.add("hidden"),stickyAtcBar&&stickyAtcBar.classList.add("hidden")}initQuantityHandlers(){this.quantityInput&&(this.setQuantityBoundries(),this.hasAttribute("data-original-section")||(this.cartUpdateUnsubscriber=FoxTheme.pubsub.subscribe(FoxTheme.pubsub.PUB_SUB_EVENTS.cartUpdate,this.fetchQuantityRules.bind(this))))}setQuantityBoundries(){FoxTheme.pubsub.publish(FoxTheme.pubsub.PUB_SUB_EVENTS.quantityBoundries,{data:{sectionId:this.sectionId,productId:this.productId}})}fetchQuantityRules(){const currentVariantId=this.productForm?.productIdInput?.value;currentVariantId&&(this.querySelector(".quantity__rules-cart")?.classList.add("btn--loading"),fetch(`${this.getAttribute("data-url")}?variant=${currentVariantId}§ion_id=${this.sectionId}`).then(response=>response.text()).then(responseText=>{const parsedHTML=new DOMParser().parseFromString(responseText,"text/html");this.updateQuantityRules(this.sectionId,this.productId,parsedHTML)}).catch(error=>{console.error(error)}).finally(()=>{this.querySelector(".quantity__rules-cart")?.classList.remove("btn--loading")}))}updateQuantityRules(sectionId,productId,parsedHTML){this.quantityInput&&(FoxTheme.pubsub.publish(FoxTheme.pubsub.PUB_SUB_EVENTS.quantityRules,{data:{sectionId,productId,parsedHTML}}),this.setQuantityBoundries())}disableButtons(){this.updateButtonsState(!0)}enableButtons(){this.updateButtonsState(!1)}}); 2//# sourceMappingURL=/cdn/shop/t/18/assets/product-info.js.map?v=166249574777008410211770743869
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.