PageSourceSearch

https://thisisholisticlondon.com/cdn/shop/t/50/assets/component-pr…?v=181573370496318028571786463752

js thisisholisticlondon.com collected 2026-10-06 21:37:12 UTC 8,193 bytes, 2 lines download raw bytes

1(()=>{class ProductForm extends HTMLElement{constructor(){super(),this.isProcessing=!1,this.cacheDOMElements(),this.onSubmitBound=this.onSubmit.bind(this),this.handleQuickViewModal=this.handleQuickViewModal.bind(this)}cacheDOMElements(){this.form=this.querySelector("form"),this.sectionId=this.getAttribute("data-section-id"),this.productInformation=this.closest("product-information"),this.cartAction=document.getElementById("PageContainer").dataset.cartAction,this.cartType=document.getElementById("PageContainer").dataset.cartType,this.cartCountIndicator=document.querySelector("[data-cart-count-indicator]"),this.giftWrapProductId=this.getAttribute("data-gift-wrap-product-id"),this.wethemeGlobal=document.querySelector("script#wetheme-global"),this.translationsObject=JSON.parse(this.wethemeGlobal.textContent),this.qtyErrorMessage=this.querySelector("[data-qty-error-message]")}connectedCallback(){this.form&&this.attachEventListeners()}attachEventListeners(){this.form.addEventListener("submit",this.onSubmitBound)}onSubmit(event){event.preventDefault(),!this.isProcessing&&this.prepareForSubmission()}prepareForSubmission(){this.cacheSubmissionElements(),this.checkRequiredInputs()&&(this.disableBlankInputs(),this.showLoadingState(),this.addItemsToCart())}cacheSubmissionElements(){this.loadingIcon=this.form.querySelector("[data-loading-icon]"),this.addToCartText=this.form.querySelector("[data-add-to-cart-text]"),this.addedText=this.form.querySelector("[data-cart-added-text]"),this.quantityInput=this.form.querySelector('[name="quantity"]'),this.quantity=this.quantityInput&&parseInt(this.quantityInput.value,10)||1}disableBlankInputs(){const elements=this.productInformation.querySelectorAll("input, textarea");this.blankElements=[],elements.forEach(element=>{element.value||(element.disabled=!0,this.blankElements.push(element))})}enableBlankInputs(){this.blankElements.forEach(element=>{element.disabled=!1}),this.blankElements=[]}fetchConfig(type="json"){return{method:"POST",headers:{"Content-Type":"application/json",Accept:`application/${type}`}}}checkRequiredInputs(){const requiredInputs=Array.from(this.productInformation.querySelectorAll("[required]:not(:disabled):not([data-input-ignore])"));this.clearErrorMessages();const invalidInputs=requiredInputs.filter(input=>input.type==="checkbox"?!input.checked:!input.value.trim());return invalidInputs.forEach(input=>this.applyErrorMessage(input)),invalidInputs.length===0}clearErrorMessages(){this.productInformation.querySelectorAll(".required-field-error").forEach(error=>error.remove())}applyErrorMessage(input){if(!input)return;const inputId=input.id,buttonWrapper=this.querySelector(".paymentButtonsWrapper"),errorContainer=input.closest(".input-wrapper")?.querySelector(".input-error-container"),errorMessage=input.hasAttribute("custom-dropdown-input")?this.translationsObject.translations.required_dropdown_error:input.type==="file"?this.translationsObject.translations.required_upload_error:input.type==="checkbox"?this.translationsObject.translations.required_checkbox_error:this.translationsObject.translations.required_input_error,errorElement=`<span id="${inputId}" class="required-field-error errors" style="display: block;">${errorMessage}</span>`,submitErrorMessage=input.type=="file"?input.closest("file-upload")?.dataset.errorMessage:input.dataset.errorMessage,submitErrorElement=`<span id="${inputId}Submit" class="required-field-error errors" style="display: block;" role="alert">${submitErrorMessage}</span>`;errorContainer?errorContainer.innerHTML=errorElement:input.insertAdjacentHTML("beforebegin",errorElement),buttonWrapper&&buttonWrapper.insertAdjacentHTML("beforebegin",submitErrorElement),input.focus(),input.type!="file"&&input.addEventListener("input",()=>{this.productInformation.querySelector(`#${inputId}.required-field-error`)?.remove(),this.querySelector(`#${inputId}Submit.required-field-error`)?.remove()},{once:!0})}giftWrapEnabled(){const giftWrapProp=this.closest("product-information")?.getAttribute("data-gift-wrap-prop");if(!giftWrapProp||!this.giftWrapProductId)return!1;const name=`properties[${giftWrapProp}]`,selector=`[name="${CSS.escape(name)}"]`;return!!this.productInformation.querySelector(selector)?.checked}async addItemsToCart(){this.isProcessing=!0;try{const mainProductAdded=await this.addProductToCart(routes.cart_add_url,this.fetchConfigWithBody());mainProductAdded&&this.giftWrapEnabled()&&await this.addProductToCart(routes.cart_add_url,this.additionalProductConfig(this.giftWrapProductId,this.quantity)),this.processResponse(mainProductAdded)}catch(error){console.error(`Error adding item(s) to cart: ${error.description||error.message}`)}finally{this.isProcessing=!1}}async addProductToCart(url,config){const response=await fetch(url,config);if(response.ok){if(this.cartType==="drawer"){const responseJson=await response.json();this.updateCartDrawer(responseJson)}}else console.error(`Error adding item to cart: ${response.description||response.statusText}`);return response}additionalProductConfig(productId,quantity){const additionalItemPayload={items:[{id:productId,quantity}]};return this.cartType==="drawer"&&(additionalItemPayload.sections="cart-drawer"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(additionalItemPayload)}}updateCartDrawer(responseJson){eventBus.emit("update:cart:drawer",responseJson)}async getCart(){try{return await(await fetch(`${routes.cart_url}?view=compare`)).json()}catch(error){console.error(`Error fetching cart: ${error.description||error.message}`)}}updateCartCountIndicator(){this.cartCountIndicator&&this.getCart().then(cart=>window.wetheme.updateCartCount(cart))}fetchConfigWithBody(){const config=this.fetchConfig("javascript");return config.headers["X-Requested-With"]="XMLHttpRequest",delete config.headers["Content-Type"],config.body=this.addSectionsParam(new FormData(this.form)),config}addSectionsParam(formData){return this.cartType==="drawer"&&formData.append("sections","cart-drawer"),formData}processResponse(response){response.ok&&this.hideLoadingState(),response.status===422&&(window.eventBus.emit("render:cart:drawer"),this.hideLoadingState(),this.qtyErrorMessage&&this.qtyErrorMessage.classList.remove("hidden")),eventBus.emit("cart:added",{sectionId:this.sectionId}),this.handleQuickViewModal(),this.enableBlankInputs()}openCartDrawer(){eventBus.emit("open:cart:drawer",{scrollToTop:!0})}handleQuickViewModal(){if(this.closest("[data-quick-view-product]")){const closeModal=()=>{document.body.classList.contains("theme-modal-open")&&eventBus.emit("theme:modal:hide")};this.cartAction==="show_added_message"&&this.addedText?setTimeout(closeModal,1500):closeModal()}}showLoadingState(){this.toggleElements(this.addToCartText,!1),this.toggleElements(this.loadingIcon,!0,"hidden"),this.toggleAddButton(!0)}hideLoadingState(){this.toggleElements(this.loadingIcon,!1,"hidden"),this.toggleCartActionDisplay()}toggleCartActionDisplay(){this.cartAction==="show_added_message"&&this.addedText?(this.addedText.style.display="block",setTimeout(()=>{this.toggleAddToCartText(!0),this.toggleAddButton(!1),this.updateCartCountIndicator()},2e3)):this.cartType==="drawer"&&this.cartAction==="go_to_or_open_cart"?(this.toggleAddToCartText(!0),this.openCartDrawer(),this.toggleAddButton(!1),this.updateCartCountIndicator()):(this.toggleAddToCartText(!0),this.toggleAddButton(!1),window.location=window.routes.cart_url)}toggleAddToCartText(show){this.addedText&&(this.addedText.style.display=s
1how?"none":"block"),this.addToCartText&&(this.addToCartText.style.display=show?"block":"none")}toggleElements(element,show,className){element&&(className?show?element.classList.remove(className):element.classList.add(className):element.style.display=show?"block":"none")}toggleAddButton(disable=!0){const addButton=this.querySelector('[name="add"]');addButton&&(addButton.disabled=disable)}disconnectedCallback(){this.form.removeEventListener("submit",this.onSubmitBound)}}customElements.get("product-form")||customElements.define("product-form",ProductForm)})();
2//# sourceMappingURL=/cdn/shop/t/50/assets/component-product-form.js.map?v=181573370496318028571786463752

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.