PageSourceSearch

https://dz.diesel.com/on/demandware.static/Sites-DieselWW-Site/-/e…ent-ShopTheLookModalFormComponent.chunks.js

js diesel.com collected 2026-09-24 08:41:27 UTC 4,768 bytes, 1 lines download raw bytes

1(self.webpackChunkapp_project=self.webpackChunkapp_project||[]).push([[2476],{12114:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>o});var r=i(38302),n=i(12737),a=i(14863);class o extends r.default{get SELECTORS(){return{addToCart:".product-tile__action .shop-the-look-add-to-cart",select:".product-tile__action select",pid:'.product-tile__action [name="pid"]',variationProductPid:'.product-tile__action [name="productpid"]',form:".product-tile__action",price:".product-tile-body__price",cartSwitcherPanel:".js-cart-switcher-panel",variationSelect:function(e){return".shop-the-look__select-".concat(e)}}}constructor(e){super(e),this.pid=null,this.formElement=this.element.querySelector(this.SELECTORS.form),this.cartSwitcherPanel=document.querySelector(this.SELECTORS.cartSwitcherPanel),this.bindChange(),this.handleButton(),this.handleSubmit()}async getVarationInfo(){let e;try{const t=new FormData(this.formElement),i=new URLSearchParams(t).toString(),r=this.element.dataset.variationUrl;if(i&&r){const t=await(0,a.ZP)("".concat(r,"?").concat(i));e=await t.json()}}catch(e){console.error(e)}return e}handleSubmit(){this.element.addEventListener("submit",(async e=>{e.preventDefault();const t=[...this.element.querySelectorAll(this.SELECTORS.select)];let i=!1,r=!1,a="";if(t.forEach((e=>{0===e.selectedIndex&&0===e.value.length?(i=!0,a=e.parentNode.id,e.parentNode.classList.add("invalid")):e.parentNode.classList.remove("invalid"),e.options.length>1&&(r=!0)}
1)),!i)try{n.Z.emit("body:loading");const e=this.formElement.action,t=new FormData(this.formElement),i=t.get("productpid");t.set("pid",i);const a=await fetch(e,{method:"POST",body:t}),o=await a.json();if(this.handleCartSwitcher(o),o&&o.quantityTotal){o.hideAddToCartPopup=!0,n.Z.emit("update:minicart",o);const e=this.element.querySelector(".shop-the-look-add-to-cart");e.classList.add("d-none"),setTimeout((()=>{e.classList.remove("d-none")}),4e3),r?n.Z.emit("product:afterAddToCartModalVueCustomizeSelect"):n.Z.emit("product:afterAddToCartModalVue")}}catch(e){console.error(e)}finally{n.Z.emit("body:loaded")}}))}async handleCartSwitcher(e){if(e&&e.cartSwitcher&&e.handleWithCartSwitcher){if(!this.cartSwitcherPanel){const t=document.createElement("div");return t.innerHTML=e.cartSwitcher.template,document.body.appendChild(t),this.cartSwitcherPanel=document.querySelector(this.SELECTORS.cartSwitcherPanel),void n.Z.once("toggler:setup",(()=>{this.openCartSwitcher(e)}))}this.openCartSwitcher(e)}}async openCartSwitcher(e){const t=e.cartSwitcher.callbackURL,i=JSON.stringify(e.cartSwitcher.data),r=this.cartSwitcherPanel.querySelector(".side-panel__inner");this.cartSwitcherPanel.offsetWidth,this.cartSwitcherPanel.componentInstance.open();const a=this.cartSwitcherPanel.querySelector(".js-cart-switcher-body");a.innerHTML="";try{n.Z.emit("loader:start",{element:r});const e=await fetch(t,{method:"POST",body:i}),o=await e.json();if(o.error)throw new Error(o.message);
1a.innerHTML=o.renderedTemplate,n.Z.emit("cartswitcher:open",{tile:this.element,type:"shop-the-look"}),n.Z.emit("sidepanel:contentLoaded")}catch(e){console.error(e)}finally{n.Z.emit("loader:end",{element:r})}}handleButton(e){const t=[...this.element.querySelectorAll(this.SELECTORS.select)].filter((e=>e.length));if(t.filter((e=>!!e.value)).map((e=>e.value)).length>=t.length){if(e){const t=this.element.querySelector(this.SELECTORS.variationProductPid);this.element.querySelector(this.SELECTORS.addToCart).setAttribute("data-pid",e),t.setAttribute("value",e),this.pid=e}else this.pid=null,t.forEach((e=>{e.dispatchEvent(new Event("change"))}));return!0}}handleResult(e){if(!e)return!1;const t=e.product;if(!t)return!1;this.updatePrice(t.renderedPrice),this.handleButton(t.id);const i=t.variationAttributes;for(let e=0;e<i.length;e++)this.updateOptions(i[e].id,i[e].values)}updateOptions(e,t){const i=this.SELECTORS.variationSelect(e),r=this.element.querySelector(i);if(this._clearOptions(r),1!==t.length||"UNI"!==t[0].id)for(let e=0;e<t.length;e++){const i=t[e];r.add(this._generateOptionElement(i.id,i.value,i.selected,!i.selectable))}}_clearOptions(e){for(let t=e.length-1;t>0;t--)e[t].value&&e[t].remove()}_generateOptionElement(e,t,i,r){const n=new Option(t,e);return n.selected=i,n.disabled=r,n}updatePrice(e){this.element.querySelector(this.SELECTORS.price).outerHTML=e}updatePrice(e){this.element.querySelector(this.SELECTORS.price).outerHTML=e}bindChange(){[...this.element.querySelectorAll(this.SELECTORS.select)].forEach((e=>{e.addEventListener("change",(async e=>{n.Z.emit("loader:start",{element:this.element});const t=await this.getVarationInfo();this.handleResult(t);const i=e.srcElement.parentElement;i.classList.contains("invalid")&&i.classList.remove("invalid"),n.Z.emit("loader:end",{element:this.element})}))}))}}}}]);

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.