PageSourceSearch

https://magicspoon.com/cdn/shop/t/667/assets/shop-all-filters.js?v=46597703023663941281787763297

js magicspoon.com collected 2026-09-24 17:08:59 UTC 4,213 bytes, 2 lines download raw bytes

1const filterButtons=document.querySelectorAll(".js-filter-item"),productCards=document.querySelectorAll(".js-product-card"),filterBar=document.querySelector(".js-filter-bar"),stickyFilterBar=document.querySelector(".js-sticky-filters"),stickyFilterButtons=stickyFilterBar.querySelectorAll(".js-filter-item"),getUrlParameter=param=>{const urlVariables=window.location.search.substring(1).split("&");for(let i=0;i<urlVariables.length;i+=1){const parameterName=urlVariables[i].split("=");if(parameterName[0]===param)return parameterName[1]===void 0?!0:decodeURIComponent(parameterName[1]).replace("+"," ")}return!1},setUrlParameter=(param,value)=>{const url=new URL(window.location);url.searchParams.set(param,value),window.history.pushState({},"",url)},removeUrlParameter=param=>{const url=new URL(window.location);url.searchParams.delete(param),window.history.pushState({},"",url)},filterProductCards=type=>{productCards.forEach(card=>{const productTypeAttribute=card.getAttribute("data-product-type"),productTypes=productTypeAttribute?productTypeAttribute.includes(",")?productTypeAttribute.split(",").map(type2=>type2.trim()):[productTypeAttribute.trim()]:[];card.classList.contains("shop-all-products__card--build-your-own")||type==="all"||productTypes.includes(type)?card.classList.remove("hide-filter"):card.classList.add("hide-filter")})},handleFilterClick=type=>{filterButtons.forEach(btn=>btn.classList.remove("active")),stickyFilterButtons.forEach(btn=>btn.classList.remove("active")),document.querySelectorAll(`.js-filter-item[data-product-type="${type}"]`).forEach(btn=>btn.classList.add("active")),filterProductCards(type),type==="all"?removeUrlParameter("filter"):setUrlParameter("filter",type),currentItems=itemsPerPage,showItems()&&startObserving()};filterButtons.forEach(button=>{button.addEventListener("click",()=>{const type=button.getAttribute("data-product-type");handleFilterClick(type)})}),stickyFilterButtons.forEach(button=>{button.addEventListener("click",()=>{const type=button.getAttribute("data-product-type");handleFilterClick(type)})});const stickyFilterBarToggle=()=>{const sticky=filterBar.offsetTop;window.pageYOffset>sticky?stickyFilterBar.classList.remove("hide"):stickyFilterBar.classList.add("hide")};window.onscroll=()=>{stickyFilterBarToggle()};const itemsPerPage=13;let currentItems=itemsPerPage;const showItems=()=>{let visibleCount=0;const productContainer=document.querySelector(".shop-all-products"),buildYourOwnDesktop=productContainer.querySelector(".js-build-your-own.hide-desktop"),buildYourOwnMobile=productContainer.querySelector(".js-build-your-own.hide-phone");buildYourOwnDesktop&&productContainer.removeChild(buildYourOwnDesktop),buildYourOwnMobile&&productC
1ontainer.removeChild(buildYourOwnMobile),productCards.forEach(card=>{card.classList.contains("hide-filter")?card.classList.add("hide"):(visibleCount+=1,visibleCount<=currentItems?card.classList.remove("hide"):card.classList.add("hide"))});const visibleCards=Array.from(productContainer.children).filter(card=>!card.classList.contains("hide")&&!card.classList.contains("hide-filter"));buildYourOwnDesktop&&(buildYourOwnDesktop.classList.remove("hide"),productContainer.insertBefore(buildYourOwnDesktop,visibleCards[1])),buildYourOwnMobile&&(buildYourOwnMobile.classList.remove("hide"),productContainer.insertBefore(buildYourOwnMobile,visibleCards[3]));const hasMore=currentItems<visibleCount;return hasMore||observer.disconnect(),hasMore},observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{entry.isIntersecting&&(observer.unobserve(entry.target),currentItems+=itemsPerPage,showItems()?startObserving():console.log("[shop-all] all items shown, no longer watching for scroll-to-load"))})},{root:null,rootMargin:"0px 0px -300px 0px",threshold:0}),startObserving=()=>{const visibleItems=Array.from(productCards).filter(card=>!card.classList.contains("hide")&&!card.classList.contains("hide-filter"));visibleItems.length>0&&observer.observe(visibleItems[visibleItems.length-1])};showItems()&&startObserving();const filterType=getUrlParameter("filter")||"all";handleFilterClick(filterType);
2//# sourceMappingURL=/cdn/shop/t/667/assets/shop-all-filters.js.map?v=46597703023663941281787763297

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.