PageSourceSearch

https://swolverine.com/cdn/shop/t/50/assets/quick-add.js?v=67088665129004718141786679406

js swolverine.com collected 2026-09-24 18:10:27 UTC 8,070 bytes, 27 lines download raw bytes

1if(!customElements.get("quick-add-drawer")){class QuickAddDrawer extends SideDrawer{constructor(){super(),this.content=this.querySelector(".js-product-details"),this.form=this.querySelector("product-form"),this.notification=this.querySelector(".js-added-to-cart"),document.addEventListener("click",this.handleDocumentClick.bind(this)),this.addEventListener("on:variant:change",this.handleVariantChange.bind(this))}handleDocumentClick(evt){evt.target.matches(".js-quick-add")&&this.open(evt.target)}handleVariantChange(evt){if(evt.detail.variant){const variantMedia=evt.detail.variant.featured_media||null;variantMedia&&this.updateMedia(variantMedia.id)}let url=this.productUrl;if(evt.detail.variant){const separator=this.productUrl.split("?").length>1?"&":"?";url+=`${separator}variant=${evt.detail.variant.id}`}this.querySelectorAll(".js-prod-link").forEach(link=>{link.href=url})}async open(opener){if(opener.setAttribute("aria-disabled","true"),this.notification.hidden=!0,this.productUrl&&this.productUrl===opener.dataset.productUrl){opener.dataset.selectedColor&&this.setActiveVariant(opener),super.open(opener),opener.removeAttribute("aria-disabled");return}if(this.productUrl=opener.dataset.productUrl,this.content.innerHTML="",super.open(opener),!document.getElementById("quick-add-drawer-bg-fix")){const bgFixEl=document.createElement("style");bgFixEl.id="quick-add-drawer-bg-fix",bgFixEl.textContent="quick-add-drawer.drawer { background-color: #ffffff !important; color: #1a1a1a !important; } quick-add-drawer.drawer .drawer__header h2, quick-add-drawer.drawer .drawer__header .h2 { color: #1a1a1a !important; } quick-add-drawer.drawer .drawer__close-btn { color: #1a1a1a !important; }",document.head.appendChild(bgFixEl)}const response=await fetch(opener.dataset.productUrl);if(response.ok){const tmpl=document.createElement("template");tmpl.innerHTML=await response.text(),this.productEl=tmpl.content.querySelector(".swol-v3")||tmpl.content.querySelector(".js-product"),this.productScriptEl=this.productEl&&this.productEl.classList.contains("swol-v3")&&this.productEl.nextElementSibling&&this.productEl.nextElementSibling.tagName==="SCRIPT"?this.productEl.nextElementSibling:null,this.productStyleEl=this.productEl&&this.productEl.classList.contains("swol-v3")&&this.productEl.previousElementSibling&&this.productEl.previousElementSibling.tagName==="STYLE"?this.productEl.previousElementSibling:null,this.renderProduct(opener)}opener.removeAttribute("aria-disabled")}renderProduct(opener){if(this.productScriptEl){const scriptText=this.productScriptEl.textContent,sidMatch=scriptText.match(/var SID\s*=\s*'([^']+)'/),sid=sidMatch?sidMatch[1]:null;let html=this.productEl.outerHTML,script=scriptText;if(sid){const newSid=sid+"_quickadd";html=html.split(sid).join(newSid),script=script.split(sid).join(newSid)}this.content.innerHTML=html;const clonedVariantPicker=this.content.querySelector("variant-picker");if(clonedVariantPicker&&(clonedVariantPicker.dataset.updateUrl="false"),this.productStyleEl){const newStyleEl=document.createElement("style");newStyleEl.textContent=this.productStyleEl.textContent,this.content.appendChild(newStyleEl)}if(this.productStyleEl){const drawerOverrideEl=document.createElement("style");drawerOverrideEl.textContent="quick-add-drawer .swol-v3 { overflow-x: hidden; } quick-add-drawer .swol-v3__grid { grid-template-columns: 1fr !important; gap: 32px !important; padding: 0 20px 40px !important; } quick-add-drawer .swol-v3__gallery { position: static !important; max-width: 560px !important; margin: 0 auto !important; width: 100% !important; padding-top: 24px !important; }",this.content.appendChild(drawerOverrideEl)}const newScriptEl=document.createElement("script");newScriptEl.textContent=script,this.content.appendChild(newScriptEl);const form=this.content.querySelector("form");form&&form.addEventListener("submit",e=>{e.preventDefault();const formData=new FormData(form);fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(Object.fromEntries(formData))}).then(r=>(r.ok&&(document.dispatchEvent(new CustomEvent("cart:updated")),document.dispatchEvent(new CustomEvent("cart:build"))),r.json())).catch(()=>{})});return}const sectionId=this.productEl.dataset.section;this.productEl.innerHTML=this.productEl.innerHTML.replaceAll(sectionId,"quickadd");const variantPicker=this.productEl.querySelector("variant-picker");variantPicker&&(variantPicker.dataset.updateUrl="false");const sizeChartModal=this.productEl.querySelector("#size-chart");sizeChartModal&&(this.productEl.querySelector('[data-modal="size-chart"]').remove(),sizeChartModal.remove()),this.updateForm(),this.updateContent();let colorImageSet=!1;if(opener.dataset.selectedColor&&(this.setActiveVariant(opener),this.currentMediaId&&(colorImageSet=!0)),!colorImageSet){const activeMedia=this.productEl.querySelector(".media-viewer__item.is-active");activeMedia&&this.updateMedia(Number(activeMedia.dataset.mediaId))}}setActiveVariant(opener){this.querySelectorAll(".option-selector").forEach(optionSelector=>{const colorOption=optionSelector.querySelector(`.opt-btn[value="${opener.dataset.selectedColor}"]`);if(colorOption){colorOption.click();return}const firstBtn=optionSelector.querySelector(".opt-btn:not(.is-unavailable)");firstBtn&&!firstBtn.checked&&firstBtn.click()})}updateMedia(mediaId){if(this.currentMediaId===mediaId)return;this.currentMediaId=mediaId;const img=this.productEl.querySelector(`[data-media-id="${mediaId}"] img`);if(!img)return;const src=img.src?img.src.split("&width=")[0]:img.dataset.src.split("&width=")[0],container=this.querySelector(".quick-add-info__media"),width=container.offsetWidth,aspectRatio=img.width/img.height;container.innerHTML=`
2        <img src="${src}&width=${width}" srcset="${src}&width=${width}, ${src}&width=${width*2} 2x" width="${width*2}" height="${width*2/aspectRatio}" alt="${img.alt}">
3      `}updateContent(){this.content.innerHTML=`
4        <div class="quick-add-info grid mb-8">
5          <div class="quick-add-info__media"></div>
6          <div class="quick-add-info__details">
7            <div class="product-vendor-sku mb-2 text-sm">
8              ${this.getElementHtml(".product-vendor-sku")}
9            </div>
10            <div class="product-title mb-2">
11              <a class="h5 js-prod-link" href="${this.productUrl}">
12                ${this.getElementHtml(".product-title")}
13              </a>
14            </div>
15            <div class="product-price js-product-price">
16              ${this.getElementHtml(".product-info__price")}
17            </div>
18            <div class="mt-4">
19              <a href="${this.productUrl}" class="feature-link feature-link--light js-prod-link">${theme.strings.viewDetails}</a>
20            </div>
21          </div>
22        </div>
23        <div class="product-options">
24          ${this.getElementHtml(".product-options",".custom-option")}
25        </div>
26      `}updateForm(){const productForm=this.productEl.querySelector("product-form");productForm?(this.form.innerHTML=productForm.innerHTML,QuickAddDrawer.restoreScripts(this.form),this.form.init(
26),Shopify&&Shopify.PaymentButton&&Shopify.PaymentButton.init()):this.form.innerHTML=""}getElementHtml(selector,...additionalSelectors){const selectors=[selector].concat(additionalSelectors);let html="";return selectors.forEach(sel=>{const els=this.productEl.querySelectorAll(sel);Array.from(els).forEach(el=>{html+=el.innerHTML})}),html}addedToCart(){this.notification.hidden=!1}static restoreScripts(el){Array.from(el.querySelectorAll("script")).forEach(oldScriptEl=>{const newScriptEl=document.createElement("script");Array.from(oldScriptEl.attributes).forEach(attr=>{newScriptEl.setAttribute(attr.name,attr.value)});const scriptText=document.createTextNode(oldScriptEl.innerHTML);newScriptEl.appendChild(scriptText),oldScriptEl.parentNode.replaceChild(newScriptEl,oldScriptEl)})}}customElements.define("quick-add-drawer",QuickAddDrawer)}
27//# sourceMappingURL=/cdn/shop/t/50/assets/quick-add.js.map?v=67088665129004718141786679406

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.