PageSourceSearch

https://tramontina.in/cdn/shop/t/158/assets/product-as-variant.js?v=100164760771533432201787029812

js tramontina.in collected 2026-10-05 01:30:50 UTC 6,838 bytes, 2 lines download raw bytes

1(()=>{if(window.ProductAsVariant)return;const SELECTORS={root:"[data-pav-root]",card:"[data-pav-card]",productSection:".js-product",productLink:".js-prod-link, .card-link, .quick-add-view-btn, .b2b-card__title a, .b2b-card__media a",cardTitle:".card__title .card-link, .b2b-card__title a",cardPrice:".price--bottom, .b2b-card__price",pdpTitle:".product-title",pdpPrice:".product-price .product-info__price",formInput:'form[action*="/cart/add"] [name="id"], .js-product-form [name="id"]',addButton:'[name="add"]',quickAdd:".js-quick-add",image:".card__main-image, .b2b-card__main-image, .product-media img"},state=new WeakMap,productCache=new Map,decode=value=>{const textarea=document.createElement("textarea");return textarea.innerHTML=value||"",textarea.value},normalise=value=>String(value||"").trim().toLowerCase(),getContainer=root=>root.closest(SELECTORS.card)||root.closest(SELECTORS.productSection)||root.closest("product-card")||root.closest(".b2b-card-wrapper")||document,fetchProduct=async handle=>{if(productCache.has(handle))return productCache.get(handle);try{const res=await fetch(`/products/${handle}.js`);if(!res.ok)return null;const data=await res.json(),variant=data.variants[0],colorOption=data.options.find(o=>o.name.toLowerCase().includes("color")||o.name.toLowerCase().includes("colour")),colorValue=colorOption?data.variants[0][`option${data.options.indexOf(colorOption)+1}`]:data.title,product={id:data.id,handle:data.handle,title:data.title,url:data.url,variantId:variant.id,variantTitle:variant.title,sku:variant.sku,available:variant.available,price:variant.price,compareAtPrice:variant.compare_at_price||0,image:data.featured_image,imageAlt:data.title,color:colorValue};return productCache.set(handle,product),product}catch{return null}},fetchAllProducts=async handles=>(await Promise.all(handles.map(fetchProduct))).filter(Boolean),setButtonState=(container,product)=>{container.querySelectorAll(SELECTORS.addButton).forEach(button=>{button.disabled=!product.available,button.setAttribute("aria-disabled",product.available?"false":"true");const label=button.querySelector(".quick-add-btn-text, .pointer-events-none:last-child, span:last-child");label&&(product.available&&button.dataset.addToCartText?label.textContent=button.dataset.addToCartText:!product.available&&window.theme?.strings?.soldOut&&(label.textContent=theme.strings.soldOut))})},updateBadges=(container,product)=>{container.querySelectorAll(".product-label--sale").forEach(badge=>{product.compareAtPrice>product.price&&product.compareAtPrice>0?(badge.textContent=`${Math.round((product.compareAtPrice-product.price)*100/product.compareAtPrice)}%`,badge.closest(".product-label-wrapper")?.removeAttribute("hidden")):badge.closest(".product-label-wrapper")?.setAttribute("hidden","")}),container.querySelectorAll(".product-label--sold-out").forEach(badge=>{const wrapper=badge.closest(".product-label-wrapper");wrapper&&(product.available?wrapper.setAttribute("hidden",""):wrapper.removeAttribute("hidden"))})},updateImage=(container,product)=>{if(!product.image)return;const cardImage=container.querySelector(".card__main-image, .b2b-card__main-image");if(cardImage)cardImage.src=product.image,cardImage.srcset="",cardImage.alt=product.imageAlt||product.title;else{const pdpImage=container.querySelector(".product-media img");pdpImage&&(pdpImage.src=product.image,pdpImage.srcset="",pdpImage.alt=product.imageAlt||product.title)}},updateLinks=(container,product,replaceUrl)=>{container.querySelectorAll(SELECTORS.productLink).forEach(link=>{link.href=product.url}),container.querySelectorAll(SELECTORS.quickAdd).forEach(button=>{button.dataset.productUrl=product.url,button.dataset.itemId=product.sku||product.variantId,button.dataset.itemName=product.title,button.dataset.itemVariant=product.variantTitle,button.dataset.price=product.price/100}),replaceUrl&&window.history?.replaceState&&window.history.replaceState({},"",product.url)},updateText=(container,product,context)=>{const titleSelector=context==="pdp"?SELECTORS.pdpTitle:SELECTORS.cardTitle,title=container.querySelector(titleSelector);title&&(title.textContent=product.title)},updateForms=(container,product)=>{container.querySelectorAll(SELECTORS.formInput).forEach(input=>{input.value=product.variantId,input.disabled=!1,input.dispatchEvent(new Event("change",{bubbles:!0}))})},updateSelectedControls=(root,product)=>{root.querySelectorAll("[data-pav-option]").forEach(button=>{const value=normalise(button.dataset.pavValue),selected=normalise(product.color)===value;button.classList.toggle("product-as-variant__swatch--selected",selected),button.setAttribute("aria-pressed",selected?"true":"false")})},applyProduct=(root,product,options={})=>{const container=getContainer(root),context=root.dataset.pavContext||"card";updateSelectedControls(root,product),updateImage(container,product),updateLinks(container,product,context==="pdp"&&options.updateUrl!==!1),updateText(container,product,context),updateForms(container,product),setButtonState(container,product),updateBadges(container,product),state.set(root,{...state.get(root),product}
1),container.dispatchEvent(new CustomEvent("product-as-variant:change",{bubbles:!0,detail:{product}}))},initRoot=async root=>{if(root.dataset.pavInitialized==="true")return;root.dataset.pavInitialized="true";let handles=[];try{handles=JSON.parse(decode(root.dataset.pavHandles))}catch{return}if(!handles.length)return;const currentId=Number(root.dataset.pavCurrentProductId);state.set(root,{handles,product:null,loaded:!1});const currentHandle=handles[0],currentProduct=await fetchProduct(currentHandle);currentProduct&&(applyProduct(root,currentProduct,{updateUrl:!1}),root.addEventListener("click",async event=>{const button=event.target.closest("[data-pav-option]");if(!button||!root.contains(button))return;event.preventDefault();const clickedValue=normalise(button.dataset.pavValue),current=state.get(root);if(!current.loaded){const allProducts=await fetchAllProducts(handles);state.set(root,{...current,products:allProducts,loaded:!0})}const{products}=state.get(root),match=products.find(p=>normalise(p.color)===clickedValue)||products[0];match&&applyProduct(root,match)}))},init=(scope=document)=>{scope.querySelectorAll(SELECTORS.root).forEach(initRoot)};if(window.ProductAsVariant={init},document.addEventListener("DOMContentLoaded",()=>init()),document.addEventListener("shopify:section:load",event=>init(event.target)),"MutationObserver"in window){const observer=new MutationObserver(mutations=>{mutations.forEach(mutation=>{mutation.addedNodes.forEach(node=>{node.nodeType===Node.ELEMENT_NODE&&init(node)})})});document.addEventListener("DOMContentLoaded",()=>{observer.observe(document.body,{childList:!0,subtree:!0})})}})();
2//# sourceMappingURL=/cdn/shop/t/158/assets/product-as-variant.js.map?v=100164760771533432201787029812

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.