1/*! 2 * 3 * ------ 4 * Note: customizing files reduces the store's ability to auto-update the theme. 5 * 6 * Disclaimer: 7 * This is a non minified version of a core js file, you can swap out the liquid / HTML link from the minified file if you choose to utilize this one. Any usage of these files is at the merchant/app/expert/agency's own risk, we take no responsibility for custom code changes. Support offerings from We Are Eight will be limited to rolling back to the latest theme version if these are utilized. 8 * 9 * License and acceptance of usage: 10 * 11 * Copyright (C) We Are Eight LTD - All Rights Reserved 12 * This file is part of Momentum theme provided for usage on Shopify online stores only. 13 * Unauthorized usage and or modification of this file outside of this Momentum utilized on a Shopify store without a valid license, is strictly prohibited. 14 * Unauthorized copying or distribution of this file, via any medium is strictly prohibited. 15 * Proprietary and confidential 16 * 17 * More information and official contact details: weareeight.com 18 * ------ 19 * 20 */(()=>{var __webpack_modules__={845:module=>{(function(e,d){module.exports=d()})(self,function(){return(()=>{"use strict";var e={};return((e2,d)=>{Object.defineProperty(d,"__esModule",{value:!0}),d.isArmadaLoaded=void 0,d.isArmadaLoaded=e3=>{var d2,o;const a=((o=(d2=window.eight)===null||d2===void 0?void 0:d2.armada)===null||o===void 0?void 0:o.loaded)===!0;if(!e3)return a;a?e3():document.addEventListener("ARMADA:LOADED",e3)},d.default=d.isArmadaLoaded})(0,e),e})()})}},__webpack_module_cache__={};function __webpack_require__(moduleId){var cachedModule=__webpack_module_cache__[moduleId];if(cachedModule!==void 0)return cachedModule.exports;var module=__webpack_module_cache__[moduleId]={exports:{}};return __webpack_modules__[moduleId](module,module.exports,__webpack_require__),module.exports}__webpack_require__.n=module=>{var getter=module&&module.__esModule?()=>module.default:()=>module;return __webpack_require__.d(getter,{a:getter}),getter},__webpack_require__.d=(exports,definition)=>{for(var key in definition)__webpack_require__.o(definition,key)&&!__webpack_require__.o(exports,key)&&Object.defineProperty(exports,key,{enumerable:!0,get:definition[key]})},__webpack_require__.o=(obj,prop)=>Object.prototype.hasOwnProperty.call(obj,prop);var __webpack_exports__={};(()=>{"use strict";var _weareeight_armada_dist_utils_isArmadaLoaded__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(845),_weareeight_armada_dist_utils_isArmadaLoaded__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_weareeight_armada_dist_utils_isArmadaLoaded__WEBPACK_IMPORTED_MODULE_0__);class ProductForm extends HTMLElement{constructor(){super(),this.getAttribute("product")&&(this.sectionId=this.getAttribute("section-id"),this.setButton=this.setButton.bind(this))}connectedCallback(){(0,_weareeight_armada_dist_utils_isArmadaLoaded__WEBPACK_IMPORTED_MODULE_0__.isArmadaLoaded)(this.init.bind(this)),document.addEventListener("ARMADA:TRANSLATION:SYNC",this.setButton(!1,!0))}
20init(){this.isQuickAdd||!this.product||(this.templateContent=this.querySelector(`template#product-form-${this.sectionId}-${this.product.id}`).content,this.loadingButtonHtml=this.templateContent.querySelector("[data-button-loading]").outerHTML,this.setInitialVariant(),this.optionInputs=[],this.optionType==="dropdowns"?this.optionInputs=this.querySelectorAll('[data-name="product-option-select"]'):this.optionType==="buttons"&&(this.optionInputs=this.querySelectorAll('[data-name="product-option-radio"]')),this.buttons=this.querySelectorAll('[data-name="product-submit"][data-product-form-block="true"]'),this.buttonWraps=this.querySelectorAll('[data-name="product-submit-wrapper"][data-product-form-block="true"]'),this.setInitialValues(),this.setEventListeners(),this.initScrollAnimations(),window.eight.armada.elementRegistry.register({key:"product-form",assetPath:"/assets/component-product-form.min.js"}))}setInitialVariant(){const variantId=new Proxy(new URLSearchParams(window.location.search),{get:(searchParams,prop)=>searchParams.get(prop)}).variant;if(variantId&&!this.forceSelection){const matchingId=this.product.variants.find(variant=>variant.id==variantId);this.currentVariant=this.forceSelection?null:matchingId,window.eight.eventsEngine&&window.eight.eventsEngine.namedEvents.changeVariant(this.product.id,this.currentVariant.id,this.currentVariant,this.scopeId)}else this.currentVariant=this.forceSelection?null:window.eight.productEngine.firstAvailableVariant(this.product)}setPrice(){this.priceElem=document.querySelectorAll(`product-price[section-id="${this.sectionId}"][use-variant="true"]`),this.priceElem.forEach(priceEl=>{let discountVal=priceEl.getAttribute("discount-value"),discountAmt=0;discountVal&&discountVal!="hide"&&this.currentVariant.compare_at_price&&(discountVal=="value"?discountAmt=this.currentVariant.compare_at_price-this.currentVariant.price:discountAmt=Math.round((this.currentVariant.compare_at_price-this.currentVariant.price)*100/this.currentVariant.compare_at_price/1)+"%"),priceEl&&this.currentVariant&&(priceEl.setAttribute("price",this.currentVariant.price),priceEl.setAttribute("compare-at",this.currentVariant.compare_at_price),priceEl.setAttribute("discount",`${discountAmt}`),priceEl.setAttribute("unit-price",this.currentVariant.unit_price),priceEl.setAttribute("unit-price-measurement",JSON.stringify(this.currentVariant.unit_price_measurement))),priceEl.classList.contains("hidden")&&priceEl.classList.remove("hidden")}),this.hideSummaryPrice()}hideSummaryPrice(){this.summaryPriceIsHidden||(this.summaryPrices=document.querySelectorAll('[data-armada-selector="product-form-summary-price"]'),this.summaryPrices.length&&(this.summaryPrices.forEach(summaryPrice=>{summaryPrice.classList.add("hidden")}),this.setAttribute("summary-price-hidden",!0)))}setPickup(){const pickupElem=document.querySelector(`pickup-availability[section-id="${this.sectionId}"]`);if(!pickupElem)return;const id=this.currentVariant?this.currentVariant.id:null;pickupElem.setAttribute("data-variant-id",id)}setValues(){!this.currentVariant||!this.optionInputs||this.currentVariant.options.forEach((option,index)=>{this.optionType==="dropdowns"?this.optionInputs?.length>0&&(this.optionInputs[index].value=option):this.optionInputs.forEach(input=>{input.value.localeCompare(option,void 0,{sensitivity:"base"})===0&&(input.checked=!0)})})}setBasicSelectValue(){this.basicSelect&&(this.currentVariant?this.basicSelect.value=this.currentVariant.id:this.basicSelect.value="")}setInstallmentsSelectValue(){if(!this.installmentsSelect)return;this.currentVariant?this.installmentsSelect.value=this.currentVariant.id:this.installmentsSelect.value="";const event=new Event("change",{bubbles:!0});this.installmentsSelect.dispatchEvent(event);const installmentsForm=this.installmentsSelect.closest("form");installmentsForm&&installmentsForm.classList.contains("hidden")&&installmentsForm.classList.remove("hidden")}get dynamicButtonsForm(){return this.querySelector("#dynamic-buttons-form")?this.querySelector("#dynamic-buttons-form"):null}checkDynamicButtons(){if(!this.dynamicButtonsForm)return;let variantAvailable;this.currentVariant&&this.currentVariant.available?variantAvailable=!0:variantAvailable=!1,variantAvailable?(this.dynamicButtonsForm.classList.remove("hidden"),this.setDynamicFormVariantId()):this.dynamicButtonsForm.classList.add("hidden")}setDynamicFormVariantId(){const dynamicFormIds=this.querySelectorAll('input[data-name="dynamic_buttons_variant_id"]');!dynamicFormIds||!this.currentVariant||dynamicFormIds.forEach(IdInput=>{IdInput.value=this.currentVariant.id})}setInitialValues(){this.forceSelection||(this.setValues(),this.setBasicSelectValue())}setEventListeners(){document.addEventListener(`${window.eight.constants.events["ARMADA:VARIANT:CHANGE"]}`,this.handleVariantChangeEvent.bind(this)),this.basicSelect&&this.basicSelect.addEventListener("change",this.handleOptionChange.bind(this)),this.optionInputs.forEac
20h(select=>{select.addEventListener("change",this.handleOptionChange.bind(this))}),this.buttons&&this.buttons.forEach(btn=>{btn.addEventListener("click",this.handleButtonClick.bind(this))})}initScrollAnimations(){const animationElements=this.querySelectorAll('[data-armada-animation$="-on-scroll"]');animationElements&&animationElements.forEach(animationElement=>{window.eight.animationEngine.initAnimation({items:[animationElement],elementToObserve:animationElement})})}handleOptionChange(e){if(!this.allOptionsChosen)return;const prevTitle=this.currentVariant?this.currentVariant.title:"";if(e.target.getAttribute("name")==="id"){const varId=parseInt(e.target.options[e.target.selectedIndex].value);this.currentVariant=this.product.variants.find(variant=>variant.id===varId)}else this.currentVariant=window.eight.productEngine.findVariant(this.product,this.optionIndexes);if(window.eight.eventsEngine&&this.currentVariant.title!==prevTitle){const variantValues=this.optionVals;window.eight.eventsEngine.namedEvents.changeVariant(this.product.id,this.currentVariant.id,this.currentVariant,this.scopeId),this.optionInputs.forEach((select,index)=>{select.value=variantValues[index],this.optionVals.push(variantValues[index])}),this.setButton()}}handleButtonClick(e){e.preventDefault();const productProperties=this.querySelectorAll('[name^=properties]:not([type="checkbox"]):not([type="radio"]):not([disabled]), [name^=properties][type="checkbox"]:not([disabled]):checked, [name^=properties][type="radio"]:not([disabled]):checked'),properties={};productProperties.forEach(property=>{let propertyKey=property.name.substring(property.name.lastIndexOf("[")+1,property.name.lastIndexOf("]"));propertyKey=propertyKey.replace(/\s+/g,"-").toLowerCase();const propertyValue=property.value;propertyValue&&(properties[propertyKey]=propertyValue)}),this.setButton("loading");const formData={items:[{id:this.currentVariant.id,quantity:this.quantity,selling_plan:this.sellingPlanId,properties:{...properties}}]};window.eight.cartEngine.addToCart(formData,"items",this.atcSuccess.bind(this),this.atcError.bind(this))}handleVariantChangeEvent(e){const{variantId,productId,scopeId}=e.detail;productId===this.product.id&&scopeId==this.scopeId&&(this.currentVariant=this.product.variants.find(v=>v.id===variantId),this.setPrice(),this.setPickup(),this.setValues(),this.setBasicSelectValue(),this.setInstallmentsSelectValue(),this.checkDynamicButtons(),this.setButton())}atcSuccess(data){this.setButton("added"),this.cartTypePage&&(window.location=this.cartPageUrl),setTimeout(()=>{this.setButton(!1,!0)},window.eight.product.addedTimeout)}atcError(data){console.warn("Error adding to cart: ",data),this.setButton(!1,!0)}setButton(mode=!1,reset=!1){if(this.buttons)if(mode)mode==="loading"?(this._buttons=this.buttons,this.buttonWraps.forEach(btnWrap=>{btnWrap.innerHTML=this.loadingButtonHtml})):mode==="added"&&(this._buttons.forEach(_btn=>{const _btnTextContainer=_btn.querySelector("[data-armada-button-text]")?_btn.querySelector("[data-armada-button-text]"):_btn;_btnTextContainer&&(_btnTextContainer.textContent=window.eight.translationEngine.strings.added),_btn.ariaLabel=window.eight.translationEngine.strings.successfully,_btn.disabled=!0,_btn.classList.add("opacity-20")}),this.buttonWraps.forEach((btnWrap,index)=>{btnWrap.innerHTML=this._buttons[index].outerHTML}));else{let buttonText=window.eight.translationEngine.strings.addToCart,disabled=!1;this.forceSelection&&!this.allOptionsChosen?(buttonText=window.eight.translationEngine.strings.choose,disabled=!0,this.buttons.forEach(btn=>{btn.ariaLabel=window.eight.translationEngine.strings.chooseVariant,btn.classList.add("opacity-20")})):this.currentVariant?this.currentVariant.available?this.preorder&&(inventory_policy[this.currentVariant.id]=="continue"||this.currentVariant.inventory_management==null)?(buttonText=window.eight.translationEngine.strings.preorder,this.buttons.forEach(btn=>{btn.ariaLabel=`'${this.currentVariant.title}' ${window.eight.translationEngine.strings.preorder}`})):this.buttons.forEach(btn=>{btn.classList.remove("opacity-20")}):(buttonText=window.eight.translationEngine.strings.soldOut,disabled=!0,this.buttons.forEach(btn=>{btn.ariaLabel=`'${this.currentVariant.title}' ${window.eight.translationEngine.strings.isSoldOut}`})):(buttonText=window.eight.translationEngine.strings.unavailable,disabled=!0,this.buttons.forEach(btn=>{btn.ariaLabel=window.eight.translationEngine.strings.isUnavailable})),this.buttons.forEach(btn=>{const btnTextContainer=btn.querySelector("[data-armada-button-text]")?btn.querySelector("[data-armada-button-text]"):btn;btnTextContainer.textContent=buttonText,btn.disabled=disabled}),reset&&(this.buttonWraps.forEach((btnWrap,index)=>{btnWrap.innerHTML=this.buttons[index].outerHTML}),this.buttons=this.querySelectorAll('[data-name="product-submit"][data-product-form-block="true"]'),this.buttons.forEach(btn=>{btn.addEventListener("click",this.handleButtonClick.bind(this))}))}}get product(){return window.eight.safeJSONParse(this.getAttribute("product"))}get scopeId(){return this.getAttribute("scope-id")}get isQuickAdd(){return this.getAttribute("quick-add")==="true"}get quantity(){return this.querySelector('input[name="quantity"]:not(.quantity-no-js-quantity)')?this.querySelector('input[name="quantity"]:not(.quantity-no-js-quantity)').value:1}get sellingPlanId(){return new FormData(this.querySelector("form")).get("selling_plan")}get forceSelection(){return this.getAttribute("force-selection")==="true"}get cartTypePage(){return document.querySelector("body").getAttribute("data-armada-cart-type-page")}get cartPageUrl(){return document.querySelector("body").getAttribute("data-cart-url")}get preorder(){return this.getAttribute("preorder")==="true"}get basicSelect(){return this.querySelector('select[data-armada-selector^="basic-product-select-"]')}get installmentsSelect(){return this.querySelector('[data-armada-selector="installments-select"]')}get summaryPriceIsHidden(){return this.getAttribute("summary-price-hidden")==="true"}get radioGroups(){let groups=[];for(let index=1;index<=this.product.options.length;index++){const elems=this.querySelectorAll(`[name="${this.sectionId}-product-${this.product.id}-option-${index}"]`);elems.length>0&&groups.push(elems)}return groups}get optionType(){return this.getAttribute("option-type")?this.getAttribute("option-type"):"dropdowns"}
20get optionIndexes(){if(!this.optionInputs)return!1;let indexes=[];return this.optionType==="dropdowns"?Array.from(this.optionInputs).forEach(s=>{const selIndex=s.options[0].disabled===!0?s.selectedIndex-1:s.selectedIndex;indexes.push(selIndex)}):this.optionType==="buttons"&&this.radioGroups.forEach(group=>{Array.from(group).forEach((s,radioIndex)=>{s.checked&&indexes.push(radioIndex)})}),indexes}get optionVals(){if(!this.optionInputs)return!1;if(this.optionType==="dropdowns")return Array.from(this.optionInputs).map(s=>s.value);if(this.optionType==="buttons"){let radioVals=[];return this.radioGroups.forEach((group,index)=>{const checkedVal=Array.from(group).filter(s=>s.checked).map(s=>s.value);radioVals[index]=checkedVal[0]?checkedVal[0]:""}),radioVals}}get allOptionsChosen(){return this.optionVals.length>0?this.optionVals?!this.optionVals.some(v=>v===""):!1:this.basicSelect?this.basicSelect.value>"":!1}}window.customElements.define("product-form",ProductForm)})()})(); 21//# sourceMappingURL=/cdn/shop/t/24/assets/component-product-form.js.map?v=124767448730236524461770623890
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.