PageSourceSearch

https://10grove.com/cdn/shop/t/33/assets/cart-drawer.js?v=68468680377998811541660790982

js 10grove.com collected 2026-10-07 00:44:57 UTC 5,137 bytes, 2 lines download raw bytes

1function debounce(fn,wait){let t;return(...args)=>{clearTimeout(t),t=setTimeout(()=>fn.apply(this,args),wait)}}function fetchConfig(type="json"){return{method:"POST",headers:{"Content-Type":"application/json",Accept:`application/${type}`}}}class CartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault(),this.closest("cart-drawer").updateQuantity(this.dataset.index,0)})}}customElements.define("cart-remove-button",CartRemoveButton);class CartDrawer extends HTMLElement{constructor(){super(),this.debouncedOnChange=debounce(event=>{this.onChange(event)},300),this.addEventListener("change",this.debouncedOnChange.bind(this))}onChange(event){event.target.classList.contains("quantity__input")&&this.updateQuantity(event.target.dataset.index,event.target.value,document.activeElement.getAttribute("name"))}getSectionsToRender(){return[{id:"main-cart-items",section:"main-cart-items",selector:".js-contents"}]}connectedCallback(){this.body=document.querySelector("body"),this.drawer=document.getElementById("shopify-section-cart-drawer"),this.cartCount=document.querySelector(".cart-count-bubble"),this.overlay=document.getElementById("cart-overlay"),this.outer=document.getElementById("cart-drawer-outer"),this.cartContents=document.querySelector(".cart__contents"),this.revealBtn=document.getElementById("cart-reveal"),this.subtotal=document.getElementById("cart-subtotal"),this.shopPayPrice=document.getElementById("cart-shop-pay-price"),this.fetchAndOpenCart=this.fetchAndOpenCart.bind(this),this.closeDrawer=this.closeDrawer.bind(this),this.revealBtn.addEventListener("click",e=>{e.preventDefault(),this.fetchAndOpenCart()}),this.querySelectorAll('button[type="button"]').forEach(closeButton=>closeButton.addEventListener("click",this.closeDrawer.bind(this))),this.overlay.addEventListener("click",e=>{this.closeDrawer()})}fetchCart(callback){fetch("/cart.js",{credentials:"same-origin",method:"GET"}).then(resp=>resp.json()).then(cart=>{cart.items.length!==0&&(this.outer.classList.remove("is-empty"),this.renderCart(cart)),typeof callback=="function"&&callback(cart)}).catch(error=>{throw new Error(error)})}updateQuantity(line,quantity,name){const body=JSON.stringify({line,quantity,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});fetch(`${routes.cart_change_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);this.outer.classList.toggle("is-empty",parsedState.item_count===0),this.subtotal.innerHTML=`$${(parsedState.items_subtotal_price/100).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}`,this.shopPayPrice.innerHTML=`$${(parsedState.items_subtotal_price/4/100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}`,this.getSectionsToRender().forEach((section=>{const elementToReplace=document.getElementById(section.id).querySelector(section.selector)||document.getElementById(section.id);elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector)})),this.updateCartCount();const lineItem=document.getElementById(`cart-product-${line}`);lineItem&&lineItem.querySelector(`[name="${name}"]`)&&lineItem.querySelector(`[name="${name}"]`).focus()}).catch(err=>{console.error(err),console.error(window.cartStrings.error)})}renderCart(cart){fetch(`${window.location.pathname}?sections=main-cart-items`).then(response=>response.json()).then(parsedState=>{this.subtotal.innerText=`$${(cart.items_subtotal_price/100).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}`,this.shopPayPrice.innerHTML=`$${(cart.items_subtotal_price/4/100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}`,this.cartContents.innerHTML=this.getSectionInnerHTML(parsedState["main-cart-items"],".js-contents"),this.updateCartCount()}).catch(e=>{console.error(e)})}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}updateCartCount(){this.cartItemCount=document.querySelector("[data-cart-length]").dataset.cartLength,this.cartCount.innerHTML=this.cartItemCount>0?parseInt(this.cartItemCount,10):null}
1openDrawer(){this.body.classList.add("drawer-active"),this.drawer.classList.add("is-active")}closeDrawer(){this.body.classList.remove("drawer-active"),this.drawer.classList.remove("is-active")}fetchAndOpenCart(){this.fetchCart(()=>{this.openDrawer()})}}customElements.define("cart-drawer",CartDrawer);class QuantityInput extends HTMLElement{constructor(){super(),this.input=this.querySelector("input"),this.changeEvent=new Event("change",{bubbles:!0}),this.querySelectorAll("button").forEach(button=>button.addEventListener("click",this.onButtonClick.bind(this)))}onButtonClick(event){event.preventDefault();const previousValue=this.input.value;event.target.name==="plus"?this.input.stepUp():this.input.stepDown(),previousValue!==this.input.value&&this.input.dispatchEvent(this.changeEvent)}}customElements.define("quantity-input",QuantityInput);
2//# sourceMappingURL=/cdn/shop/t/33/assets/cart-drawer.js.map?v=68468680377998811541660790982

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.