PageSourceSearch

https://shop.marineconservation.org.au/cdn/shop/t/2/assets/quick-add.js?v=175128043763041801041744768034

js marineconservation.org.au collected 2026-09-24 19:00:28 UTC 5,393 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}this.productUrl=opener.dataset.productUrl,this.content.innerHTML="",super.open(opener);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(".cc-main-product .js-product"),this.renderProduct(opener)}opener.removeAttribute("aria-disabled")}renderProduct(opener){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/2/assets/quick-add.js.map?v=175128043763041801041744768034

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.