PageSourceSearch

https://allthingsgolden.com.au/cdn/shop/t/356/assets/cart-drawer.js?v=91429641452253246331787041888

js allthingsgolden.com.au collected 2026-10-06 11:20:15 UTC 7,644 bytes, 2 lines download raw bytes

1let cartDrawerPointerInteraction=!1;document.addEventListener("pointerdown",()=>{cartDrawerPointerInteraction=!0},{capture:!0,passive:!0}),document.addEventListener("keydown",()=>{cartDrawerPointerInteraction=!1},{capture:!0,passive:!0});class CartDrawer extends HTMLElement{constructor(){super(),this.addEventListener("keyup",evt=>evt.code==="Escape"&&this.close()),this.querySelector("#CartDrawer-Overlay").addEventListener("click",this.close.bind(this)),this.setHeaderCartIconAccessibility()}setHeaderCartIconAccessibility(){const cartLink=document.querySelector("#cart-icon-link");cartLink.setAttribute("role","button"),cartLink.setAttribute("aria-haspopup","dialog"),cartLink.addEventListener("click",event=>{event.preventDefault(),cartDrawerPointerInteraction&&cartLink.blur(),this.open(cartLink)}),cartLink.addEventListener("keydown",event=>{event.code.toUpperCase()==="SPACE"&&(event.preventDefault(),this.open(cartLink))})}open(triggeredBy){triggeredBy&&this.setActiveElement(triggeredBy),this.classList.toggle("drawer--pointer-open",cartDrawerPointerInteraction);const cartDrawerNote=this.querySelector('[id^="Details-"] summary');cartDrawerNote&&!cartDrawerNote.hasAttribute("role")&&this.setSummaryAccessibility(cartDrawerNote),setTimeout(()=>{this.classList.add("animate","active")}),this.addEventListener("transitionend",()=>{const containerToTrapFocusOn=this.classList.contains("is-empty")?this.querySelector(".drawer__inner-empty"):document.getElementById("CartDrawer"),focusElement=this.querySelector(".drawer__inner")||this.querySelector(".drawer__close");trapFocus(containerToTrapFocusOn,focusElement)},{once:!0}),document.documentElement.classList.add("overflow-hidden"),document.body.classList.add("overflow-hidden")}close(){this.classList.remove("active"),removeTrapFocus(this.activeElement),cartDrawerPointerInteraction&&this.activeElement?.blur(),document.documentElement.classList.remove("overflow-hidden"),document.body.classList.remove("overflow-hidden")}setSummaryAccessibility(cartDrawerNote){cartDrawerNote.setAttribute("role","button"),cartDrawerNote.setAttribute("aria-expanded","false"),cartDrawerNote.nextElementSibling.getAttribute("id")&&cartDrawerNote.setAttribute("aria-controls",cartDrawerNote.nextElementSibling.id),cartDrawerNote.addEventListener("click",event=>{event.currentTarget.setAttribute("aria-expanded",!event.currentTarget.closest("details").hasAttribute("open"))}),cartDrawerNote.parentElement.addEventListener("keyup",onKeyUpEscape)}handleGWPandUpsell(){setTimeout(()=>{this.autoAddGWP(),this.autoRemoveGWP(),this.removeGWP(),this.addGwp(),this.renderCartUpsell(),this.updateThresholdMessage(),this.updateShippingMessage()},1e3)}autoAddGWP(){const ELM_cartItems=this.querySelector(".cart-items");if(!ELM_cartItems)return;const isAutoAdd=ELM_cartItems.dataset.autoAddGwp,ELM_gwpProductSubmit=document.querySelector(".cart-gwp").querySelector(".cart-gwp__product")?.querySelector(".quick-add__submit");isAutoAdd==="true"&&ELM_gwpProductSubmit&&ELM_gwpProductSubmit?.click()}addGwp(){const ELM_thresholds=document.querySelector(".thresholds-message");if(!ELM_thresholds)return;const ELM_addGwpText=ELM_thresholds.querySelector(".thresholds-message__text-changed__add-gwp"),ELM_gwpProductHideSubmit=document.querySelector(".cart-gwp__product--hidden")?.querySelector(".quick-add__submit");ELM_addGwpText?.addEventListener("click",()=>{ELM_gwpProductHideSubmit?.click()})}autoRemoveGWP(){const ELM_cartItems=this.querySelector(".cart-items");if(!ELM_cartItems)return;const isAutoRemove=ELM_cartItems.dataset.autoRemoveGwp,ELM_gwpItem=ELM_cartItems.querySelector(".cart-item--gwp");if(ELM_gwpItem&&isAutoRemove==="true"){const ELM_remove=ELM_gwpItem?.querySelector("cart-remove-button");ELM_remove&&ELM_remove.click()}}removeGWP(){setTimeout(()=>{const ELM_cartItems=this.querySelector(".cart-items");if(!ELM_cartItems)return;const ELM_gwpItem=ELM_cartItems.querySelector(".cart-item--gwp"),ELM_gwpProductWrapper=document.querySelector(".cart-gwp").querySelector(".cart-gwp__product").querySelector(".card-wrapper"),cartDrawer=document.querySelector(".cart-drawer");ELM_gwpItem&&ELM_gwpItem.querySelector("cart-remove-button").addEventListener("click",e=>{e.preventDefault(),ELM_gwpProductWrapper?.remove(),cartDrawer.classList.add("removed-gwp")}
1)},280)}renderCartUpsell(){const ELM_cartUpsell=document.querySelector(".cart-upsell"),ELM_cartItemUpsell=document.getElementById("CartDrawer-Item-Upsell");if(ELM_cartItemUpsell&&ELM_cartUpsell){ELM_cartItemUpsell.innerHTML=ELM_cartUpsell?.innerHTML,ELM_cartItemUpsell.querySelectorAll(".swiper-slide")?.forEach(item=>{const buttonSubmit=item.querySelector(".quick-add__submit"),variants=item.querySelectorAll("[data-custom-select-list] li");variants.length>1&&buttonSubmit?.classList.add("disabled"),variants?.forEach(variant=>{variant?.addEventListener("click",e=>{const id_value=e.currentTarget.getAttribute("data-value");ELM_cartUpsell.querySelector(`[data-custom-select-list] li[data-value="${id_value}"]`).click(),id_value.length>0?buttonSubmit?.classList.remove("disabled"):buttonSubmit?.classList.add("disabled")})}),buttonSubmit?.addEventListener("click",e=>{e.preventDefault();const product_id=buttonSubmit.getAttribute("data-product-id");ELM_cartUpsell.querySelector(`.swiper-wrapper button.quick-add__submit[data-product-id="${product_id}"]`).click(),document.getElementById("CartDrawer").classList.add("cart-drawer--ctl-product-added"),localStorage.setItem("isCartUpSell","show")})});const summary=document.querySelector("#CartDrawer-Item-Upsell .cart-upsell__header");summary?.addEventListener("click",()=>{summary.closest(".cart-upsell__details").toggleAttribute("open")})}}updateThresholdMessage(){const thresHoldMessage=document.querySelector(".thresholds-message__text.hidden");setTimeout(()=>{thresHoldMessage?.classList.remove("hidden")})}updateShippingMessage(){const globalShippingMessage=this.getAttribute("data-global-shipping-message"),taxShippingMessage=this.querySelector(".cart-drawer__footer-taxes--global-shipping");taxShippingMessage&&(taxShippingMessage.innerHTML=`${globalShippingMessage}`)}renderContents(parsedState){this.querySelector(".drawer__inner").classList.contains("is-empty")&&this.querySelector(".drawer__inner").classList.remove("is-empty"),this.productId=parsedState.id,this.getSectionsToRender().forEach(section=>{const sectionElement=section.selector?document.querySelector(section.selector):document.getElementById(section.id);sectionElement.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.id],section.selector)}),setTimeout(()=>{this.querySelector("#CartDrawer-Overlay").addEventListener("click",this.close.bind(this)),this.open(),this.handleGWPandUpsell()})}getSectionInnerHTML(html,selector=".shopify-section"){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}getSectionsToRender(){return[{id:"cart-drawer",selector:"#CartDrawer"},{id:"cart-icon-bubble"}]}getSectionDOM(html,selector=".shopify-section"){return new DOMParser().parseFromString(html,"text/html").querySelector(selector)}setActiveElement(element){this.activeElement=element}}customElements.define("cart-drawer",CartDrawer);class CartDrawerItems extends CartItems{getSectionsToRender(){return[{id:"CartDrawer",section:"cart-drawer",selector:".drawer__inner"},{id:"shopify-section-cart-drawer",section:"cart-drawer",selector:".cart-upsell"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"}]}}customElements.define("cart-drawer-items",CartDrawerItems);
2//# sourceMappingURL=/cdn/shop/t/356/assets/cart-drawer.js.map?v=91429641452253246331787041888

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.