PageSourceSearch

https://www.banyanbotanicals.com/cdn/shop/t/18/assets/cart-drawer.js?v=88072384404397417691789689644

js banyanbotanicals.com collected 2026-09-24 17:38:27 UTC 8,357 bytes, 2 lines download raw bytes

1class CartDrawer extends HTMLElement{constructor(){super(),this.progressAnimationFrame=null,this.addEventListener("keyup",evt=>evt.code==="Escape"&&this.close()),this.querySelector("#CartDrawer-Overlay")?.addEventListener("click",this.close.bind(this)),this.addEventListener("click",this.onCartDrawerClick.bind(this)),this.setHeaderCartIconAccessibility()}setHeaderCartIconAccessibility(){const cartLink=document.querySelectorAll("#cart-icon-bubble, #cart-icon-bubble-mobile");for(var i=0;i<cartLink.length;i++)cartLink[i].setAttribute("role","button"),cartLink[i].setAttribute("aria-haspopup","dialog"),cartLink[i].addEventListener("click",event=>{event.preventDefault(),this.open(cartLink[i])}),cartLink[i].addEventListener("keydown",event=>{event.code.toUpperCase()==="SPACE"&&(event.preventDefault(),this.open(cartLink[i]))})}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.animateShippingProgressBar()}),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");containerToTrapFocusOn&&focusElement&&typeof trapFocus=="function"&&trapFocus(containerToTrapFocusOn,focusElement)},{once:!0}),document.body.classList.add("overflow-hidden")}animateShippingProgressBar(){const progressBar=this.querySelector("#shipping-progress-bar");if(!progressBar)return;const targetValue=Number(progressBar.getAttribute("value")),maxValue=Number(progressBar.getAttribute("max"));if(!Number.isFinite(targetValue)||!Number.isFinite(maxValue)||maxValue<=0)return;if(this.progressAnimationFrame&&(cancelAnimationFrame(this.progressAnimationFrame),this.progressAnimationFrame=null),window.matchMedia("(prefers-reduced-motion: reduce)").matches){progressBar.value=targetValue;return}const animationDuration=1600,animationStart=performance.now();progressBar.value=0;const tick=timestamp=>{const elapsed=timestamp-animationStart,progress=Math.min(elapsed/animationDuration,1),easedProgress=1-Math.pow(1-progress,3);progressBar.value=targetValue*easedProgress,progress<1?this.progressAnimationFrame=requestAnimationFrame(tick):(progressBar.value=targetValue,this.progressAnimationFrame=null,this.animateFreeShippingBadge())};this.progressAnimationFrame=requestAnimationFrame(tick)}animateFreeShippingBadge(){const shippingBadge=this.querySelector(".progress-bar-free-shipping.qualify-free-shipping");shippingBadge&&(shippingBadge.classList.remove("is-celebrating"),shippingBadge.offsetWidth,shippingBadge.classList.add("is-celebrating"),shippingBadge.addEventListener("animationend",()=>{shippingBadge.classList.remove("is-celebrating")},{once:!0}))}close(){this.classList.remove("active"),this.progressAnimationFrame&&(cancelAnimationFrame(this.progressAnimationFrame),this.progressAnimationFrame=null),typeof removeTrapFocus=="function"&&removeTrapFocus(this.activeElement),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)}renderContents(parsedState){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),sectionHtml=parsedState?.sections?.[section.id];!sectionElement||!sectionHtml||(sectionElement.innerHTML=this.getSectionInnerHTML(sectionHtml,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-icon-bubble"},{id:"cart-icon-bubble-mobile"}]}getSectionDOM(html,selector=".shopify-section"){return new DOMParser().parseFromString(html,"text/html").querySelector(selector)}setActiveElement(element){this.activeElement=element}onCartDrawerClick(event){const target=event.target;if(!target||typeof target.closest!="function")return;const applyButton=target.closest("[data-cart-apply-discount]");applyButton&&(event.preventDefault(),this.applyDiscountCode(applyButton))}getDiscountSectionsToRender(){return[{id:"CartDrawer",section:"cart-drawer",selector:".drawer__inner"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"},{id:"cart-icon-bubble-mobile",section:"cart-icon-bubble-mobile",selector:".shopify-section"}]}applyDiscountCode(button){try{const code=(button.getAttribute("data-cart-apply-discount")||"").trim();if(!code||button.getAttribute("aria-busy")==="true")return;const errorEl=this.querySelector(".totals__promo-error");errorEl&&(errorEl.hidden=!0),button.setAttribute("aria-busy","true");const updateUrl=window.routes?.cart_update_url||"/cart/update.js",fetchSettings=typeof fetchConfig=="function"?fetchConfig():{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"}},sectionsToRender=this.getDiscountSectionsToRender();fetch(updateUrl,{...fetchSettings,body:JSON.stringify({discount:code,sections:sectionsToRender.map(section=>section.section),sections_url:window.location.pathname})}).then(response=>{if(!response.ok)throw new Error(String(response.status));return response.json()}).then(state=>{if(!state||state.errors)throw new Error("discount-apply");if(state.sections){this.renderDiscountSections(state.sections,sectionsToRender);const remainingButton=this.querySelector("[data-cart-apply-discount]");remainingButton&&this.showDiscountApplyError(remainingButton,this.querySelector(".totals__promo-error"));return}this.refreshCartDrawer()}).catch(()=>{this.showDiscountApplyError(button,errorEl)})}catch{this.showDiscountApplyError(button,this.querySelector(".totals__promo-error"))}}renderDiscountSections(sections,sectionsToRender){sectionsToRender.forEach(section=>{const sectionRoot=document.getElementById(section.id),html=sections?.[section.section];if(!sectionRoot||!html)return;const elementToReplace=sectionRoot.querySelector(section.selector)||sectionRoot,newInner=this.getSectionInnerHTML(html,section.selector);newInner&&(elementToReplace.innerHTML=newInner)})}
1showDiscountApplyError(button,errorEl){button&&button.removeAttribute("aria-busy"),errorEl&&(errorEl.hidden=!1)}refreshCartDrawer(){const cartUrl=window.routes?.cart_url||"/cart";fetch(`${cartUrl}?section_id=cart-drawer`).then(response=>{if(!response.ok)throw new Error(String(response.status));return response.text()}).then(responseText=>{const sourceInner=new DOMParser().parseFromString(responseText,"text/html").querySelector(".drawer__inner"),targetInner=this.querySelector(".drawer__inner");sourceInner&&targetInner&&sourceInner.innerHTML&&(targetInner.innerHTML=sourceInner.innerHTML)}).catch(()=>{const busyButton=this.querySelector('[data-cart-apply-discount][aria-busy="true"]');busyButton&&busyButton.removeAttribute("aria-busy")})}}customElements.get("cart-drawer")||customElements.define("cart-drawer",CartDrawer);class CartDrawerItems extends CartItems{getSectionsToRender(){return[{id:"CartDrawer",section:"cart-drawer",selector:".drawer__inner"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"},{id:"cart-icon-bubble-mobile",section:"cart-icon-bubble-mobile",selector:".shopify-section"}]}}customElements.get("cart-drawer-items")||customElements.define("cart-drawer-items",CartDrawerItems);
2//# sourceMappingURL=/cdn/shop/t/18/assets/cart-drawer.js.map?v=88072384404397417691789689644

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.