PageSourceSearch

https://red-equipment.com.au/cdn/shop/t/36/assets/variants.js?v=78675043230104167611789571742

js red-equipment.com.au collected 2026-10-06 09:29:57 UTC 9,814 bytes, 2 lines download raw bytes

1const{getElements}=window.BAO.Utils,selectors={addToCart:"[data-product-add-to-cart]",addToCartText:"[data-product-add-to-cart-text]",backInStockTrigger:"[data-product-bis-trigger]",form:"[data-product-form]",price:"[data-product-price]",sku:"[data-product-sku]",variantIndicator:"[data-product-variant-indicator]",variantContent:"[data-product-variant-content]",variantDrawerTrigger:"[data-product-variant-trigger]"};class Variant{constructor(data){this.data=data}async setPrice(context){await window.BAO.sectionRenderer.fetch("product-price",`${context.dataset.url}?variant=${this.data.id}&section_id=product-price`).then(res=>{const myself=window.BAO.sectionRenderer.convertToDOM(res["product-price"]).querySelector(".shopify-section");if(!myself)return;getElements(`${selectors.price}[data-form-id='${context.dataset.formId}']`).forEach(el=>{el.innerHTML=myself.innerHTML})})}setAvailability(context){const endOfLife=context.dataset.endOfLife==="true",showBackInStock=!this.data.available&&!endOfLife;getElements(`${selectors.addToCart}[data-form-id='${context.dataset.formId}']`).forEach(el=>{el.disabled=!this.data.available,el.setAttribute("aria-hidden",showBackInStock)}),getElements(`${selectors.backInStockTrigger}[data-form-id='${context.dataset.formId}']`).forEach(el=>{el.setAttribute("aria-hidden",!showBackInStock),el.setAttribute("data-product-url",this.url.toString())});let addToCartText=window.theme.strings.addToCart;const preorderData=JSON.parse(document.querySelector("product-preorder")?.getAttribute("data-preorder-data")||"[]"),variantIdString=this.data.id.toString(),variantData=preorderData.find(item=>item.id===variantIdString),productTag=document.querySelector(".prd-Tags_Tag-preorder"),formFooter=document.querySelector(".prd-Form_Footer"),formFooterContainer=document.querySelector(".prd-Form_FooterAncillaries"),formFooterButtonEl=document.querySelector(".prd-Form_Button"),formFooterPreorderButtonIcon=document.querySelector(".prd-Form_ButtonIcon-preorder"),formFooterButtonIcon=document.querySelector(".prd-Form_ButtonIcon-regular"),formFixedBarAncillaries=document.querySelector(".prd-FixedBar_Ancillaries"),formFixedBarButtonEl=document.querySelector(".prd-FixedBar_Button"),formFixedBarPreorderButtonIcon=document.querySelector(".prd-FixedBar_ButtonIcon-preorder"),formFixedBarButtonIcon=document.querySelector(".prd-FixedBar_ButtonIcon-regular");variantData?.enable==="true"?(addToCartText=window.theme.strings.preOrder,productTag?.setAttribute("aria-hidden",!1),formFooter?.classList.add("prd-Form_Footer-preorder"),formFooterButtonEl?.classList.add("prd-Form_Button-preorder"),formFooterContainer?.setAttribute("aria-hidden",!0),formFooterPreorderButtonIcon?.setAttribute("aria-hidden",!1),formFooterButtonIcon?.setAttribute("aria-hidden",!0),formFixedBarAncillaries?.setAttribute("aria-hidden",!0),formFixedBarButtonEl?.classList.add("prd-FixedBar_Button-preorder"),formFixedBarPreorderButtonIcon?.setAttribute("aria-hidden",!1),formFixedBarButtonIcon?.setAttribute("aria-hidden",!0)):(productTag?.setAttribute("aria-hidden",!0),formFooter?.classList.remove("prd-Form_Footer-preorder"),formFooterButtonEl?.classList.remove("prd-Form_Button-preorder"),formFooterContainer?.setAttribute("aria-hidden",!1),formFooterPreorderButtonIcon?.setAttribute("aria-hidden",!0),formFooterButtonIcon?.setAttribute("aria-hidden",!1),formFixedBarAncillaries?.setAttribute("aria-hidden",!1),formFixedBarButtonEl?.classList.remove("prd-FixedBar_Button-preorder"),formFixedBarPreorderButtonIcon?.setAttribute("aria-hidden",!0),formFixedBarButtonIcon?.setAttribute("aria-hidden",!1)),getElements(`${selectors.addToCartText}[data-form-id='${context.dataset.formId}']`).forEach(el=>{el.textContent=this.data.available?addToCartText:window.theme.strings.soldOut})}updateInput(context){getElements(`form[action*="/cart/add"][id="${context.dataset.formId}"] [name="id"]`).forEach(input=>{input.value=this.id,input.dispatchEvent(new Event("change",{bubbles:!0}))})}updateIndicator(name,value,context){const variantIndicator=getElements(`${selectors.variantIndicator}[data-form-id='${context.dataset.formId}']`).find(el=>el.dataset.name===name);variantIndicator&&(variantIndicator.textContent=value)}updatePackageContent(name,value,context){const variantContent=getElements(`${selectors.variantContent}[data-form-id='${context.dataset.formId}']`).find(el=>el.dataset.name===name);variantContent&&(variantContent.textContent=value||"")}setUrl(){window.history.replaceState({path:this.url.toString()},"",this.url.toString())}setShareUrl(){const shareButtons=getElements("share-button");shareButtons.length!==0&&shareButtons.forEach(shareButton=>{shareButton.updateUrl(this.url.toString())})}get id(){return this.data.id}get url(){const url=new URL(window.location.href);return url.searchParams.set("variant",this.id.toString()),url}}export class VariantOptions extends window.BAO.CustomElement(){static get requiredElements(){return["data","option","option-choice"]}constructor(){super(),this.collectedVariants=[]}setupListeners(){super.setupListeners(),this.onVariantChange=this.onVariantChange.bind(this),this.listeners.add(this,"change",this.onVariantChange),this.updateOptionStates()}onVariantChange(e){if(!e.target.matches(this.els["option-choice"].selector))return;const changedOptionIndex=this.els.option.elements.findIndex(optionEl=>optionEl.contains(e.target));this.ensureValidSelections(changedOptionIndex),this.updateOptionStates();const variant=this.getVariant();if(!variant){this.setUnavailableCombination();return}variant.setAvailability(this),variant.setPrice(this),variant.updateInput(this),this.updateSelectedOptionContent(variant),window.BAO.dispatchEvent(window.BAO.EVENTS.PRODUCT.VARIANT_CHANGE,{variant}),variant.setUrl(),variant.setShareUrl(),e.target.closest("site-drawer")?.querySelector("[data-drawers-close]")?.click()}ensureValidSelections(changedOptionIndex){for(let optionIndex=changedOptionIndex+1;optionIndex<this.els.option.elements.length;
1optionIndex++){const optionEl=this.els.option.elements[optionIndex],choices=this.getChoices(optionEl),selectedChoice=choices.find(choice=>choice.checked);if(selectedChoice&&this.getMatchingVariants(optionIndex,selectedChoice.value).length>0)continue;const existingChoice=choices.find(choice=>this.getMatchingVariants(optionIndex,choice.value).some(variant=>variant.available))||choices.find(choice=>this.getMatchingVariants(optionIndex,choice.value).length>0);existingChoice&&(existingChoice.checked=!0)}}updateOptionStates(){this.els.option.elements.forEach((optionEl,optionIndex)=>{this.getChoices(optionEl).forEach(choice=>{const matchingVariants=this.getMatchingVariants(optionIndex,choice.value),exists=matchingVariants.length>0,available=matchingVariants.some(variant=>variant.available);choice.disabled=!exists,choice.dataset.variantExists=exists.toString(),choice.dataset.variantAvailable=available.toString();const item=choice.closest(".drw-Variants_Item"),label=item?.querySelector(selectors.variantDrawerTrigger);item&&(item.hidden=!exists),label&&(label.dataset.variantExists=exists.toString(),label.dataset.variantAvailable=available.toString(),label.setAttribute("aria-disabled",(!exists).toString()))})})}updateSelectedOptionContent(variant){this.els.option.elements.forEach(optionEl=>{const selectedChoice=this.getChoices(optionEl).find(choice=>choice.checked);selectedChoice&&(variant.updateIndicator(optionEl.dataset.name,selectedChoice.dataset.value||selectedChoice.value,this),variant.updatePackageContent(optionEl.dataset.name,selectedChoice.dataset.packageContent,this))})}getMatchingVariants(optionIndex,value){const selectedOptions=this.selectedOptions;return this.data.filter(variant=>{if(variant.options[optionIndex]!==value)return!1;for(let index=0;index<optionIndex;index++)if(variant.options[index]!==selectedOptions[index]?.value)return!1;return!0})}getChoices(optionEl){return getElements(this.els["option-choice"].selector,{context:optionEl})}setUnavailableCombination(){getElements(`${selectors.addToCart}[data-form-id='${this.dataset.formId}']`).forEach(el=>{el.disabled=!0,el.setAttribute("aria-hidden",!1)}),getElements(`${selectors.backInStockTrigger}[data-form-id='${this.dataset.formId}']`).forEach(el=>{el.setAttribute("aria-hidden",!0)}),getElements(`${selectors.addToCartText}[data-form-id='${this.dataset.formId}']`).forEach(el=>{el.textContent=window.theme.strings.soldOut})}createVariant(data){const variant=new Variant(data);return this.collectedVariants.push(variant),variant}getVariant(){if(!this.currentVariant)return null;const existingVariant=this.collectedVariants.find(variant=>variant.id===this.currentVariant.id);return existingVariant||this.createVariant(this.currentVariant)}get selectedOptions(){return this.throwError("selectedOptions needs to be implemented on this class"),[]}get currentVariant(){const selectedOptions=this.selectedOptions;return this.data.find(variant=>variant.options.every((option,index)=>selectedOptions[index]?.value===option))}get data(){return JSON.parse(this.els.data.element.innerText)}}export class VariantRadios extends VariantOptions{get selectedOptions(){return this.els.option.elements.map(el=>{const{name}=el.dataset,choice=getElements(this.els["option-choice"].selector,{context:el}).find(choiceEl=>choiceEl.checked);return{label:name,value:choice?.value}})}}export class VariantSelects extends VariantOptions{get selectedOptions(){return this.els.option.elements.map(el=>{const{name}=el.dataset;return{label:name,value:el.querySelector("select")?.value}})}}customElements.get("variant-radios")||customElements.define("variant-radios",VariantRadios),customElements.get("variant-selects")||customElements.define("variant-selects",VariantSelects);
2//# sourceMappingURL=/cdn/shop/t/36/assets/variants.js.map?v=78675043230104167611789571742

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.