PageSourceSearch

https://pusheen.com/cdn/shop/t/643/assets/component-product-recomm…?v=152825416814617534381789755400

js pusheen.com collected 2026-09-24 09:00:53 UTC 6,761 bytes, 2 lines download raw bytes

1(()=>{"use strict";class Component{constructor(theme,element){this.theme=theme,this.element=element,theme.registerComponent(this)}onWindowResizeRaw=({width})=>{};onWindowResize=({width,oldWidth,breakpoint})=>{};onWindowResizeBreakpoint=({width,breakpoint,oldBreakpoint})=>{};onWindowScroll=()=>{}}class QuickAdd extends Component{constructor(theme,element){super(theme,element),this.theme=theme,this.element=element,this.onSubmit=this.onSubmit.bind(this),this.isProcessing=!1,this.cartAction=document.getElementById("PageContainer").dataset.cartAction,this.cartType=document.getElementById("PageContainer").dataset.cartType,this.languageUrl=document.getElementById("PageContainer").dataset.languageUrl,this.formWrappers=this.element.querySelectorAll(".quick-add-wrapper.is-singular"),this.wethemeGlobal=document.querySelector("script#wetheme-global"),this.translationsObject=JSON.parse(this.wethemeGlobal.textContent),this.formWrappers.length&&this.formWrappers.forEach(wrapper=>{const form=wrapper.querySelector(".shopify-product-form");form&&!form.hasAttribute("data-quick-add-initialized")&&(form.addEventListener("submit",this.onSubmit),form.setAttribute("data-quick-add-initialized","true"))})}async onSubmit(e){if(this.isProcessing){e.preventDefault();return}if(this.cartType=="page"&&this.cartAction!="show_added_message")return;e.preventDefault(),this.isProcessing=!0;const currentForm=e.currentTarget,currentButton=currentForm.querySelector("[data-quick-add-button]"),productWrapper=currentForm.closest(".quick-add-wrapper.is-singular");let previousInnerHTML=null,isDesktopQuickAdd=!1;try{if(!productWrapper)return console.error("Product wrapper not found."),!1;const liveRegion=currentForm.querySelector('.sr-only[aria-live="polite"]');isDesktopQuickAdd=currentButton.classList.contains("quick-add-button-desktop"),isDesktopQuickAdd&&(previousInnerHTML=currentButton.innerHTML,currentButton.classList.add("is-loading"),currentButton.innerHTML=`<svg viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" width="1.6em" height="1.6em" class="spin flex-full"><g clip-path="url(#clip0_3605_47041)"><path d="M12.5 23C6.42487 23 1.5 18.0751 1.5 12C1.5 5.92487 6.42487 1 12.5 1C18.5751 1 23.5 5.92487 23.5 12C23.5 15.1767 22.1534 18.0388 20 20.0468" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></g><defs><clipPath id="clip0_3605_47041"><rect width="24" height="24" fill="none" transform="translate(0.5)"/></clipPath></defs>${this.translationsObject.translations.loading}</svg>`);const formData=new FormData(currentForm),data=new URLSearchParams(formData).toString(),response=await window.fetch("/cart/add.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:data});if(!response.ok)return!1;if(this.cartType=="drawer"){const responseJson=await response.json();window.eventBus.emit("update:cart:drawer",responseJson)}const languageParam=!this.languageUrl||this.languageUrl=="/"?"":this.languageUrl,response2=await window.fetch(`${languageParam}/cart?view=compare`);if(!response2.ok)return!1;const cart=await response2.json();if(this.cartType=="drawer"&&this.cartAction=="go_to_or_open_cart"?window.eventBus.emit("open:cart:drawer",{scrollToTop:!0}):isDesktopQuickAdd&&(currentButton.classList.remove("is-loading"),currentButton.innerHTML=this.translationsObject.translations.productAdded),this.cartType=="drawer"){const successMessage=productWrapper.getAttribute("data-product-added");liveRegion&&successMessage&&(liveRegion.textContent=successMessage)}this.theme.updateCartCount(cart),isDesktopQuickAdd&&setTimeout(()=>{const translationKey=currentButton.dataset.addToCartTranslationKey||"addToCart";currentButton.classList.remove("is-loading"),currentButton.innerHTML=this.translationsObject.translations[translationKey]},2e3)}catch(e2){console.error("Unable to add to cart: ",e2)}finally{currentButton&&isDesktopQuickAdd&&previousInnerHTML&&currentButton.classList.contains("is-loading")&&(currentButton.classList.remove("is-loading"),currentButton.innerHTML=previousInnerHTML),this.isProcessing=!1}return!1}}class productRecommendations extends HTMLElement{constructor(){super(),this.isAlreadyLoaded=this.querySelector(".product-page-related-products"),this.abortController=null,this.bindEventHandlers()}connectedCallback(){this.addEventListeners(),this.init()}bindEventHandlers(){this.debouncedRenderRecommendationsBound=this.debouncedRenderRecommendations.bind(this)}addEventListeners(){window.Shopify.designMode&&document.addEventListener("shopify:section:load",this.debouncedRenderRecommendationsBound)}debouncedRenderRecommendations(){this.renderTimeout&&clearTimeout(this.renderTimeout),this.abortController&&this.abortController.abort();const delay=window.Shopify.designMode?800:100;this.renderTimeout=setTimeout(()=>this.renderRecommendations(),delay)}init(){if(this.isAlreadyLoaded&&this.isAlreadyLoaded.remove(),window.wetheme.webcomponentRegistry.register({key:"product-recommendations"}),window.Shopify.designMode){this.renderRecommendations();return}const handleIntersection=(entries,observer)=>{entries[0].isIntersecting&&(observer.unobserve(this),this.renderRecommendations())};new IntersectionObserver(handleIntersection.bind(this),{rootMargin:"0px 0px 0px 0px"}).observe(this)}renderRecommendations(){this.abortController&&this.abortController.abort(),this.abortController=new AbortController;let url=this.dataset.recommendationsUrl;window.Shopify.designMode&&(url+=`&t=${Date.now()}`),fetch(url,{signal:this.abortController.signal}).then(response=>response.text()).then(text=>{var container=document.createElement("div");container.innerHTML=text;const recommendations=container.querySelector("product-recommendations");
1if(recommendations&&recommendations.innerHTML.trim().length){this.innerHTML=recommendations.innerHTML,window.wetheme.addBadges(this,1e3),this.quickAddButtons=new QuickAdd(window.wetheme,this);const sectionLoadedEvent=new CustomEvent("theme:section:load",{detail:{sectionId:this.dataset.sectionId}});document.dispatchEvent(sectionLoadedEvent);const recommendationsLoadedEvent=new CustomEvent("recommendations:loaded");document.dispatchEvent(recommendationsLoadedEvent)}}).catch(e=>{e.name!=="AbortError"&&console.error(e)})}disconnectedCallback(){this.renderTimeout&&clearTimeout(this.renderTimeout),this.abortController&&this.abortController.abort(),window.Shopify.designMode&&document.removeEventListener("shopify:section:load",this.debouncedRenderRecommendationsBound)}isMobile=()=>window.matchMedia("(max-width: 1023px)").matches}customElements.define("product-recommendations",productRecommendations)})();
2//# sourceMappingURL=/cdn/shop/t/643/assets/component-product-recommendations.js.map?v=152825416814617534381789755400

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.