PageSourceSearch

https://diamondprotech.co/cdn/shop/t/35/assets/product.js?v=100655248903770262161775108815

js diamondprotech.co collected 2026-10-10 02:30:19 UTC 22,906 bytes, 91 lines download raw bytes

1window.onSubmitAtcForm=async(form,event)=>{event.preventDefault();const btn=form.querySelector(".btn-atc");btn.innerHTML=`
2        <div class="spinner-border spinner-border-sm" role="status">
3            <span class="visually-hidden">Loading...</span>
4        </div>
5    `,form.classList.add("loading");const response=await fetch("/cart/add.js",{method:"POST",body:new FormData(form)});if(form.classList.remove("loading"),btn.innerHTML=window.theme.product.addedToCart,setTimeout(()=>{btn.innerHTML=btn.dataset.textAddToCart},2e3),window.refreshCartContents(response),form.hasAttribute("data-ecomify-upsell-modal")||btn.closest(".modal"))return;document.querySelector("#offcanvas-cart")&&bootstrap.Offcanvas.getOrCreateInstance("#offcanvas-cart").show(),(window._learnq||[]).push(["track","Added to Cart",{ProductID:form.dataset.productId,Name:form.dataset.productTitle,URL:form.dataset.productUrl}])},window.onClickAtcFormVariant=async(btn,event)=>{const form=btn.closest("form");form.querySelector('[name="id"]').value=btn.dataset.variantId,window.onSubmitAtcForm(form,event)},window.onChangeProductOption=async input=>{const selectedOptions=[];input.closest("form").querySelectorAll(".product-option").forEach(elem=>{elem.type==="radio"?elem.checked&&selectedOptions.push(elem.value):selectedOptions.push(elem.value)});const selectedVariant=JSON.parse(input.closest("form").dataset.variants).find(variant=>JSON.stringify(variant.options)===JSON.stringify(selectedOptions));console.log(selectedVariant);const btn=input.closest("form").querySelector(".btn-atc");if(selectedVariant){input.closest("form").querySelector('[name="id"]').value=selectedVariant.id,selectedVariant.available?(btn.disabled=!1,btn.querySelector(".btn-atc-text").textContent=window.theme.product.addToCart):(btn.disabled=!0,btn.querySelector(".btn-atc-text").textContent=window.theme.product.soldOut),selectedVariant.compare_at_price>selectedVariant.price?input.closest(".product-content").querySelector(".product-price").innerHTML=`
6                <span class="product-price-compare text-muted me-3">
7                    <span class="visually-hidden">
8                        ${window.theme.product.priceFrom} &nbsp;
9                    </span>
10                    <s>
11                        ${Shopify.formatMoney(selectedVariant.compare_at_price)}
12                    </s>
13                </span>
14                <span class="product-price-final">
15                    <span class="visually-hidden">
16                        ${window.theme.product.priceSale} &nbsp;
17                    </span>
18                    ${Shopify.formatMoney(selectedVariant.price)}
19                </span>
20            `:input.closest(".product-content").querySelector(".product-price").innerHTML=`
21                <span class="product-price-final">
22                    ${Shopify.formatMoney(selectedVariant.price)}
23                </span>
24            `,selectedVariant.available&&selectedVariant.compare_at_price?input.closest(".product-content").querySelector(".product-price").insertAdjacentHTML("beforeend",`
25                <span class="price-badge-sale badge">
26                    ${window.theme.product.save}: ${Shopify.formatMoney(selectedVariant.compare_at_price-selectedVariant.price)}
27                </span>    
28            `):selectedVariant.available||input.closest(".product-content").querySelector(".product-price").insertAdjacentHTML("beforeend",`
29                <span class="price-badge-sold-out badge">
30                    ${window.theme.product.soldOut}
31                </span>
32            `);const purchaseOptionsWrapper=document.querySelector("#product-purchase-options");purchaseOptionsWrapper&&(purchaseOptionsWrapper.querySelector("input#purchase-options-one-time + label [data-price]").textContent=Shopify.formatMoney(selectedVariant.price),purchaseOptionsWrapper.querySelector("input#purchase-options-subscription + label [data-price]").textContent=Shopify.formatMoney(selectedVariant.selling_plan_allocations[0].price));const skuWrapper=input.closest(".product-content").querySelector(".current-variant-sku");if(skuWrapper&&(selectedVariant.sku.length?(skuWrapper.textContent=selectedVariant.sku,skuWrapper.removeAttribute("hidden")):skuWrapper.setAttribute("hidden","hidden")),input.closest("#product-template")){const url=new URL(window.location);url.searchParams.set("variant",selectedVariant.id),window.history.replaceState({},"",url)}btn.querySelector(".btn-atc-price")&&(btn.querySelector(".btn-atc-price").textContent=Shopify.formatMoney(selectedVariant.price));
32const customEvent=new CustomEvent("variantChange.ecomify.product",{detail:selectedVariant});window.dispatchEvent(customEvent)}else btn.disabled=!0,btn.querySelector(".btn-atc-text").textContent=window.theme.product.unavailable;input.closest(".color-swatches")&&(input.closest(".product-option-wrapper").querySelector(".color-swatches-title span").textContent=input.value),input.closest(".size-buttons")&&(input.closest(".product-option-wrapper").querySelector(".size-buttons-title span").textContent=input.value)},window.addEventListener("variantChange.ecomify.product",async event=>{const inventoryBar=document.querySelector("#inventory-bar");inventoryBar&&(inventoryBar.style.opacity=".25");const text=await(await fetch(window.location.href)).text(),newDocument=new DOMParser().parseFromString(text,"text/html");document.querySelector("#inventory-bar")?.replaceWith(newDocument.querySelector("#inventory-bar")),document.querySelector("#product-qty-breaks")?.replaceWith(newDocument.querySelector("#product-qty-breaks")),document.querySelector("#product-store-availability-wrapper")?.replaceWith(newDocument.querySelector("#product-store-availability-wrapper")),document.querySelector(".page-type-product")&&document.querySelector(".product-variant-selector")?.replaceWith(newDocument.querySelector(".product-variant-selector")),initInventoryBar(),initQtyBreaks(),document.querySelector(".product-gallery-variant-based")&&(document.querySelector(".product-gallery-variant-based")?.replaceWith(newDocument.querySelector(".product-gallery-variant-based")),initProductGallery()),document.querySelector("#product-block-variant-description")&&document.querySelector("#product-block-variant-description")?.replaceWith(newDocument.querySelector("#product-block-variant-description")),document.querySelectorAll('[role="tooltip"]').forEach(el=>el.remove()),document.querySelectorAll('.product-options [data-bs-toggle="tooltip"]').forEach(el=>new bootstrap.Tooltip(el))});const initPurchaseOptions=()=>{const wrapper=document.querySelector("#product-purchase-options");if(!wrapper)return;wrapper.querySelectorAll('[name="purchase_option"]').forEach(input=>{input.addEventListener("change",()=>{if(input.id==="purchase-options-one-time"){if(wrapper.querySelector("#purchase-delivery-options").setAttribute("hidden","hidden"),wrapper.querySelector('[name="selling_plan"]').disabled=!0,input.closest("#product-template")){const url=new URL(window.location);url.searchParams.delete("selling_plan"),window.history.replaceState({},"",url)}const btnAtcPrice=input.closest("form").querySelector(".btn-atc-price");btnAtcPrice&&(btnAtcPrice.textContent=Shopify.formatMoney(input.dataset.price))}else{if(wrapper.querySelector("#purchase-delivery-options").removeAttribute("hidden"),wrapper.querySelector('[name="selling_plan"]').disabled=!1,input.closest("#product-template")){const url=new URL(window.location);url.searchParams.set("variant",wrapper.closest(".product-content").querySelector('[name="id"]').value),url.searchParams.set("selling_plan",wrapper.querySelector('[name="selling_plan"]').value),window.history.replaceState({},"",url)}const btnAtcPrice=input.closest("form").querySelector(".btn-atc-price");btnAtcPrice&&(btnAtcPrice.textContent=Shopify.formatMoney(input.dataset.price))}})});const deliverEverySelect=wrapper.querySelector("#purchase-delivery-options-select");deliverEverySelect&&deliverEverySelect.addEventListener("change",()=>{if(deliverEverySelect.closest("#product-template")){const url=new URL(window.location);url.searchParams.set("selling_plan",wrapper.querySelector('[name="selling_plan"]').value),window.history.replaceState({},"",url)}}),wrapper.dataset.subSelectedFirst==="true"&&(wrapper.querySelector("input#purchase-options-subscription").checked=!0,wrapper.querySelector("input#purchase-options-subscription").dispatchEvent(new Event("change")))};initPurchaseOptions(),window.onChangeProductItemVariant=(select,event)=>{select.options[select.selectedIndex].dataset.variantImage?.length&&(select.closest(".product-item").querySelector(".product-item-img").src=select.options[select.selectedIndex].dataset.variantImage);const compareAtPrice=select.options[select.selectedIndex].dataset.compareAtPrice,price=select.options[select.selectedIndex].dataset.price;compareAtPrice.length?select.closest(".product-item").querySelector(".product-item-price").innerHTML=`
33            <span class="product-item-price-compare text-muted me-1">
34                <span class="visually-hidden">
35                    ${window.theme.product.priceFrom} &nbsp;
36                </span>
37                <s>
38                    ${Shopify.formatMoney(compareAtPrice)}
39                </s>
40            </span>
41            <span class="product-item-price-final">
42                <span class="visually-hidden">
43                    ${window.theme.product.priceSale} &nbsp;
44                </span>
45                ${Shopify.formatMoney(price)}
46            </span>
47        `:select.closest(".product-item").querySelector(".product-item-price").innerHTML=`
48            <span class="product-item-price-final">
49                ${Shopify.formatMoney(price)}
50            </span>
51        `},window.onChangeProductItemSwatches=(btn,event)=>{const productItem=btn.closest(".product-item");if(productItem.querySelector(".product-carousel")){productItem.querySelector(".product-carousel .carousel-inner").insertAdjacentHTML("beforeend",`
52            <div class="carousel-item">
53                <img
54                    class="product-item-img img-fluid rounded ${btn.dataset.imgThumbnail}"
55                    src="${btn.dataset.img}"
56                    alt=""
57                    width="${btn.dataset.imgWidth}"
58                    height="${btn.dataset.imgHeight}"
59                    loading="lazy">
60            </div>
61        `);const index=productItem.querySelectorAll(".product-carousel .carousel-item").length-1;bootstrap.Carousel.getOrCreateInstance(productItem.querySelector(".product-carousel")).to(index)}else productItem.querySelector(".product-item-img").setAttribute("src",btn.dataset.img)},window.onClickBuyBtn=btn=>{btn.innerHTML=`
62        <div class="spinner-border spinner-border-sm" role="status">
63            <span class="visually-hidden">Loading...</span>
64        </div>
65    `;const form=btn.closest("form"),variantId=form.querySelector('[name="id"]').value,qty=Number(form.querySelector('input[name="quantity"]')?.value||1);window.location.href=`/cart/${variantId}:${qty}`};const initProductGallery=()=>{document.querySelectorAll(".product-gallery:not(.init)").forEach(gallery=>{gallery.classList.add("init");const main=new Splide(gallery.querySelector(".main-splide"),{start:Number(gallery.dataset.start),rewind:!0,arrows:+(gallery.dataset.mediaCount>1)&&gallery.dataset.arrows==="main-slider",rewindByDrag:!0,pagination:!1,noDrag:"model-viewer",mediaQuery:"min",breakpoints:{0:{padding:{right:gallery.dataset.showThumbsMobile==="false"?"4rem":0}},992:{padding:0}},direction:document.documentElement.getAttribute("dir")}),totalSlides=gallery.querySelectorAll(".main-splide .splide__slide").length,thumbs=new Splide(gallery.querySelector(".thumbs-splide"),{start:Number(gallery.dataset.start),arrows:+(gallery.dataset.mediaCount>3)&&gallery.dataset.arrows==="thumbs-slider",gap:".5rem",rewind:!0,rewindByDrag:!0,pagination:!1,isNavigation:!0,focus:totalSlides>5?"center":0,mediaQuery:"min",breakpoints:{0:{perPage:5},576:{perPage:5},768:{perPage:5},992:{perPage:5},1200:{perPage:5},1400:{perPage:5}},direction:document.documentElement.getAttribute("dir")});if(main.on("move",(newIndex,prevIndex)=>{const prevSlide=gallery.querySelector(`.splide__slide:nth-child(${prevIndex+1}`);prevSlide&&(prevSlide.querySelector("iframe")&&(prevSlide.querySelector("iframe").src=prevSlide.querySelector("iframe").src),prevSlide.querySelector("video")&&prevSlide.querySelector("video").pause());const currentSlide=gallery.querySelector(`.splide__slide:nth-child(${newIndex+1}`);currentSlide&&currentSlide.querySelector("video")&&currentSlide.querySelector("video").play()}),window.addEventListener("variantChange.ecomify.product",event=>{if(main.root.closest(".product-gallery-variant-based"))return;const selectedVariant=event.detail;selectedVariant.featured_media&&main.go(selectedVariant.featured_media.position-1)},!1),main.sync(thumbs),main.mount(),thumbs.mount(),window.matchMedia("(min-width: 992px)").matches){const navbarHeight=document.querySelector("#navbar-desktop")?.clientHeight||0,announcementBarHeight=document.querySelector('[id*="__announcement-bar"].sticky-top')?.clientHeight||0,galleryWrapper=gallery.closest(".product-gallery-wrapper");if(!galleryWrapper)return;galleryWrapper.style.position="sticky",galleryWrapper.style.top=`${navbarHeight+announcementBarHeight+20}px`,galleryWrapper.style.zIndex="1"}if(window.GLightbox){const lightbox=GLightbox({selector:`[data-gallery="product-gallery-${gallery.dataset.productId}"]`,videosWidth:"1290px",loop:!0});lightbox.on("open",()=>{gallery.querySelectorAll("video").forEach(video=>{video.pause()})}),lightbox.on("slide_changed",({prev,current})=>{main.go(current.index)})}const modelViewer=gallery.querySelector("model-viewer");if(modelViewer){const increaseBtn=gallery.querySelector("[data-model-3d-increase-zoom]"),decreaseBtn=gallery.querySelector("[data-model-3d-decrease-zoom]"),fullscreenBtn=gallery.querySelector("[data-model-3d-fullscreen]");increaseBtn.addEventListener("click",()=>{modelViewer.zoom(1)}),decreaseBtn.addEventListener("click",()=>{modelViewer.zoom(-1)}),fullscreenBtn.addEventListener("click",()=>{document.fullscreenElement?(document.exitFullscreen(),fullscreenBtn.querySelector(".bi-fullscreen").removeAttribute("hidden"),fullscreenBtn.querySelector(".bi-fullscreen-exit").setAttribute("hidden","hidden")):(modelViewer.closest(".product-gallery-model-3d").requestFullscreen(),fullscreenBtn.querySelector(".bi-fullscreen").setAttribute("hidden","hidden"),fullscreenBtn.querySelector(".bi-fullscreen-exit").removeAttribute("hidden"))})}})};initProductGallery(),document.addEventListener("shopify:section:load",e=>{e.target.querySelector(".product-gallery")&&initProductGallery()}),window.addEventListener("updated.ecomify.collection",initProductGallery);const initInventoryBar=()=>{const wrapper=document.querySelector("#inventory-bar");if(!wrapper)return;const progressBar=wrapper.querySelector(".progress-bar");setTimeout(()=>{progressBar.style.width=progressBar.dataset.width},250)};initInventoryBar(),document.addEventListener("shopify:section:load",e=>{e.target.querySelector("#inventory-bar")&&initInventoryBar()});const initUpsellModal=()=>{const modal=document.querySelector("#product-upsell-modal");if(!modal)return;const form=document.querySelector('#product-content form[onsubmit*="onSubmitAtcForm"]');form&&(form.setAttribute("data-ecomify-upsell-modal","true"),form.addEventListener("submit",e=>{bootstrap.Modal.getOrCreateInstance("#product-upsell-modal").show()}),document.querySelectorAll("#product-upsell-modal .btn-atc").forEach(btn=>{btn.addEventListener("click",()=>{const footerBtn=document.querySelector("#product-upsell-modal .modal-footer .btn");footerBtn.classList.remove(footerBtn.dataset.defaultClass),footerBtn.classList.add(footerBtn.dataset.activeClass)})}),modal.addEventListener("hidden.bs.modal",()=>{document.querySelector("#offcanvas-cart")&&bootstrap.Offcanvas.getOrCreateInstance("#offcanvas-cart").show()}))};initUpsellModal(),document.addEventListener("shopify:section:load",e=>{e.target.querySelector("#product-upsell-modal")&&initUpsellModal()});const initBoughtTogether=()=>{if(!document.querySelector("#product-bought-together"))return;const setTotalPrice=()=>{let totalCompareAtPrice=0,totalPrice=0;document.querySelectorAll("#product-bought-together .product-item-price").forEach(elem=>{elem.closest(".product-item").querySelector(".bought-together-check:checked")&&(totalCompareAtPrice+=elem.dataset.compareAtPrice.length?Number(elem.dataset.compareAtPrice):Number(elem.dataset.price),totalPrice+=Number(elem.dataset.price))});const totalElem=document.querySelector("#bought-together-total");totalCompareAtPrice>totalPrice?totalElem.innerHTML=`
66                ${totalElem.dataset.textTotalPrice}: 
67                <span class="bought-together-total-compare-price text-muted me-2">
68                    <span class="visually-hidden">
69                        ${window.theme.product.priceFrom} &nbsp;
70                    </span>
71                    <s>
72                        ${Shopify.formatMoney(totalCompareAtPrice)}
73                    </s>
74                </span>
75                <span class="bought-together-total-price text-success">
76                    <span class="visually-hidden">
77                        ${window.theme.product.priceSale} &nbsp;
78                    </span>
79                    ${Shopify.formatMoney(totalPrice)}
80                </span>
81            `:totalElem.innerHTML=`
82                ${totalElem.dataset.textTotalPrice}: 
83                <span class="bought-together-total-price">
84                    ${Shopify.formatMoney(totalPrice)}
85                </span>
86            `};document.querySelectorAll(".bought-together-check").forEach(checkbox=>{checkbox.addEventListener("change",()=>{checkbox.checked?checkbox.closest(".product-item").style.opacity="1":checkbox.closest(".product-item").style.opacity=".5",document.querySelector(".bought-together-check:checked")?document.querySelector("#bought-together-atc").disabled=!1:document.querySelector("#bought-together-atc").disabled=!0,setTotalPrice()})}),document.querySelectorAll('#product-bought-together select[name="id"]').forEach(select=>{select.addEventListener("change",()=>{const compareAtPrice=select.options[select.selectedIndex].dataset.compareAtPrice,price=select.options[select.selectedIndex].dataset.price;select.closest(".product-item").querySelector(".product-item-price").setAttribute("data-compare-at-price",compareAtPrice),select.closest(".product-item").querySelector(".product-item-price").setAttribute("data-price",price),setTotalPrice()})}),document.querySelector("#bought-together-atc").addEventListener("click",async e=>{const btn=e.target;btn.style.width=btn.clientWidth+4+"px",btn.innerHTML=`
87            <div class="spinner-border spinner-border-sm" role="status">
88                <span class="visually-hidden">Loading...</span>
89            </div>
90        `;const items=[];document.querySelectorAll("#product-bought-together .product-item").forEach(elem=>{elem.querySelector(".bought-together-check:checked")&&items.push({id:Number(elem.querySelector('[name="id"]').value),quantity:1})});const response=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items})});btn.innerHTML=window.theme.product.addedToCart,setTimeout(()=>{btn.innerHTML=btn.dataset.textAddToCart},2e3),window.refreshCartContents(response),bootstrap.Offcanvas.getOrCreateInstance("#offcanvas-cart").show()})};initBoughtTogether();const initQtyBreaks=()=>{document.querySelectorAll('[name="product-qty-breaks"]').forEach(radio=>{radio.addEventListener("change",()=>{const qty=Number(radio.dataset.qty),qtyField=radio.closest("form").querySelector('[name="quantity"]'),form=radio.closest("form"),btn=form.querySelector('button[name="add"]');qtyField&&(qtyField.value=qty,qtyField.dispatchEvent(new Event("change")),setTimeout(()=>{btn.classList.add("animate__animated","animate__shakeX")},250),setTimeout(()=>{btn.classList.remove("animate__animated","animate__shakeX")},1500),form.querySelector(".btn-atc-price")&&(form.querySelector(".btn-atc-price").textContent=radio.dataset.totalPrice),document.querySelectorAll('[name="product-qty-breaks"]').forEach(radio2=>{radio2.closest(".form-check").classList.remove("form-check-is-checked")}),radio.closest(".form-check").classList.add("form-check-is-checked"))})}),document.querySelectorAll('[name="product-qty-breaks"]').forEach(radio=>{radio.closest(".form-check").querySelector("label").addEventListener("click",()=>{radio.closest(".form-check").classList.contains("form-check-is-checked")&&(radio.closest(".form-check").classList.remove("form-check-is-checked"),setTimeout(()=>{document.querySelectorAll('[name="product-qty-breaks"]').forEach(radio2=>{radio2.checked=!1});const qtyField=radio.closest("form").querySelector('[name="quantity"]');qtyField.value="1";const form=radio.closest("form"),qtyBreaksList=radio.closest("#product-qty-breaks-list");form.querySelector(".btn-atc-price")&&(form.querySelector(".btn-atc-price").textContent=qtyBreaksList.dataset.currentVariantPrice)},100))})})};initQtyBreaks();const initPrevNextButtons=async()=>{const wrapper=document.querySelector("#product-prev-next");if(!wrapper||!window.matchMedia("(max-width: 1599px)").matches)return;await new Promise(resolve=>setTimeout(resolve,1e3));const threshold=document.querySelector('.product-content form[action*="/cart/add"]').getBoundingClientRect().bottom+window.scrollY;console.log(threshold),window.addEventListener("scroll",()=>{window.scrollY>threshold?wrapper.classList.add("show"):wrapper.classList.remove("show")})};initPrevNextButtons();const initPersonalization=()=>{document.querySelectorAll('.product-personalization-field[data-type="checkbox"]').forEach(elem=>{let values=[];elem.querySelectorAll("input").forEach(checkbox=>{checkbox.addEventListener("change",()=>{checkbox.checked?values.push(checkbox.value):values=values.filter(item=>item!==checkbox.value),elem.querySelector('[type="hidden"]').value=values.join(", ")})})})};initPersonalization();const initLimitedOffer=()=>{const block=document.querySelector("#product-limited-offer");if(!block)return;const icon=block.querySelector(".block-icon");setInterval(()=>{icon.classList.add("animate__animated","animate__tada"),setTimeout(()=>{icon.classList.remove("animate__animated","animate__tada")},1500)},3e3)};initLimitedOffer();const initSyncQuantity=()=>{const productFormQtyInput=document.querySelector('.product-buy-buttons input[name="quantity"]');productFormQtyInput&&productFormQtyInput.addEventListener("change",()=>{const stickyAtcQtyInput=document.querySelector('#sticky-atc input[name="quantity"]');stickyAtcQtyInput&&(stickyAtcQtyInput.value=productFormQtyInput.value)})};initSyncQuantity();
91//# sourceMappingURL=/cdn/shop/t/35/assets/product.js.map?v=100655248903770262161775108815

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.