PageSourceSearch

https://xavierderome.com/cdn/shop/t/66/assets/cart-drawer.js?v=134866099483276531891788266116

js xavierderome.com collected 2026-09-27 03:48:12 UTC 6,632 bytes, 2 lines download raw bytes

1import{ThemeEvents,CartUpdatedEvent}from"@theme/events";import{processGifts,extractCartItemCollections}from"@theme/auto-gift-processor";class CartDrawer extends HTMLElement{#rendering=!1;constructor(){super(),this.checkoutButton=null,this.openCartIcons=null,this.backdropClickHandler=this.#onBackdropClick.bind(this),this.checkoutButtonClickHandler=this.#handleCheckoutButtonClick.bind(this),this.cartUpdateHandler=this.#handleCartUpdate.bind(this),this.openHandler=this.open.bind(this),this.closeHandler=this.close.bind(this)}connectedCallback(){this.checkoutButton=this.querySelector('[data-ref="checkout-button"]'),this.addEventListener("click",this.backdropClickHandler),this.checkoutButton.addEventListener("click",this.checkoutButtonClickHandler),document.addEventListener(ThemeEvents.cartUpdated,this.cartUpdateHandler),document.addEventListener(ThemeEvents.cartOpen,this.openHandler),document.addEventListener(ThemeEvents.cartClose,this.closeHandler),Shopify.designMode&&(document.addEventListener("shopify:section:unload",this.#onSectionUnload),window.theme?.isCartDrawerOpen&&(this.open(),window.theme.isCartDrawerOpen=!1))}disconnectedCallback(){document.removeEventListener(ThemeEvents.cartClose,this.closeHandler),document.removeEventListener(ThemeEvents.cartOpen,this.openHandler),document.removeEventListener(ThemeEvents.cartUpdated,this.cartUpdateHandler),this.checkoutButton.removeEventListener("click",this.checkoutButtonClickHandler),this.removeEventListener("click",this.backdropClickHandler),Shopify.designMode&&document.removeEventListener("shopify:section:unload",this.#onSectionUnload)}#onSectionUnload=event=>{event.detail.sectionId===this.dataset.sectionId&&(window.theme=window.theme||{},window.theme.isCartDrawerOpen=this.isOpen())};#handleCheckoutButtonClick(event){event.target.classList.add("is-loading")}#handleCartUpdate(event){this.renderCartContents(event.detail.data)}#onBackdropClick(event){if(event.target.closest("dialog[open]"))return;const rect=this.querySelector(".cart-drawer__inner").getBoundingClientRect();rect.top<=event.clientY&&event.clientY<=rect.top+rect.height&&rect.left<=event.clientX&&event.clientX<=rect.left+rect.width||this.close()}open(){this.classList.remove("is-closing"),this.classList.add("is-open"),document.body.classList.add("overflow-hidden")}close(){this.classList.add("is-closing"),setTimeout(()=>{this.classList.remove("is-open","is-closing"),document.body.classList.remove("overflow-hidden")},125)}isOpen(){return this.classList.contains("is-open")}#updateAutoGiftsMapping(autoGiftsHtml){if(!autoGiftsHtml)return;const newScript=new DOMParser().parseFromString(autoGiftsHtml,"text/html").querySelector('[data-ref="cart-item-collections"]'),currentScript=document.querySelector('[data-ref="cart-item-collections"]');newScript&&currentScript&&(currentScript.textContent=newScript.textContent)}async renderCartContents(parsedState){if(!this.#rendering){this.#rendering=!0;try{const sectionId=this.dataset.sectionId,newCartDrawer=new DOMParser().parseFromString(parsedState.sections[sectionId],"text/html"),newAutoGiftsHtml=parsedState.sections?.["auto-gifts"],newAutoGifts=newAutoGiftsHtml?new DOMParser().parseFromString(newAutoGiftsHtml,"text/html"):null,newCollections=newAutoGifts?extractCartItemCollections(newAutoGifts):{},giftResult=await processGifts(sectionId,newCollections);giftResult?.sections&&(parsedState={...parsedState,sections:{...parsedState.sections,...giftResult.sections},itemCount:giftResult.itemCount??parsedState.itemCount});const finalCartDrawer=giftResult?.sections?.[sectionId]?new DOMParser().parseFromString(giftResult.sections[sectionId],"text/html"):newCartDrawer,currentCartDrawer=this.querySelector(".cart-drawer__inner");currentCartDrawer.innerHTML=finalCartDrawer.querySelector(".cart-drawer__inner").innerHTML,this.#updateAutoGiftsMapping(parsedState.sections?.["auto-gifts"]),setTimeout(()=>{parsedState.itemCount==0?this.classList.add("cart-drawer--empty"):this.classList.remove("cart-drawer--empty")}),this.#syncCartIconCount(parsedState)}finally{this.#rendering=!1}}}#syncCartIconCount(parsedState){const cartIcon=document.querySelector("cart-icon");if(!cartIcon)return;const countEl=cartIcon.querySelector('[data-ref="cart-count"]');
1if(countEl){if(typeof parsedState.itemCount=="number"){countEl.textContent=parsedState.itemCount;return}cartIcon.ensureCartCountIsCorrect()}}}customElements.get("cart-drawer")||customElements.define("cart-drawer",CartDrawer);class CartDrawerItem extends HTMLElement{constructor(){super(),this.removeItemButton=null,this.quantitySelectorInput=null,this.itemRemoveHandler=this.#handleItemRemove.bind(this),this.quantityInputChangeHandler=this.#handleQuantityInputChange.bind(this)}connectedCallback(){this.removeItemButton=this.querySelector('[data-ref="remove-item"]'),this.quantitySelectorInput=this.querySelector('[data-ref="quantity-selector-input"]'),this.removeItemButton?.addEventListener("click",this.itemRemoveHandler),this.quantitySelectorInput?.addEventListener("change",this.quantityInputChangeHandler)}disconnectedCallback(){this.quantitySelectorInput?.removeEventListener("change",this.quantityInputChangeHandler),this.removeItemButton?.removeEventListener("click",this.itemRemoveHandler)}#handleItemRemove(event){event.preventDefault(),this.#updateLineItemQuantity(this.dataset.index,0)}#handleQuantityInputChange(event){event.preventDefault(),this.#updateLineItemQuantity(this.dataset.index,this.quantitySelectorInput.value)}#updateLineItemQuantity(line,quantity){this.#enableLoading();const body=JSON.stringify({line,quantity,sections:[this.closest("cart-drawer").dataset.sectionId,"auto-gifts"].join(","),sections_url:window.location.pathname});fetch(Theme.routes.cart_change_url,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body}).then(response=>response.text()).then(responsetext=>{const parsedResponseText=JSON.parse(responsetext);if(parsedResponseText.errors){document.dispatchEvent(new CustomEvent("toast:open",{detail:{type:"error",message}}));return}document.dispatchEvent(new CartUpdatedEvent({},{itemCount:parsedResponseText.item_count,source:"cart-drawer-item",sections:parsedResponseText.sections}))}).catch(e=>{console.error(e),this.#disableLoading()}).finally(()=>{this.#disableLoading()})}#enableLoading(){this.classList.add("cart-drawer__item--loading")}#disableLoading(){this.classList.remove("cart-drawer__item--loading")}}customElements.get("cart-drawer-item")||customElements.define("cart-drawer-item",CartDrawerItem);
2//# sourceMappingURL=/cdn/shop/t/66/assets/cart-drawer.js.map?v=134866099483276531891788266116

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.