PageSourceSearch

https://poppybarley.com/cdn/shop/t/33/assets/product-carousel.js?v=96585213142114971931790349198?v=1.0

js poppybarley.com collected 2026-10-02 16:32:59 UTC 8,125 bytes, 2 lines download raw bytes

1(function(){"use strict";var API_BASE="https://data.poppybarley.com/shopify/Carousel.php",SCROLL_TRIGGER_THRESHOLD=400,BUFFER_MULTIPLIER=2;function skeletonCardHTML(){return'<div class="productGridItem productGridItem--skeleton" aria-hidden="true"><div class="grid__image product-image-skeleton"></div><div class="productDetailsContainer pushDown"><div class="productDetailsReviews"><div class="productDetailsSwatches"><div class="text-skeleton skeleton-swatches"></div></div></div><div class="productDetailsTitle"><div class="text-skeleton skeleton-title"></div></div><div class="productDetailsColour"><div class="text-skeleton skeleton-price"></div></div></div></div>'}function escapeHTML(str){var div=document.createElement("div");return div.textContent=str==null?"":String(str),div.innerHTML}function productCardHTML(product){var image1=product.image1,image2=product.image2,swatchesHTML="";product.swatches&&product.swatches.length&&(swatchesHTML=product.swatches.map(function(sw){return'<li><a href="'+escapeHTML(sw.url)+'" rel="'+escapeHTML(sw.title)+'" draggable="false" title="'+escapeHTML(sw.title)+'"><img src="'+escapeHTML(sw.image)+'" alt="'+escapeHTML(sw.title)+'" loading="lazy"></a></li>'}).join(""));var priceHTML="";return product.price&&(product.compareAtPrice?priceHTML='<span class="priceRed">$'+escapeHTML(product.price.amount)+" "+escapeHTML(product.price.currency)+'</span><br><span class="visually-hidden">Regular price</span><span class="compareAtPrice">$'+escapeHTML(product.compareAtPrice.amount)+' <span class="currency">'+escapeHTML(product.compareAtPrice.currency)+"</span></span>":priceHTML='<span class="priceNorm">$'+escapeHTML(product.price.amount)+' <span class="currency">'+escapeHTML(product.price.currency)+"</span></span>"),'<div class="productGridItem">'+(product.isPreOrder?'<div class="circle-preorder"><span>Pre Order</span></div>':"")+'<a href="'+escapeHTML(product.url)+'" class="grid__image product_image_roll product-image-skeleton" draggable="false">'+(image1?'<img src="'+escapeHTML(image1.src)+'" alt="'+escapeHTML(image1.alt)+'" srcset="'+escapeHTML(image1.srcset)+'" width="'+image1.width+'" height="'+image1.height+'" loading="lazy" class="fade-image" draggable="false" onload="this.classList.add(\'loaded\')" sizes="(min-width: 990px) 25vw, (min-width: 750px) 33vw, 50vw">':"")+(image2?'<img src="'+escapeHTML(image2.src)+'" alt="'+escapeHTML(image2.alt)+'" srcset="'+escapeHTML(image2.srcset)+'" width="'+image2.width+'" height="'+image2.height+'" loading="eager"  draggable="false" class="product_image_roll_image" sizes="(min-width: 990px) 25vw, (min-width: 750px) 33vw, 50vw">':"")+'</a><div class="productDetailsContainer pushDown"><div class="productDetailsReviews"><div class="productDetailsSwatches">'+(swatchesHTML?'<ul class="colourSwatchesCollection">'+swatchesHTML+"</ul>":"")+'</div></div><div class="productDetailsTitle"><p class="collectionProductTitle"><a href="'+escapeHTML(product.url)+'" draggable="false">'+escapeHTML(product.title)+'</a></p></div><div class="productDetailsColour"><p class="collectionPrice">'+priceHTML+"</p></div></div></div>"}function CarouselWidget(rootEl){this.root=rootEl,this.collectionHandle=rootEl.getAttribute("data-collection"),this.manualPageSize=parseInt(rootEl.getAttribute("data-page-size"),10)||null,this.cursor=null,this.hasNextPage=!0,this.isLoading=!1,this.pageSize=this.manualPageSize||6,this.buildSkeletonShell()}CarouselWidget.prototype.buildSkeletonShell=function(){this.root.classList.add("product-carousel"),this.root.innerHTML='<div class="productCarouselViewport"><div class="productCarouselTrack"></div></div>',this.viewport=this.root.querySelector(".productCarouselViewport"),this.track=this.root.querySelector(".productCarouselTrack"),this.track.insertAdjacentHTML("beforeend",skeletonCardHTML());var self=this;requestAnimationFrame(function(){self.calculatePageSize(),self.fillInitialSkeletons(),self.loadNextPage(),self.attachScrollListener(),self.attachDragToScroll()})},CarouselWidget.prototype.calculatePageSize=function(){if(this.manualPageSize){this.pageSize=this.manualPageSize;return}var sampleCard=this.track.querySelector(".productGridItem"),cardWidth=sampleCard?sampleCard.getBoundingClientRect().width:200,gap=parseFloat(getComputedStyle(this.track).gap)||0,viewportWidth=this.viewport.clientWidth||window.innerWidth,visibleCount=Math.max(1,Math.ceil(viewportWidth/(cardWidth+gap)));this.visibleCount=visibleCount,this.pageSize=Math.max(visibleCount*BUFFER_MULTIPLIER,visibleCount+1)},CarouselWidget.prototype.fillInitialSkeletons=function(){for(var needed=this.pageSize-1,html="",i=0;i<needed;i++)html+=skeletonCardHTML();this.track.insertAdjacentHTML("beforeend",html)},CarouselWidget.prototype.addSkeletonsForNextPage=function(count){for(var html="",i=0;i<count;i++)html+=skeletonCardHTML();return this.track.insertAdjacentHTML("beforeend",html),this.track.querySelectorAll(".productGridItem--skeleton")},CarouselWidget.prototype.loadNextPage=function(){if(!(this.isLoading||!this.hasNextPage)){this.isLoading=!0;var url=API_BASE+"?collection="+encodeURIComponent(this.collectionHandle)+"&limit="+encodeURIComponent(this.pageSize)+(this.cursor?"&cursor="+encodeURIComponent(this.cursor):""),self=this;fetch(url).then(function(res){if(!res.ok)throw new Error("Carousel API error: "+res.status);return res.json()}).then(function(data){self.renderPage(data)}
1).catch(function(err){console.error("[product-carousel]",err),self.removeRemainingSkeletons(),self.hasNextPage=!1}).finally(function(){self.isLoading=!1})}},CarouselWidget.prototype.renderPage=function(data){for(var skeletons=this.track.querySelectorAll(".productGridItem--skeleton"),products=data.products||[],i=0;i<skeletons.length;i++)i<products.length?skeletons[i].outerHTML=productCardHTML(products[i]):skeletons[i].remove();this.cursor=data.nextCursor,this.hasNextPage=!!data.hasNextPage},CarouselWidget.prototype.removeRemainingSkeletons=function(){var skeletons=this.track.querySelectorAll(".productGridItem--skeleton");skeletons.forEach(function(el){el.remove()})},CarouselWidget.prototype.attachDragToScroll=function(){var self=this,isDown=!1,hasDragged=!1,startX=0,startScrollLeft=0,pointerId=null,DRAG_THRESHOLD=6;this.viewport.addEventListener("pointerdown",function(e){e.button===0&&(isDown=!0,hasDragged=!1,startX=e.clientX,startScrollLeft=self.viewport.scrollLeft,pointerId=e.pointerId)}),this.viewport.addEventListener("pointermove",function(e){if(isDown){var walk=e.clientX-startX;if(!hasDragged&&Math.abs(walk)>DRAG_THRESHOLD){hasDragged=!0,self.viewport.style.scrollSnapType="none";try{self.viewport.setPointerCapture(pointerId)}catch(err){}}hasDragged&&(e.preventDefault(),self.viewport.scrollLeft=startScrollLeft-walk)}}),this.viewport.addEventListener("pointerup",function(e){if(isDown=!1,hasDragged){self.viewport.style.scrollSnapType="";try{self.viewport.releasePointerCapture(pointerId)}catch(err){}}}),this.viewport.addEventListener("pointercancel",function(){isDown=!1,hasDragged&&(self.viewport.style.scrollSnapType="")}),this.viewport.addEventListener("click",function(e){hasDragged&&(e.preventDefault(),e.stopPropagation(),hasDragged=!1)},!0),this.viewport.addEventListener("dragstart",function(e){e.preventDefault()})},CarouselWidget.prototype.attachScrollListener=function(){var self=this,ticking=!1;this.viewport.addEventListener("scroll",function(){ticking||(ticking=!0,requestAnimationFrame(function(){var el=self.viewport,distanceFromEnd=el.scrollWidth-(el.scrollLeft+el.clientWidth);distanceFromEnd<SCROLL_TRIGGER_THRESHOLD&&self.hasNextPage&&!self.isLoading&&(self.addSkeletonsForNextPage(self.visibleCount||self.pageSize),self.loadNextPage()),ticking=!1}))},{passive:!0})};function init(){var nodes=document.querySelectorAll("[data-collection]:not([data-carousel-initialized])");nodes.forEach(function(node){node.setAttribute("data-carousel-initialized","true"),new CarouselWidget(node)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",init):init()})();
2//# sourceMappingURL=/cdn/shop/t/33/assets/product-carousel.js.map?v=96585213142114971931790349198%3Fv%3D1.0

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.