PageSourceSearch

https://shop.fonobo.pl/cdn/shop/t/13/assets/component-product-form.min.js?v=128530044118416936161744969132

js fonobo.pl collected 2026-10-02 23:40:07 UTC 12,839 bytes, 1 lines download raw bytes

1(()=>{var t={845:t=>{self,t.exports=(()=>{"use strict";var t={};return((t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isArmadaLoaded=void 0,e.isArmadaLoaded=t=>{var e,i;const r=!0===(null===(i=null===(e=window.eight)||void 0===e?void 0:e.armada)||void 0===i?void 0:i.loaded);if(!t)return r;r?t():document.addEventListener("ARMADA:LOADED",t)},e.default=e.isArmadaLoaded})(0,t),t})()}},e={};function i(r){var s=e[r];if(void 0!==s)return s.exports;var n=e[r]={exports:{}};return t[r](n,n.exports,i),n.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";var t=i(845);class e extends HTMLElement{constructor(){super(),this.getAttribute("product")&&(this.sectionId=this.getAttribute("section-id"),this.setButton=this.setButton.bind(this))}connectedCallback(){(0,t.isArmadaLoaded)(this.init.bind(this)),document.addEventListener("ARMADA:TRANSLATION:SYNC",this.setButton(!1,!0))}renderBlocks(){this.blocks&&!this.hasBlocks&&(this.blocks.forEach((t=>{t&&this.appendChild(t.cloneNode(!0))})),this.setAttribute("has-blocks",!0))}init(){!this.isQuickAdd&&this.product&&(this.templateContent=this.querySelector(`template#product-form-${this.sectionId}-${this.product.id}
1`).content,this.isStickyForm&&this.renderBlocks(),this.loadingButtonHtml=this.templateContent.querySelector("[data-button-loading]").outerHTML,this.currentVariant=this.forceSelection?null:window.eight.productEngine.firstAvailableVariant(this.product),this.optionInputs=[],"dropdowns"===this.optionType?this.optionInputs=this.querySelectorAll('[data-name="product-option-select"]'):"buttons"===this.optionType&&(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.giftCardRecipientForm=this.querySelector("gift-card-recipient-form"),this.checkboxWrapper=this.querySelector("gift-card-recipient-form [data-checkbox-wrapper]"),this.giftCardRecipientCheckbox=this.querySelector("gift-card-recipient-form #show_gift_card_recipient_checkbox"),this.giftCardRecipientInputFieldsWrapper=this.querySelector("gift-card-recipient-form .gift_card_recipient_fields"),this.giftCardRecipientInputFields=this.querySelectorAll('gift-card-recipient-form [name*="Recipient"]'),window.eight.armada.elementRegistry.register({key:"product-form",assetPath:"/assets/component-product-form.min.js"}))}setPrice(){this.priceElem=document.querySelectorAll(`product-price[section-id="${this.sectionId}"]`),this.priceElem.forEach((t=>{let e=t.getAttribute("discount-value"),i=0;e&&"hide"!=e&&this.currentVariant.compare_at_price&&(i="value"==e?this.currentVariant.compare_at_price-this.currentVariant.price:Math.round(100*(this.currentVariant.compare_at_price-this.currentVariant.price)/this.currentVariant.compare_at_price/1)+"%"),t&&this.currentVariant&&(t.setAttribute("price",this.currentVariant.price),t.setAttribute("compare-at",this.currentVariant.compare_at_price),t.setAttribute("discount",`${i}`),t.setAttribute("unit-price",this.currentVariant.unit_price),t.setAttribute("unit-price-measurement",JSON.stringify(this.currentVariant.unit_price_measurement))),t.classList.contains("hidden")&&t.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((t=>{t.classList.add("hidden")})),this.setAttribute("summary-price-hidden",!0)))}setPickup(){const t=document.querySelector(`pickup-availability[section-id="${this.sectionId}"]`);if(!t)return;const e=this.currentVariant?this.currentVariant.id:null;t.setAttribute("data-variant-id",e)}setInventory(){if(this.inventoryElem=document.querySelector(`stock-level-indicator[section-id="${this.sectionId}"]`),!this.inventoryElem)return;const t=this.currentVariant?this.currentVariant.id:null;this.inventoryElem.setAttribute("variant-id",t)}setSku(){if(this.skuElem=this.querySelector('[data-armada-selector="product-form-sku"]'),!this.skuElem)return;const t=this.currentVariant?this.currentVariant.sku:"";this.skuElem.textContent=t}setValues(){this.currentVariant&&this.optionInputs&&this.currentVariant.options.forEach(((t,e)=>{"dropdowns"===this.optionType?this.optionInputs?.length>0&&(this.optionInputs[e].value=t):this.optionInputs.forEach((e=>{0===e.value.localeCompare(t,void 0,{sensitivity:"base"})&&(e.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 t=new Event("change",{bubbles:!0});this.installmentsSelect.dispatchEvent(t);const e=this.installmentsSelect.closest("form");e&&e.classList.contains("hidden")&&e.classList.remove("hidden")}get dynamicButtonsForm(){return this.querySelector("#dynamic-buttons-form")?this.querySelector("#dynamic-buttons-form"):null}checkDynamicButtons(){if(!this.dynamicButtonsForm)return;let t;t=!!this.currentVariant&&!!this.currentVariant.available,t?(this.dynamicButtonsForm.classList.remove("hidden"),this.setDynamicFormVariantId()):this.dynamicButtonsForm.classList.add("hidden")}setDynamicFormVariantId(){const t=this.querySelectorAll('input[data-name="dynamic_buttons_variant_id"]');t&&this.currentVariant&&t.forEach((t=>{t.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
1h((t=>{t.addEventListener("change",this.handleOptionChange.bind(this))})),this.buttons&&this.buttons.forEach((t=>{t.addEventListener("click",this.handleButtonClick.bind(this))}))}handleOptionChange(t){if(!this.allOptionsChosen)return;const e=this.currentVariant?this.currentVariant.title:"";if("id"===t.target.getAttribute("name")){const e=parseInt(t.target.options[t.target.selectedIndex].value);this.currentVariant=this.product.variants.find((t=>t.id===e))}else this.currentVariant=window.eight.productEngine.findVariant(this.product,this.optionIndexes);this.setButton(),window.eight.eventsEngine&&this.currentVariant.title!==e&&window.eight.eventsEngine.namedEvents.changeVariant(this.product.id,this.currentVariant.id,this.currentVariant,this.scopeId)}handleButtonClick(t){t.preventDefault();const e=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'),i={};e.forEach((t=>{let e=t.name.substring(t.name.lastIndexOf("[")+1,t.name.lastIndexOf("]"));const r=t.value;r&&(i[e]=r)})),this.setButton("loading");const r={items:[{id:this.currentVariant.id,quantity:this.quantity,selling_plan:this.sellingPlanId,properties:{...i}}]};window.eight.cartEngine.addToCart(r,"items",this.atcSuccess.bind(this),this.atcError.bind(this))}handleVariantChangeEvent(t){const{variantId:e,productId:i,scopeId:r}=t.detail;i===this.product.id&&r==this.scopeId&&(this.currentVariant=this.product.variants.find((t=>t.id===e)),this.updateFormVariant(this.currentVariant.id),this.setPrice(),this.setPickup(),this.setInventory(),this.setSku(),this.setValues(),this.setBasicSelectValue(),this.setInstallmentsSelectValue(),this.checkDynamicButtons(),this.setButton())}updateFormVariant(t){if(!t)return;this.querySelectorAll("#add-to-cart-form input[data-armada-variant-id]").forEach((e=>{e.value=t}))}atcSuccess(t){this.setButton("added"),this.giftCardRecipientCheckbox.checked&&(this.giftCardRecipientInputFields.forEach((t=>{t.value="",t.disabled=!0})),this.giftCardRecipientCheckbox.checked=!1,this.giftCardRecipientInputFieldsWrapper.classList.add("invisible","opacity-0"),this.giftCardRecipientForm.style.height=`${this.checkboxWrapper.offsetHeight}px`),this.cartTypePage&&(window.location=this.cartPageUrl),setTimeout((()=>{this.setButton(!1,!0)}),window.eight.product.addedTimeout)}atcError(t){console.warn("Error adding to cart: ",t),this.setButton(!1,!0)}setButton(t=!1,e=!1){if(this.buttons)if(t)"loading"===t?(this._buttons=this.buttons,this.buttonWraps.forEach((t=>{t.innerHTML=this.loadingButtonHtml}))):"added"===t&&(this._buttons.forEach((t=>{t.textContent=window.eight.translationEngine.strings.added,t.ariaLabel=window.eight.translationEngine.strings.successfully,t.disabled=!0,t.classList.add("opacity-20")})),this.buttonWraps.forEach(((t,e)=>{t.innerHTML=this._buttons[e].outerHTML})));else{let t=window.eight.translationEngine.strings.addToCart,i=!1;this.forceSelection&&!this.allOptionsChosen?(t=window.eight.translationEngine.strings.choose,i=!0,this.buttons.forEach((t=>{t.ariaLabel=window.eight.translationEngine.strings.chooseVariant,t.classList.add("opacity-20")}))):this.currentVariant?this.currentVariant.available?this.buttons.forEach((t=>{t.classList.remove("opacity-20")})):(t=window.eight.translationEngine.strings.soldOut,i=!0,this.buttons.forEach((t=>{t.ariaLabel=`'${this.currentVariant.title}' ${window.eight.translationEngine.strings.isSoldOut}`}))):(t=window.eight.translationEngine.strings.unavailable,i=!0,this.buttons.forEach((t=>{t.ariaLabel=window.eight.translationEngine.strings.isUnavailable}))),this.buttons.forEach((e=>{e.textContent=t,e.disabled=i})),e&&(this.buttonWraps.forEach(((t,e)=>{t.innerHTML=this.buttons[e].outerHTML})),this.buttons=this.querySelectorAll('[data-name="product-submit"][data-product-form-block="true"]'),this.buttons.forEach((t=>{t.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"true"===this.getAttribute("quick-add")}get isStickyForm(){return this.getAttribute("data-armada-sticky-form")}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 cartTypePage(){return document.querySelector("body").getAttribute("data-armada-cart-type-page")}get cartPageUrl(){return document.querySelector("body").getAttribute("data-cart-url")}get forceSelection(){return"true"===this.getAttribute("force-selection")}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"true"===this.getAttribute("summary-price-hidden")}get radioGroups(){let t=[];for(let e=1;e<=this.product.options.length;e++){const i=this.querySelectorAll(`[name="${this.sectionId}-product-${this.product.id}-option-${e}"]`);i.length>0&&t.push(i)}return t}get optionType(){return this.getAttribute("option-type")?this.getAttribute("option-type"):"dropdowns"}
1get optionIndexes(){if(!this.optionInputs)return!1;let t=[];return"dropdowns"===this.optionType?Array.from(this.optionInputs).forEach((e=>{const i=!0===e.options[0].disabled?e.selectedIndex-1:e.selectedIndex;t.push(i)})):"buttons"===this.optionType&&this.radioGroups.forEach((e=>{Array.from(e).forEach(((e,i)=>{e.checked&&t.push(i)}))})),t}get optionVals(){if(!this.optionInputs)return!1;if("dropdowns"===this.optionType)return Array.from(this.optionInputs).map((t=>t.value));if("buttons"===this.optionType){let t=[];return this.radioGroups.forEach(((e,i)=>{const r=Array.from(e).filter((t=>t.checked)).map((t=>t.value));t[i]=r[0]?r[0]:""})),t}}get allOptionsChosen(){return this.optionVals.length>0?!!this.optionVals&&!this.optionVals.some((t=>""===t)):!!this.basicSelect&&this.basicSelect.value>""}get blockOrder(){const t=this.getAttribute("block-order")?this.getAttribute("block-order"):"title,price,options,quantity,payment-buttons";return!!(t&&t.length>0)&&t.split(",")}get blocks(){if(!this.blockOrder)return!1;return this.blockOrder.map((t=>this.templateContent.querySelector(`[data-name="${t}"]`)))}get hasBlocks(){return"true"===this.getAttribute("has-blocks")}}window.customElements.define("product-form",e)})()})();

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.