PageSourceSearch

https://www.mechlands.com/cdn/shop/t/10/assets/wishlist.js?v=16470808071557734181760921004

js mechlands.com collected 2026-09-30 21:07:04 UTC 5,153 bytes, 2 lines download raw bytes

1class Wishlist{constructor(){this.isWishlistPage=!1,this.storageKey="m-wishlist-products",this.products=[],this.productNodes={},this.pageTemplate="page.wishlist",this.addedClass="added-to-wishlist",this.hasItemClass="wishlist-has-item",this.selectors={container:".m-wishlist-page-content__wrapper",noProducts:".m-wishlist-no-products",wrapper:".m-wishlist-card",productCard:".m-product-card",wishlistButton:".m-wishlist-button",wishlistText:".m-wishlist-button-text",removeButton:".m-wishlist-remove-button",count:".m-wishlist-count"},this.products=Array.from(new Set(Array.from(JSON.parse(localStorage.getItem(this.storageKey))||[]))),this.isWishlistPage=MinimogSettings.template===this.pageTemplate,this.init()}init=async()=>{this.isWishlistPage&&(await this.renderWishlistPage(),this.addEventToRemoveButtons()),this.setWishlistButtonsState(),this.addEventToWishlistButtons(),this.updateWishlistCount()};saveToStorage=()=>{this.products=Array.from(new Set(this.products)),localStorage.setItem(this.storageKey,JSON.stringify(this.products))};addToWishlist(handle){handle&&this.products.indexOf(handle)===-1&&(this.products.push(handle),this.saveToStorage())}removeFromWishlist(handle){this.products=this.products.filter(hdl=>hdl!==handle),this.saveToStorage()}setWishlistButtonsState=()=>{document.querySelectorAll(this.selectors.wishlistButton).forEach(btn=>{const prodHandle=btn&&btn.dataset.productHandle;this.products.indexOf(prodHandle)>=0&&btn&&!btn.classList.contains(this.addedClass)&&(this.toggleButtonState(btn,!0),this.isWishlistPage&&(btn.classList.remove(this.selectors.wishlistButton.replace(".","")),btn.classList.add(this.selectors.removeButton.replace(".",""))))})};updateWishlistCount=()=>{const size=this.products.length;[...document.querySelectorAll(this.selectors.count)].forEach(elem=>{elem.textContent=size,size<1?elem.classList.add("m:hidden"):elem.classList.remove("m:hidden")});const method=size?"add":"remove";document.body.classList[method](this.hasItemClass)};addEventToWishlistButtons=()=>{addEventDelegate({selector:this.selectors.wishlistButton,handler:(e,btn)=>{e.preventDefault();const productHandle=btn&&btn.dataset.productHandle;if(productHandle){const active=!btn.classList.contains(this.addedClass);this.toggleButtonState(btn,active),this.updateWishlistCount(),document.querySelectorAll(this.selectors.wishlistButton).forEach(btnItem=>{if(btnItem&&btnItem.dataset.productHandle===productHandle&&btnItem!==btn){const isAdded=!btnItem.classList.contains(this.addedClass);this.toggleButtonState(btnItem,isAdded)}})}}})};toggleButtonState=(btn,active)=>{const productHandle=btn&&btn.dataset.productHandle,wishlistText=btn&&btn.querySelector(this.selectors.wishlistText);if(active?(this.addToWishlist(productHandle),btn.classList.add(this.addedClass)):(this.removeFromWishlist(productHandle),btn.classList.remove(this.addedClass)),wishlistText){const temp=wishlistText.dataset.revertText;wishlistText.dataset.revertText=wishlistText.textContent,wishlistText.textContent=temp}};addEventToRemoveButtons=()=>{addEventDelegate({selector:this.selectors.removeButton,handler:(e,btn)=>{e.preventDefault();const prod=btn&&btn.closest(this.selectors.wrapper);prod&&prod.remove();const productHandle=btn&&btn.dataset.productHandle;productHandle&&(this.removeFromWishlist(productHandle),this.updateWishlistCount(),this.products.length||this.showNoProductsMessage())}})};wishlistRemoveButton(prdHandle){const html='<svg class="m-svg-icon--medium" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>',button=document.createElement("DIV");return button.classList.add("m-tooltip","m-wishlist-remove-button","m:block","md:m:hidden"),button.setAttribute("data-product-handle",prdHandle),button.innerHTML=html,button}renderWishlistPage=async()=>{const container=document.querySelector(this.selectors.container);if(container){let noItemAvailable=!0;if(this.products.length){const promises=this.products.map(async hdl=>{const url=formatUrl("products",hdl,"view=grid-card-item"),prodHTML=await fetchCache(url),item=document.createElement("DIV");item.classList.add("m:hidden","m:column","m-wishlist-card"),item.innerHTML=prodHTML,item.querySelector(this.selectors.productCard)&&(noItemAvailable=!1,item.appendChild(this.wishlistRemoveButton(hdl)),this.productNodes[hdl]=item)});
1await Promise.all(promises),this.products.forEach(hdl=>{const prod=this.productNodes[hdl];prod&&(container.appendChild(prod),MinimogTheme.CompareProduct&&MinimogTheme.CompareProduct.setCompareButtonsState(),prod.classList.remove("m:hidden"))})}noItemAvailable?this.showNoProductsMessage():this.setWishlistButtonsState(),container.classList.add("is-visible")}};showNoProductsMessage=()=>{const container=document.querySelector(this.selectors.container),noProducts=document.querySelector(this.selectors.noProducts);container.classList.add("m:hidden"),noProducts.classList.remove("m:hidden")}}MinimogTheme.Wishlist=new Wishlist;
2//# sourceMappingURL=/cdn/shop/t/10/assets/wishlist.js.map?v=16470808071557734181760921004

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.