PageSourceSearch

https://niallhoran.com/cdn/shop/t/56/assets/3ddd1fd090dc413d078d_visual-pagination_build.js

js niallhoran.com collected 2026-09-24 21:09:19 UTC 10,932 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkgcom_rhythm=self.webpackChunkgcom_rhythm||[]).push([[2340,2388,7546],{9883(t,e,i){i.r(e),i.d(e,{attachProductCardSelectedListeners:()=>m,initCarouselProductCardImpressions:()=>l,publishProductCardView:()=>u,publishProductCardViews:()=>h});const r=Object.freeze({carouselParent:'[data-carousel-type="grid-carousel"]',viewport:'[data-items-element="swiper__viewport"]',productGrid:".grid--product",productCard:".product_card"}),n=new WeakSet,a=new WeakSet,s=new Set,o=new WeakSet,c=new WeakMap,d=.5;function l(t=document){"IntersectionObserver"in window&&g()&&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 o=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<d)return;const r=b(t.target);a.has(t.target)||r&&s.has(r)?e.unobserve(t.target):i.push(t.target)}),h(i).forEach(t=>{e.unobserve(t)})},{root:t,threshold:d});return c.set(t,i),i}(e);i.querySelectorAll(r.productCard).forEach(t=>{if(!(t instanceof HTMLElement))return;if(n.has(t)||a.has(t))return;const e=b(t);e&&s.has(e)||function(t){const e=f(t);return e?{currency:window.currentCurrency,items:[e]}:null}(t)&&(n.add(t),o.observe(t))})})}function u(t){return h([t]).length>0}function h(t){if(!g())return[];const e=[],i=[];return t.forEach(t=>{if(a.has(t))return;const r=b(t);if(r&&s.has(r))return;const n=f(t);n&&(e.push(t),i.push(n))}),i.length<1?[]:(window.Shopify.analytics.publish("product_card_viewed",{currency:window.currentCurrency,items:i}),e.forEach(t=>{a.add(t);const e=b(t);e&&s.add(e)}),e)}function m(t=document){p()||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&&(o.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"),n=_(t,"gtm_item_price");if(!(e&&i&&r&&n))return null;const a=_(t,"gtm_item_sku"),s={item_name:e,item_id:i,item_category:_(t,"gtm_item_collection")||"",item_variant:r,upc:_(t,"gtm_item_upc"),price:parseFloat(n)},o={currency:window.currentCurrency,items:[s]};"DE"===window.shop_iso_code&&Object.assign(o,{value:n,items:[{...s,category:_(t,"gtm_item_category")||"",item_brand:_(t,"gtm_item_brand")||"",item_sku:a,item_group_id:a.slice(0,6),item_list_name:_(t,"gtm_item_list_name")||"",item_list_id:_(t,"gtm_item_list_id")||""}]});return o}(t);e&&window.Shopify?.analytics?.publish&&window.Shopify.analytics.publish("product_card_selected",e)}),o.add(e)))})}function g(){return!p()&&Boolean(window.Shopify?.analytics?.publish)}function p(){return Boolean("undefined"!=typeof Shopify&&Shopify.designMode)}function f(t){const e=_(t,"gtm_item_name"),i=_(t,"gtm_item_id"),r=_(t,"gtm_item_variant"),n=parseFloat(_(t,"gtm_item_price")||"");if(!e||!i||!r||Number.isNaN(n))return null;const a=_(t,"gtm_item_sku")||"",s=_(t,"gtm_item_upc")||"",o={item_name:e,item_id:i,item_category:_(t,"gtm_item_collection")||"",item_variant:r,upc:a||s,price:n};return"DE"===window.shop_iso_code&&Object.assign(o,{barcode:s,category:_(t,"gtm_item_category")||"",item_brand:_(t,"gtm_item_brand")||"",item_sku:a,item_group_id:_(t,"gtm_item_group_id")||a.slice(0,6),item_list_name:_(t,"gtm_item_list_name")||"",item_list_id:_(t,"gtm_item_list_id")||""}),o}function _(t,e){return t.querySelector(`[name="${e}"]`)?.getAttribute("value")||""}function b(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"),n=_(t,"gtm_item_list_name"),a=t.closest('[id^="shopify-section-"], [data-section-id], .shopify-section')?.id||"";return[r||n||a||"page",e,i].join(":")}},1777(t,e,i){i.d(e,{VisualPagination:()=>s});var r=i(9883);const n=Object.freeze({mainContent:"#MainContent",productGrid:"#product-grid",grid:".grid--product",item:"[data-pagination-item]",buffer:"[data-pagination-buffer]",productCard:".product_card",arrowTemplate:"[data-visual-pagination-arrow]"}),a="visual_page";class s extends HTMLElement{constructor(){super(),this.grid=null,this.buffer=null,this.pages=Number(this.dataset.pages||"1")||1,this.initialItems=[],this.publishedProductCardKeys=new Set,this.arrowIcon="",this.boundHandleClick=this.handleClick.bind(this),this.boundHandlePopState=this.handlePopState.bind(this)}connectedCallback(){if(this.grid=this.getGrid(),!this.grid)return;this.arrowIcon=this.querySelector(n.arrowTemplate)?.innerHTML||"",this.cacheInitialItems(),this.addEventListener("click",this.boundHandleClick),window.addEventListener("popstate",this.boundHandlePopState);const t=this.getCurrentPage();this.loadBuffer()&&(t>1&&this.renderPage(t),this.renderPagination()),this.attachProductCardSelectedListeners(),this.publishVisibleProductCardViews()}disconnectedCallback(){this.removeEventListener("click",this.boundHandleClick),window.removeEventListener("popstate",this.boundHandlePopState)}loadBuffer(){if(this.buffer)return this.buffer;const t=this.closest(n.productGrid)?.querySelector(n.buffer);if(!t)return null;try{return this.buffer=JSON.parse(t.textContent||"{}"),this.buffer}catch(t){return null}}getCurrentPage(){const t=Number(new URL(window.location.href).searchParams.get(a)||"1");return Number.isNaN(t)?1:Math.min(Math.max(t,1),this.pages)}getGrid(){return this.closest(n.productGrid)?.querySelector(n.grid)??null}renderPagination(){if(this.pages<=1)return void(this.innerHTML="");const t=this.getCurrentPage(),e=[],i=this.getPaginationParts(t,this.pages);t>1&&e.push(this.renderPaginationLink({page:t-1,content:this.arrowIcon,className:"pagination__item pagination__item--prev rotate-90",ariaLabel:this.dataset.previousLabel||""}
1)),i.forEach(i=>{"ellipsis"!==i?i===t?e.push(this.renderCurrentPage(i)):e.push(this.renderPaginationLink({page:i,content:String(i),className:"pagination__item",ariaLabel:this.getPageLabel(i)})):e.push(this.renderPaginationEllipsis())}),t<this.pages&&e.push(this.renderPaginationLink({page:t+1,content:this.arrowIcon,className:"pagination__item pagination__item--next rotate-[-90deg]",ariaLabel:this.dataset.nextLabel||""})),this.innerHTML=`\n      <div class="${this.dataset.wrapperClasses||"pagination-wrapper"}">\n        <nav class="pagination" role="navigation" aria-label="${this.dataset.paginationLabel||""}">\n          <ul class="pagination__list flex flex-wrap justify-center items-center gap-sm-xs" role="list" data-visual-pagination-list>\n            ${e.join("")}\n          </ul>\n        </nav>\n      </div>\n    `}getPaginationParts(t,e){if(e<=7)return Array.from({length:e},(t,e)=>e+1);const i=new Set([1,e]),r=Math.max(2,t-2),n=Math.min(e-1,t+2);for(let t=r;t<=n;t++)i.add(t);const a=Array.from(i).sort((t,e)=>t-e),s=[];return a.forEach((t,e)=>{const i=a[e-1];i&&t-i>1&&s.push("ellipsis"),s.push(t)}),s}renderPaginationLink({page:t,content:e,className:i,ariaLabel:r}){const n=this.dataset.allitemClasses||"",a=this.dataset.inactiveClasses||"",s=this.dataset.inactiveHoverClasses||"";return`\n      <li class="pagination__list-item">\n        <a href="${this.getPageUrl(t)}" data-visual-page="${t}" class="${i} ${n} ${a} ${s}" aria-label="${r}">\n          ${e}\n        </a>\n      </li>\n    `}renderCurrentPage(t){return`\n      <li class="pagination__list-item">\n        <a role="link" aria-disabled="true" class="pagination__item pagination__item--current ${this.dataset.allitemClasses||""} ${this.dataset.activeClasses||""}" aria-current="page" aria-label="${this.getPageLabel(t)}">${t}</a>\n      </li>\n    `}renderPaginationEllipsis(){return`\n      <li class="pagination__list-item">\n        <span class="pagination__item ${this.dataset.allitemClasses||""} ${this.dataset.inactiveClasses||""}">…</span>\n      </li>\n    `}getPageUrl(t){const e=new URL(window.location.href);return 1===t?e.searchParams.delete(a):e.searchParams.set(a,String(t)),e.toString()}getPageLabel(t){return(this.dataset.pageLabelTemplate||"").replace("__PAGE__",String(t))}handleClick(t){const e=t.target;if(!(e instanceof Element))return;const i=e.closest("[data-visual-page]");if(!(i instanceof HTMLAnchorElement))return;t.preventDefault();const r=Number(i.dataset.visualPage||"1");this.loadBuffer()&&(this.setCurrentPage(r),this.renderPage(r),this.renderPagination(),this.attachProductCardSelectedListeners(),this.publishVisibleProductCardViews(),this.focusGrid())}handlePopState(){if(!this.loadBuffer())return;const t=this.getCurrentPage();this.renderPage(t),this.renderPagination(),this.attachProductCardSelectedListeners(),this.publishVisibleProductCardViews()}setCurrentPage(t){const e=new URL(window.location.href);t<=1?e.searchParams.delete(a):e.searchParams.set(a,String(t)),window.history.pushState({},"",e.toString())}renderPage(t){if(!this.grid||!this.buffer)return;this.grid.querySelectorAll(n.item).forEach(t=>t.remove());const e=[...this.buffer.products.map(t=>({type:"product",...t})),...this.buffer.genericCards.map(t=>({type:"generic",...t}))].concat(1===t?this.initialItems:[]).filter(e=>e.page===t).sort((t,e)=>t.position-e.position);for(const t of e){const e=document.createElement("div");e.innerHTML=t.html;const i=e.firstElementChild;i&&this.grid.appendChild(i)}}focusGrid(){if(!this.grid)return;this.grid.hasAttribute("tabindex")||this.grid.setAttribute("tabindex","-1");(document.querySelector(n.mainContent)??this.grid).scrollIntoView({behavior:"smooth"}),this.grid.focus({preventScroll:!0})}publishVisibleProductCardViews(){if(!this.grid)return;const t=[];this.grid.querySelectorAll(n.productCard).forEach(e=>{if(!(e instanceof HTMLElement))return;const i=this.getProductCardKey(e);i&&this.publishedProductCardKeys.has(i)||t.push(e)}),(0,r.publishProductCardViews)(t).forEach(t=>{const e=this.getProductCardKey(t);e&&this.publishedProductCardKeys.add(e)})}attachProductCardSelectedListeners(){this.grid&&(0,r.attachProductCardSelectedListeners)(this.grid)}cacheInitialItems(){!this.grid||this.initialItems.length>0||(this.initialItems=Array.from(this.grid.querySelectorAll(n.item)).filter(t=>t instanceof HTMLElement).map(t=>({page:1,position:Number(t.dataset.productPosition||t.dataset.genericPosition||"0"),html:t.outerHTML})))}getProductCardKey(t){return[t.dataset.product||"",t.querySelector('[name="gtm_item_variant"]')?.getAttribute("value")||""].filter(
1Boolean).join(":")}}}}]);

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.