PageSourceSearch

https://www.jlab.com/cdn/shop/t/133/assets/cart-drawer.js?v=30989664472478659641786553402

js jlab.com collected 2026-09-24 09:02:55 UTC 5,726 bytes, 2 lines download raw bytes

1function hydrateCartDrawerRecImages(root=document){hydrateDeferredImages(root)}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(),this.addEventListener("click",this.onRecommendationsClick.bind(this))}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))})}onRecommendationsClick(event){const prevBtn=event.target.closest("[data-cart-drawer-rec-prev]"),nextBtn=event.target.closest("[data-cart-drawer-rec-next]");if(prevBtn||nextBtn){event.preventDefault();const section=(prevBtn||nextBtn).closest("[data-cart-drawer-recommendations]"),track=section&&section.querySelector("[data-cart-drawer-rec-track]");if(!track)return;const card=track.querySelector(".cart-drawer__rec-card"),scrollAmount=card?card.offsetWidth+8:140;track.scrollBy({left:prevBtn?-scrollAmount:scrollAmount,behavior:"smooth"});return}const productRec=event.target.closest(".cart-drawer__recommendations .product__rec");if(!productRec)return;event.preventDefault();const variantId=productRec.getAttribute("data-variant-id"),productId=productRec.getAttribute("data-product-id"),isAvailable=productRec.querySelector(".available")!==null;if(!variantId||!isAvailable)return;typeof posthog<"u"&&posthog.capture("cart_drawer_atc",{product_id:productId,variant_id:variantId}),productRec.classList.add("loading");const formData=new FormData;formData.append("id",variantId),formData.append("quantity",1),formData.append("sections",this.getSectionsToRender().map(section=>section.id)),formData.append("sections_url",window.location.pathname),this.setActiveElement(document.activeElement),fetch(window.Shopify.routes.root+"cart/add.js",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},body:new URLSearchParams(formData)}).then(response=>response.json()).then(data=>{if(data.status&&data.status>=400){console.error("Error adding product to cart:",data.description||data.message);return}if(!data.sections)return fetch(window.location.pathname+"?sections=cart-drawer,cart-icon-bubble").then(response=>response.json()).then(sections=>{data.sections=sections,this.renderContents(data)});this.renderContents(data)}).catch(error=>{console.error("Error adding product to cart:",error)}).finally(()=>{productRec.classList.remove("loading")})}open(triggeredBy){triggeredBy&&this.setActiveElement(triggeredBy),hydrateCartDrawerRecImages(this);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});const scrollbarWidth=window.innerWidth-document.documentElement.clientWidth;document.body.style.paddingRight=`${scrollbarWidth}px`,document.body.classList.add("overflow-hidden")}close(){this.classList.remove("active"),removeTrapFocus(this.activeElement),document.body.classList.remove("overflow-hidden"),document.body.style.paddingRight=""}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.classList.remove("is-empty"),this.querySelector(".drawer__inner").classList.remove("is-empty"),this.productId=parsedState.id,this.get
1SectionsToRender().forEach(section=>{const sectionElement=section.selector?document.querySelector(section.selector):document.getElementById(section.id);sectionElement.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.id],section.selector)}),requestAnimationFrame(()=>{this.querySelector("#CartDrawer-Overlay").addEventListener("click",this.close.bind(this)),hydrateCartDrawerRecImages(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"}]}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:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"}]}}customElements.define("cart-drawer-items",CartDrawerItems);
2//# sourceMappingURL=/cdn/shop/t/133/assets/cart-drawer.js.map?v=30989664472478659641786553402

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.