PageSourceSearch

https://5sos.com/cdn/shop/t/19/assets/1f06748441b13bd50f87_collection-view-more_build.js

js 5sos.com collected 2026-09-24 20:40:40 UTC 11,192 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkgcom_rhythm=self.webpackChunkgcom_rhythm||[]).push([[2388,7546,7667],{9883(t,e,i){i.r(e),i.d(e,{attachProductCardSelectedListeners:()=>g,initCarouselProductCardImpressions:()=>d,publishProductCardView:()=>h,publishProductCardViews:()=>u});const r=Object.freeze({carouselParent:'[data-carousel-type="grid-carousel"]',viewport:'[data-items-element="swiper__viewport"]',productGrid:".grid--product",productCard:".product_card"}),s=new WeakSet,n=new WeakSet,o=new Set,a=new WeakSet,c=new WeakMap,l=.5;function d(t=document){"IntersectionObserver"in window&&f()&&function(t){const e=new Set;if(t instanceof HTMLElement){t.matches(r.carouselParent)&&e.add(t);const i=t.closest(r.carouselParent);i instanceof HTMLElement&&e.add(i)}"querySelectorAll"in t&&t.querySelectorAll(r.carouselParent).forEach(t=>{t instanceof HTMLElement&&e.add(t)});return Array.from(e)}(t).forEach(t=>{if(!(t instanceof HTMLElement))return;const e=t.querySelector(r.viewport),i=t.querySelector(r.productGrid);if(!(e instanceof HTMLElement&&i instanceof HTMLElement))return;const a=function(t){const e=c.get(t);if(e)return e;const i=new IntersectionObserver((t,e)=>{const i=[];t.forEach(t=>{if(!(t.target instanceof HTMLElement))return;if(!t.isIntersecting||t.intersectionRatio<l)return;const r=E(t.target);n.has(t.target)||r&&o.has(r)?e.unobserve(t.target):i.push(t.target)}),u(i).forEach(t=>{e.unobserve(t)})},{root:t,threshold:l});return c.set(t,i),i}(e);i.querySelectorAll(r.productCard).forEach(t=>{if(!(t instanceof HTMLElement))return;if(s.has(t)||n.has(t))return;const e=E(t);e&&o.has(e)||function(t){const e=p(t);return e?{currency:window.currentCurrency,items:[e]}:null}(t)&&(s.add(t),a.observe(t))})})}function h(t){return u([t]).length>0}function u(t){if(!f())return[];const e=[],i=[];return t.forEach(t=>{if(n.has(t))return;const r=E(t);if(r&&o.has(r))return;const s=p(t);s&&(e.push(t),i.push(s))}),i.length<1?[]:(window.Shopify.analytics.publish("product_card_viewed",{currency:window.currentCurrency,items:i}),e.forEach(t=>{n.add(t);const e=E(t);e&&o.add(e)}),e)}function g(t=document){m()||function(t){const e=new Set;t instanceof HTMLElement&&t.matches(r.productCard)&&e.add(t);"querySelectorAll"in t&&t.querySelectorAll(r.productCard).forEach(t=>{t instanceof HTMLElement&&e.add(t)});return Array.from(e)}(t).forEach(t=>{const e=t.querySelector("a");e instanceof HTMLAnchorElement&&(a.has(e)||(e.addEventListener("click",()=>{const e=function(t){const e=_(t,"gtm_item_name"),i=_(t,"gtm_item_id"),r=_(t,"gtm_item_variant"),s=_(t,"gtm_item_price");if(!(e&&i&&r&&s))return null;const n=_(t,"gtm_item_sku"),o={item_name:e,item_id:i,item_category:_(t,"gtm_item_collection")||"",item_variant:r,upc:_(t,"gtm_item_upc"),price:parseFloat(s)},a={currency:window.currentCurrency,items:[o]};"DE"===window.shop_iso_code&&Object.assign(a,{value:s,items:[{...o,category:_(t,"gtm_item_category")||"",item_brand:_(t,"gtm_item_brand")||"",item_sku:n,item_group_id:n.slice(0,6),item_list_name:_(t,"gtm_item_list_name")||"",item_list_id:_(t,"gtm_item_list_id")||""}]});return a}(t);e&&window.Shopify?.analytics?.publish&&window.Shopify.analytics.publish("product_card_selected",e)}),a.add(e)))})}function f(){return!m()&&Boolean(window.Shopify?.analytics?.publish)}function m(){return Boolean("undefined"!=typeof Shopify&&Shopify.designMode)}function p(t){const e=_(t,"gtm_item_name"),i=_(t,"gtm_item_id"),r=_(t,"gtm_item_variant"),s=parseFloat(_(t,"gtm_item_price")||"");if(!e||!i||!r||Number.isNaN(s))return null;const n=_(t,"gtm_item_sku")||"",o=_(t,"gtm_item_upc")||"",a={item_name:e,item_id:i,item_category:_(t,"gtm_item_collection")||"",item_variant:r,upc:n||o,price:s};return"DE"===window.shop_iso_code&&Object.assign(a,{barcode:o,category:_(t,"gtm_item_category")||"",item_brand:_(t,"gtm_item_brand")||"",item_sku:n,item_group_id:_(t,"gtm_item_group_id")||n.slice(0,6),item_list_name:_(t,"gtm_item_list_name")||"",item_list_id:_(t,"gtm_item_list_id")||""}),a}function _(t,e){return t.querySelector(`[name="${e}"]`)?.getAttribute("value")||""}function E(t){const e=_(t,"gtm_item_id")||t.dataset.product||"",i=_(t,"gtm_item_variant");if(!e||!i)return"";const r=_(t,"gtm_item_list_id"),s=_(t,"gtm_item_list_name"),n=t.closest('[id^="shopify-section-"], [data-section-id], .shopify-section')?.id||"";return[r||s||n||"page",e,i].join(":")}},768(t,e,i){i.d(e,{CollectionViewMore:()=>n});var r=i(9883);const s=Object.freeze({sectionSelector:".shopify-section",gridSelector:".grid--product",gridItemSelector:".grid-item__wrapper",productCardSelector:".product_card",labelSelector:".progress-label",progressSelector:".progress",buttonSelector:"button",errorNotificationSelector:".notification",errorNotificationTextSelector:".notification__text",loadingAnimationClass:"motion-safe:animate-pulse",hiddenClass:"hidden",gridTransition:"max-height 0.5s ease-in-out",sectionIdPrefix:"shopify-section-"});
1class n extends HTMLElement{constructor(){super(),this.loading=!1,this.domParser=new DOMParser,this.refs=this.getRefs(),this.sectionId=this.getSectionId(),this.dataNextUrl=this.refs.gridEl.dataset.nextUrl,this.useManualPagination=this.refs.gridEl.hasAttribute("data-manual-pagination"),this.currentPage=1,this.paginationBuffer=null,this.storedMaxHeight=null,this.boundHandleResize=this.handleResize.bind(this),this.useManualPagination&&(this.paginationBuffer=this.loadPaginationBuffer())}loadPaginationBuffer(){const t=this.refs.sectionEl.querySelector("[data-pagination-buffer]");if(!t)return null;try{return JSON.parse(t.textContent)}catch(t){return null}}static get observedAttributes(){return["shown"]}get limit(){return this.getAttributeInt("limit")}get total(){return this.getAttributeInt("total")}get shown(){return this.getAttributeInt("shown")}set shown(t){t>this.total&&(t=this.total),this.setAttribute("shown",String(t))}connectedCallback(){this.setGridStyles(),this.refs.buttonEl.addEventListener("click",this.handleButtonClick.bind(this)),window.addEventListener("resize",this.boundHandleResize),this.useManualPagination&&this.publishVisibleProductCardViews()}disconnectedCallback(){this.refs.buttonEl.remove(),window.removeEventListener("resize",this.boundHandleResize)}attributeChangedCallback(t,e,i){"shown"===t&&this.renderProgress()}getAttributeInt(t){const e=this.getAttribute(t);if(!e)throw new ReferenceError(`Missing ${t} attribute`);const i=parseInt(e,10);if(isNaN(i))throw new TypeError(`Invalid ${t} attribute`);return i}setGridStyles(){this.refs.gridEl.style.transition=s.gridTransition,this.refs.gridEl.style.maxHeight=`${this.refs.gridEl.scrollHeight}px`,this.refs.gridEl.style.overflow="hidden"}handleResize(){this.storedMaxHeight&&(this.storedMaxHeight=`${this.refs.gridEl.scrollHeight}px`)}async handleButtonClick(t){if(t.preventDefault(),!this.loading){this.setLoading(!0),this.hideErrorNotification();try{await this.loadMore()}catch(t){this.handleError(t)}finally{this.setLoading(!1)}}}async loadMore(){if(this.useManualPagination)return void this.loadMoreManual();const t=this.getNextUrl();if(!t)return;const e=await fetch(t).then(t=>{if(!t.ok)throw new RangeError(`Invalid response status, expected 200-299, got ${t.status}`);return t.text()}),i=this.processResult(e),r=i.querySelectorAll(s.gridItemSelector);if(r.length<1)return;this.dataNextUrl=i.dataset.nextUrl;let n=0;for(const t of r)t instanceof HTMLElement&&(t.querySelector('[id*="generic-card-"]')||n++);this.shown+=n,this.renderUpdates(i.innerHTML),this.attachProductCardSelectedListeners(),this.publishVisibleProductCardViews()}loadMoreManual(){this.currentPage++,this.paginationBuffer&&this.renderPageFromBuffer(this.currentPage)}renderPageFromBuffer(t){if(!this.paginationBuffer)return;const e=this.paginationBuffer.products.filter(e=>e.page===t),i=this.paginationBuffer.genericCards.filter(e=>e.page===t),r=[...e.map(t=>({type:"product",...t})),...i.map(t=>({type:"generic",...t}))].sort((t,e)=>t.position-e.position);for(const t of r)"product"===t.type?(this.renderProduct(t),this.shown++):this.renderGenericCard(t);this.updateGridHeight(),this.renderProgress(),this.publishVisibleProductCardViews()}publishVisibleProductCardViews(){(0,r.publishProductCardViews)(Array.from(this.refs.gridEl.querySelectorAll(s.productCardSelector)).filter(t=>t instanceof HTMLElement))}attachProductCardSelectedListeners(){(0,r.attachProductCardSelectedListeners)(this.refs.gridEl)}renderProduct(t){const e=document.createElement("div");e.innerHTML=t.html;const i=e.firstElementChild;i&&(this.refs.gridEl.appendChild(i),i instanceof HTMLElement&&this.attachProductCardSelectedListeners())}renderGenericCard(t){const e=document.createElement("div");e.innerHTML=t.html;const i=e.firstElementChild;i&&this.refs.gridEl.appendChild(i)}updateGridHeight(){this.storedMaxHeight&&(this.refs.gridEl.style.maxHeight=this.storedMaxHeight),this.refs.gridEl.offsetHeight;const t=`${this.refs.gridEl.scrollHeight}px`;this.refs.gridEl.style.maxHeight=t,setTimeout(()=>{this.storedMaxHeight=t,this.refs.gridEl.style.maxHeight=""},500)}getNextUrl(){if(!this.dataNextUrl)return null;const t=new URL(this.dataNextUrl,window.location.origin);return t.searchParams.set("section_id",this.sectionId),t}processResult(t){const e=this.domParser.parseFromString(t,"text/html");return this.getRequiredElement(s.gridSelector,e)}renderUpdates(t){this.refs.gridEl.insertAdjacentHTML("beforeend",t),this.refs.gridEl.style.maxHeight=`${this.refs.gridEl.scrollHeight}px`}renderProgress(){this.refs.labelEl.textContent=`Showing ${this.shown} of ${this.total} total`;const t=this.shown/this.total*100;this.refs.progressEl.style.setProperty("--progress-percentage",`${t}%`);let e=!1;if(this.useManualPagination&&this.paginationBuffer){const t=this.currentPage+1,i=this.paginationBuffer.products.some(e=>e.page===t),r=this.paginationBuffer.genericCards.some(e=>e.page===t);e=i||r}else e=this.shown<this.total;e||this.refs.buttonEl.remove()}setLoading(t){this.loading=t,this.refs.buttonEl.disabled=t,this.refs.buttonEl.classList.toggle(s.loadingAnimationClass,t)}handleError(t){const e=t instanceof Error?t:new Error("Unknown error");this.showErrorNotification(e.message)}showErrorNotification(t){this.refs.errorNotificationEl.classList.remove(s.hiddenClass),this.refs.errorNotificationTextEl.textContent=t}hideErrorNotification(){this.refs.errorNotificationEl.classList.add(s.hiddenClass)}
1getRefs(){if(this.refs)return this.refs;const t=this.closest(s.sectionSelector);if(!t)throw new ReferenceError("Missing required closest section element");return{sectionEl:t,labelEl:this.getRequiredElement(s.labelSelector),gridEl:this.getRequiredElement(s.gridSelector,t),progressEl:this.getRequiredElement(s.progressSelector),buttonEl:this.getRequiredElement(s.buttonSelector),errorNotificationEl:this.getRequiredElement(s.errorNotificationSelector),errorNotificationTextEl:this.getRequiredElement(s.errorNotificationTextSelector)}}getRequiredElement(t,e=this){const i=e.querySelector(t);if(!i)throw new ReferenceError(`Missing required element: ${t}`);return i}getSectionId(){if(this.sectionId)return this.sectionId;const t=this.refs.sectionEl.getAttribute("id");if(!t)throw new ReferenceError("Missing section id");return t.replace(s.sectionIdPrefix,"")}}}}]);

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.