PageSourceSearch

https://us.koala.com/cdn/shop/t/128/assets/cart-drawer.js?v=71241964035844378701771470524

js koala.com collected 2026-09-25 18:14:07 UTC 5,306 bytes, 2 lines download raw bytes

1class 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(),this.#setupKlaviyoFormListener()}#setupKlaviyoFormListener(){window.addEventListener("klaviyoForms",event=>{event.detail.type==="submit"&&this.#setupDiscountFetchMonitor()})}#setupDiscountFetchMonitor(){this.discountObserver&&this.discountObserver.disconnect();const observer=new PerformanceObserver(list=>{for(const entry of list.getEntries())if(entry.name.includes("/discount/")){observer.disconnect(),this.discountObserver=null,setTimeout(()=>{this.#refreshCartDrawer()},300);break}});observer.observe({entryTypes:["resource","navigation"]}),this.discountObserver=observer}async#refreshCartDrawer(){const sections=this.getSectionsToRender().map(section=>section.id).join(",");try{const parsedState=await(await fetch(`${window.location.pathname}?sections=${sections}`)).json();this.getSectionsToRender().forEach(section=>{const sectionElement=section.selector?document.querySelector(section.selector):document.getElementById(section.id);sectionElement&&parsedState[section.id]&&(sectionElement.innerHTML=this.getSectionInnerHTML(parsedState[section.id],section.selector))})}catch(error){console.error("Error refreshing cart drawer:",error)}}setHeaderCartIconAccessibility(){const cartLink=document.querySelector("#cart-icon-bubble");cartLink.setAttribute("role","button"),cartLink.setAttribute("aria-haspopup","dialog"),cartLink.addEventListener("click",event=>{event.preventDefault(),this.open(cartLink)}),cartLink.addEventListener("keydown",event=>{event.code.toUpperCase()==="SPACE"&&(event.preventDefault(),this.open(cartLink))})}open(triggeredBy){triggeredBy&&this.setActiveElement(triggeredBy);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.body.classList.add("overflow-hidden"),window.analytics&&window.analytics.track("Cart Drawer Opened",{url:window.location.pathname}),window.polar&&window.polar.track("Cart Drawer Opened",{url:window.location.pathname})}close(){this.classList.remove("active"),removeTrapFocus(this.activeElement),document.body.classList.remove("overflow-hidden"),window.analytics&&window.analytics.track("Cart Drawer Closed",{url:window.location.pathname}),window.polar&&window.polar.track("Cart Drawer Closed",{url:window.location.pathname})}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)}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()})}getSectionInnerHTML(html,selector=".shopify-section"){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}getSectionsToRender(){return[{id:"cart-drawer",selector:"#CartDrawer"},{id:"cart-count-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(){const data=[{id:"CartDrawer",section:"cart-drawer",selector:".drawer__inner > .drawer__header"},{id:"CartDrawer",section:"cart-drawer",selector:"cart-drawer-items"},{id:"CartDrawer",section:"cart-drawer",selector:".drawer__footer"},{id:"CartDrawer",section:"cart-drawer",selector:".drawer__inner-empty-wrapper"},{id:"cart-count-bubble",section:"cart-count-bubble",selector:".shopify-section"}],cartProgressBar={id:"CartDrawer",section:"cart-drawer",selector:".cart-progress-bar__message"};return document.querySelector(".cart-progress-bar__message")&&data.push(cartProgressBar),data}}customElements.define("cart-drawer-items",CartDrawerItems);
2//# sourceMappingURL=/cdn/shop/t/128/assets/cart-drawer.js.map?v=71241964035844378701771470524

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.