PageSourceSearch

https://www.pasticceriacova.com/cdn/shop/t/2/assets/product-cards.js?v=77717289362563609031725443711

js pasticceriacova.com collected 2026-10-02 04:19:36 UTC 13,584 bytes, 31 lines download raw bytes

1function handle(text){return text.toString().normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w\-]+/g,"").replace(/\_/g,"-").replace(/\-\-+/g,"-").replace(/\-$/g,"")}class ProductCardMini extends HTMLElement{constructor(){super()}connectedCallback(){this.image=this.querySelector("img[product-card-image]"),this.imageContainerRatio=this.getAttribute("image-container-ratio").trim(),this.imageFit=this.hasAttribute("image-fit"),this.quickShopTrigger=this.getAttribute("quick-shop-trigger"),this._isRendered=this.hasAttribute("rendered")}set product(product){this._product=product,this._isRendered||this._render()}get product(){return this._product}set sectionId(id){this._sectionId=id}get sectionId(){return this._sectionId}_render(){if(this.setAttribute("product-id",this._product.id),this.querySelectorAll("a[product-card-link]").forEach(link=>link.setAttribute("href",this._product.url)),this._product.available?this._product.compare_at_price>this._product.price&&this.classList.add("product-card--sale"):this.classList.add("product-card--sold-out"),this.imageContainerRatio==="natural"){const previewImage=this.querySelector("img[product-card-image]");previewImage.closest(".o-ratio").style.paddingBottom="100%"}if(this.product.media&&this.product.media.length>0){const mainImageSource=this.product.media[0].preview_image;this._updateImage(mainImageSource.src,mainImageSource.width,mainImageSource.height,mainImageSource.alt);const secondaryImagePlaceholder=this.querySelector("product-card-secondary-image-placeholder");if(secondaryImagePlaceholder&&this.product.media[1]){const secondaryImageSource=this.product.media[1].preview_image,secondaryImage=this._renderImage(secondaryImageSource.src,secondaryImageSource.width,secondaryImageSource.height,secondaryImagePlaceholder.getAttribute("class"),secondaryImageSource.alt,this.image.getAttribute("sizes"));secondaryImage.setAttribute("product-card-secondary-image",""),this.image.parentElement.classList.add("product-card__media--hover-image"),secondaryImagePlaceholder.replaceWith(secondaryImage)}this.getAttribute("image-hover")==="zoom"&&this.image.parentElement.classList.add("product-card__media--hover-zoom"),this.imageContainerRatio==="natural"?this.image.closest(".o-ratio").style.paddingBottom=`${1/mainImageSource.aspect_ratio*100}%`:this.image.closest(".o-ratio").style.paddingBottom=null,this._updateSkeleton()}const vendor=this.querySelector("product-card-vendor");vendor&&(vendor.textContent=this._product.vendor),this.querySelector("product-card-title").textContent=this._product.title;const price=this.querySelector("product-card-price");if(price){const variantPrice=`
2        <span class="u-hidden-visually">${window.theme.t.regular_price}</span>
3        <span class="price__number ${this._product.compare_at_price>this._product.price?"price__number--sale":""}">
4          <span class="money">
5          ${this._product.price_varies?window.theme.t.from_price:""}
6          ${Shopify.formatMoney(this._product.price,window.theme.money_product_price_format)}
7          </span>
8        </span>
9        ${this._product.compare_at_price>this._product.price?`
10              <span class="u-hidden-visually">${window.theme.t.sale_price}</span>
11              <span class="price__compare">
12                <span class="money">${Shopify.formatMoney(this._product.compare_at_price,theme.money_format)}
13                </span>
14              </span>
15            `:""}
16      `;price.innerHTML=variantPrice}const priceNotes=this.querySelector("product-card-price-notes"),currentVariant=this._product.variants.find(variant=>variant.available);if(priceNotes&&currentVariant&&currentVariant.unit_price_measurement){const priceNote=document.createElement("span");priceNote.classList.add("price__note","price__note--unit");const unitPriceTemplate=document.getElementById("template-unit-price").content;priceNote.appendChild(unitPriceTemplate.cloneNode(!0)),priceNotes.appendChild(priceNote);const baseUnit=`${currentVariant.unit_price_measurement.reference_value!==1?currentVariant.unit_price_measurement.reference_value:""}${currentVariant.unit_price_measurement.reference_unit}`;
16priceNotes.querySelector("unit-price").innerHTML=window.Shopify.formatMoney(currentVariant.unit_price,window.theme.money_format),priceNotes.querySelector("base-unit").innerHTML=baseUnit}if(this.quickShopTrigger==="button"){const productCardButton=this.querySelector("product-card-button");if(this._product.available)if(this._product.variants&&this._product.variants.length>1){const quickShopButton=document.getElementById(`${this._sectionId?`${this._sectionId}--`:""}template-quick-shop-button`).content.cloneNode(!0),link=quickShopButton.querySelector("a");link&&(link.href=this._product.url),productCardButton.appendChild(quickShopButton)}else{const addToCartForm=document.getElementById(`${this._sectionId?`${this._sectionId}--`:""}template-add-to-cart-form`).content.cloneNode(!0);addToCartForm.querySelector('input[name="id"]').value=this._product.variants[0].id;const spinner=document.getElementById("template-spinner").content.cloneNode(!0);addToCartForm.querySelector("product-card-button-spinner").appendChild(spinner);const quickShopContainer2=this.querySelector("product-card-quick-shop");quickShopContainer2&&quickShopContainer2.remove(),productCardButton.appendChild(addToCartForm)}else{const soldOutButtonTemplate=document.getElementById(`${this._sectionId?`${this._sectionId}--`:""}template-sold-out-button`).content,quickShopContainer2=this.querySelector("product-card-quick-shop");quickShopContainer2&&quickShopContainer2.remove(),productCardButton.appendChild(soldOutButtonTemplate.cloneNode(!0))}}const quickShopContainer=this.querySelector("product-card-quick-shop");if(quickShopContainer&&!(this.quickShopTrigger==="button"&&(!this._product.available||this._product.variants.length===1))){const quickShop=document.getElementById(`${this._sectionId?`${this._sectionId}--`:""}template-quick-shop`).content.cloneNode(!0).querySelector("quick-shop");quickShop.hasAttribute("placeholder")&&quickShop.setAttribute("data-product-url",this._product.url),quickShopContainer.replaceWith(quickShop)}this.setAttribute("rendered",""),this._isRendered=!0}_renderImage(url,width,height,classes="",alt="",sizes="100vw",srcsetWidths=[180,360,540,720,900,1080,1296,1512]){if(!url||!width||!height)return null;const image=document.createElement("img"),imageContainerRatio=this.imageContainerRatio!=="natural"?this.imageContainerRatio.split(":").reduce((ratio,value)=>ratio!==0?value/ratio:value,0):null,aspectRatio=width/height,uncroppedImage=this.imageContainerRatio==="natural"||imageContainerRatio&&this.imageFit;let masterWidth=width,masterHeight=height;uncroppedImage||(masterHeight=Math.round(masterWidth*imageContainerRatio),masterHeight>height&&(masterHeight=height,masterWidth=Math.round(masterHeight/imageContainerRatio)));const srcset=srcsetWidths.reduce((srcset2,srcWidth)=>{const srcHeight=Math.round(uncroppedImage?srcWidth/aspectRatio:srcWidth*imageContainerRatio);return srcWidth>masterWidth||srcHeight>masterHeight?srcset2:`${srcset2}${url}${url.includes("?")?"&":"?"}width=${srcWidth}${uncroppedImage?"":`&height=${srcHeight}&crop=center`} ${srcWidth}w ${srcHeight}h, `},""),masterSrc=uncroppedImage?url:`${url}${url.includes("?")?"&":"?"}width=${masterWidth}&height=${masterHeight}&crop=center`;return image.setAttribute("src",masterSrc),image.setAttribute("srcset",srcset),image.setAttribute("width",masterWidth),image.setAttribute("height",masterHeight),image.setAttribute("class",classes),image.setAttribute("alt",alt),image.setAttribute("sizes",sizes),image}_updateImage(url,width,height,alt="",srcsetWidths=[180,360,540,720,900,1080,1296,1512]){if(!this.image||!url||!width||!height)return null;const imageContainerRatio=this.imageContainerRatio!=="natural"?this.imageContainerRatio.split(":").reduce((ratio,value)=>ratio!==0?value/ratio:value,0):null,aspectRatio=width/height,uncroppedImage=this.imageContainerRatio==="natural"||imageContainerRatio&&this.imageFit;let masterWidth=width,masterHeight=height;uncroppedImage||(masterHeight=Math.round(masterWidth*imageContainerRatio),masterHeight>height&&(masterHeight=height,masterWidth=Math.round(masterHeight/imageContainerRatio)));const srcset=srcsetWidths.reduce((srcset2,srcWidth)=>{const srcHeight=Math.round(uncroppedImage?srcWidth/aspectRatio:srcWidth*imageContainerRatio);return srcWidth>masterWidth||srcHeight>masterHeight?srcset2:`${srcset2}${url}${url.includes("?")?"&":"?"}width=${srcWidth}${uncroppedImage?"":`&height=${srcHeight}&crop=center`} ${srcWidth}w ${srcHeight}h, `},""),masterSrc=uncroppedImage?url:`${url}${url.includes("?")?"&":"?"}width=${masterWidth}&height=${masterHeight}&crop=center`;this.image.setAttribute("src",masterSrc),this.image.setAttribute("srcset",srcset),this.image.setAttribute("width",masterWidth),this.image.setAttribute("height",masterHeight),this.image.setAttribute("alt",alt)}_updateSkeleton(){if(!this.image)return;const skeleton=this.image.nextElementSibling&&this.image.nextElementSibling.tagName.toLowerCase()==="image-skeleton"?this.image.nextElementSibling:null;if(skeleton){const svg=skeleton.querySelector("svg"),rect=svg.querySelector("rect"),width=this.image.getAttribute("width"),height=this.image.getAttribute("height");skeleton.setAttribute("aria-label",`Loading image for ${this._product.title}
16`),svg.setAttribute("width",width),svg.setAttribute("height",height),svg.setAttribute("viewBox",`0 0 ${width} ${height}`),rect.setAttribute("width",width),rect.setAttribute("height",height)}}}customElements.define("product-card-mini",ProductCardMini);class ProductCard extends ProductCardMini{constructor(){super(),this._boundSetVariant=this.setVariant.bind(this)}connectedCallback(){super.connectedCallback(),this._swatchTriggers=[],this._product&&!this._isRendered&&(this._currentVariantUrl=this._product.url,this._render()),this._swatchTriggers.length===0&&(this._swatchTriggers=Array.from(this.querySelectorAll("li[variant-id]"))),this._product||this._setProductData(),this._setUpSwatchesListeners()}disconnectedCallback(){this._removeSwatchesListeners()}set product(product){super.product=product,this._isRendered||(this._currentVariantUrl=this._product.url,this._setUpSwatchesListeners())}get product(){return this._product}_render(){super._render();const swatches=this.querySelector("product-card-variant-swatches");if(swatches){const swatchOption=this._product.options.find(option=>theme.swatches.triggers.includes(option.name.toLowerCase()));if(swatchOption){const templateId=this._sectionId?`${this._sectionId}--template-swatch`:"template-swatch",swatchTemplate=document.getElementById(templateId).content;swatches.innerHTML=`
17          <div class="swatch-wrapper">
18            <div class="product-card__swatch">
19              <ul class="product-card__swatch__items o-list-inline">
20              </ul>
21              ${swatchOption.values.length>5?`
22                    <div class="product-card__overflow">
23                      <a product-card-link href="${this._product.url}" class="product-card__overflow__item" title="${this._product.title}">
24                        <span class="">+${swatchOption.values.length-5}</span>
25                      </a>
26                    </div>
27                  `:""}
28            </div>
29          </div>
30        `;const swatchList=swatches.querySelector("ul");swatchOption.values.slice(0,5).forEach(value=>{const variant=this._product.variants.find(v=>v[`option${swatchOption.position}`]===value);if(variant){const variantId=variant.id,swatchFragment=swatchTemplate.cloneNode(!0),variantNameHandle=handle(value),variantSwatch=swatchFragment.querySelector("variant-swatch");variantSwatch.setAttribute("swatch-id",variantNameHandle),variantSwatch.style.setProperty("--background-graphic",variantNameHandle.replaceAll("-","")),variantSwatch.setAttribute("aria-label",value.replaceAll('"',""));const variantTrigger=swatchFragment.querySelector("li");variantTrigger.setAttribute("variant-id",variantId),this._swatchTriggers.push(variantTrigger),swatchList.appendChild(swatchFragment)}})}}}_setProductData(){const productData=this.querySelector("[id^=ProductJson]");productData&&(this._product=JSON.parse(productData.textContent))}setVariant(e){if(!e.target.hasAttribute("variant-id"))return;const variantId=e.target.getAttribute("variant-id"),variant=this._product.variants.find(v=>v.id.toString()===variantId);if(variant){this.querySelectorAll("li.is-active").forEach(li=>li.classList.remove("is-active")),e.target.classList.add("is-active"),this._currentVariantUrl=`${this._product.url}${this._product.url.includes("?")?"&":"?"}variant=${variantId}`;const variantImage=variant.featured_media?variant.featured_media.preview_image:this._product.media&&this._product.media.length>0?this._product.media[0].preview_image:null;this.querySelectorAll("a[product-card-link]").forEach(link=>link.setAttribute("href",this._currentVariantUrl)),variantImage&&this._updateImage(variantImage.src,variantImage.width,variantImage.height,variantImage.alt);const quickShop=this.querySelector("quick-shop");quickShop&&(quickShop.variantId=variantId)}}_setUpSwatchesListeners(){this._swatchTriggers.forEach(trigger=>{trigger.addEventListener("click",this._boundSetVariant)})}_removeSwatchesListeners(){this._swatchTriggers.forEach(trigger=>{trigger.removeEventListener("click",this._boundSetVariant)})}}customElements.define("product-card",ProductCard);
31//# sourceMappingURL=/cdn/shop/t/2/assets/product-cards.js.map?v=77717289362563609031725443711

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.