PageSourceSearch

https://misterk.fr/cdn/shop/t/277/assets/mx-cart-drawer.js?v=38460715753946284851790683902

js misterk.fr collected 2026-10-06 02:46:26 UTC 6,025 bytes, 2 lines download raw bytes

1initCartDrawer();function initCartDrawer(){document.querySelector(".shopify-section-cart-drawer").addEventListener("click",event=>{const clickEventPath=event.composedPath().slice(0,-2);for(const element of clickEventPath){const clickAction=element?.getAttribute("data-click-action");if(clickAction==="close-cart-drawer"){closeCartDrawerHandler(element),window.mx.showGorgiasButton();break}else if(clickAction==="remove-item-from-cart"){removeItemFromCartHandler(element);break}else if(clickAction==="set-coupon-code"){setCouponCodeHandler(element);break}else if(clickAction==="cart-item-add"){addItemToCartHandler(element);break}}}),document.querySelector(".shopify-section-cart-drawer").addEventListener("focusin",event=>{event.target.addEventListener("keyup",handleCouponConfirmation)}),document.querySelector(".mx-cart-drawer").addEventListener("focusout",event=>{event.target.removeEventListener("keyup",handleCouponConfirmation)})}async function loadRecommendedProducts(){try{const cartRecommendationsContainer=document.querySelector(".cart-recommendations-container"),cartRecommendationsEndpoint=cartRecommendationsContainer.dataset.url,cartRecommendationsMarkup=await fetch(cartRecommendationsEndpoint).then(response=>response.text()),newCartRecommendationsContainer=new DOMParser().parseFromString(cartRecommendationsMarkup,"text/html").querySelector(".cart-recommendations-container");cartRecommendationsContainer.innerHTML=newCartRecommendationsContainer.innerHTML}catch(error){console.error(error)}}function closeCartDrawerHandler(closeButton){closeButton.closest(".shopify-section-cart-drawer").querySelector(".mx-cart-drawer").removeAttribute("data-open"),document.documentElement.removeAttribute("data-locked"),window.scrollTo(0,-1*parseInt(document.documentElement.style.top)),document.documentElement.style.top=null,document.documentElement.style.scrollBehavior=null}async function removeItemFromCartHandler(removeButton){const itemKey=removeButton.closest(".cart-item-container").getAttribute("data-line-key"),sectionId=removeButton.closest(".shopify-section-cart-drawer").id.split("shopify-section-").pop();try{const cartUpdateJson=await fetch("/cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:{[itemKey]:0},sections:[sectionId]})}).then(response=>response.json());refreshCartUserInterface(cartUpdateJson.sections[sectionId])}catch(error){console.error("Error removing the product from cart",error)}}async function setCouponCodeHandler(applyCouponButton){const couponInput=applyCouponButton.previousElementSibling,couponCode=couponInput.value.toUpperCase(),couponCodeLoadingString=applyCouponButton.parentElement.getAttribute("data-loading-string");if(couponInput.value="",couponInput.placeholder=couponCodeLoadingString,couponInput.blur(),couponCode!==null)try{await fetch("/discount/"+couponCode);const sectionId=applyCouponButton.closest(".shopify-section-cart-drawer").id.split("shopify-section-").pop(),sectionJson=await fetch(`/?sections=${sectionId}`).then(response=>response.json());refreshCartUserInterface(sectionJson[sectionId]),requestAnimationFrame(()=>{const refreshedCouponMessage=document.querySelector(".cart-coupon-message");refreshedCouponMessage&&refreshedCouponMessage.dataset.hasDiscount==="0"&&(refreshedCouponMessage.classList.add("is-active"),setTimeout(()=>{refreshedCouponMessage.classList.remove("is-active")},7e3))})}catch(error){console.error("Error applying the coupon code",error)}}function refreshCartUserInterface(sectionMarkup){const sectionHtml=new DOMParser().parseFromString(sectionMarkup,"text/html"),cartDrawer=document.querySelector(".mx-cart-drawer"),newCartDrawer=sectionHtml.querySelector(".mx-cart-drawer"),newCartItemCount=newCartDrawer.getAttribute("data-cart-item-count");document.querySelectorAll("[data-cart-item-count]").forEach(element=>{element.setAttribute("data-cart-item-count",newCartItemCount)}),cartDrawer.replaceChildren(...newCartDrawer.children),initAnnouncementBar()}function handleCouponConfirmation(event){event.key==="Enter"&&setCouponCodeHandler(event.target.nextElementSibling)}async function addItemToCartHandler(addButton){const variantId=addButton.getAttribute("data-product-id"),sectionId=addButton.closest(".shopify-section-cart-drawer").id.replace("shopify-section-","");try{await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({id:Number(variantId),quantity:1})});const updatedSections=await fetch(`/?sections=${sectionId}`).then(res=>res.json());refreshCartUserInterface(updatedSections[sectionId])}catch(error){console.error("Error adding product to cart",error)}}const DEFAULT_SWITCH_DELAY=5e3;let carouselInterval;
1function initAnnouncementBar(){stopCarousel();const announcementBar=document.querySelector(".cart-announcement");if(!announcementBar)return;const announcements=announcementBar.querySelector(".cart-announcement-list");if(!announcements)return;const switchDelay=parseInt(announcements.getAttribute("data-switch-delay")??DEFAULT_SWITCH_DELAY);announcementBar.addEventListener("mouseenter",stopCarousel),announcementBar.addEventListener("mouseleave",()=>{startCarousel(announcements,switchDelay)}),startCarousel(announcements,switchDelay)}function switchAnnouncement(announcements,switchDelay){const firstAnnouncement=announcements.firstElementChild;if(!firstAnnouncement)return;const announcementWidth=firstAnnouncement.offsetWidth;announcements.scrollBy({left:announcementWidth,behavior:"smooth"}),setTimeout(()=>{announcements.append(firstAnnouncement.cloneNode(!0)),announcements.removeChild(firstAnnouncement),announcements.scroll({left:0})},switchDelay/2)}function startCarousel(announcements,switchDelay){carouselInterval=setInterval(()=>{switchAnnouncement(announcements,switchDelay)},switchDelay)}function stopCarousel(){clearInterval(carouselInterval)}initAnnouncementBar();
2//# sourceMappingURL=/cdn/shop/t/277/assets/mx-cart-drawer.js.map?v=38460715753946284851790683902

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.