PageSourceSearch

https://betseyjohnson.com/cdn/shop/t/1305/assets/cart-drawer.js?v=31215585978535086161788851375

js betseyjohnson.com collected 2026-09-24 17:34:22 UTC 16,380 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.addEventListener("openCartDrawer",()=>this.open()),window.addEventListener("openCartDrawer",()=>this.open()),this.setHeaderCartIconAccessibility(),window.addEventListener("pageshow",event=>{event.persisted&&window.location.reload()})}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){localStorage.removeItem("spanDrawerVisible"),window.__isMiniCartOpen=!0;const spanDrawer=document.querySelector(".initial-count-units-drawer");spanDrawer&&(spanDrawer.style.display="none"),triggeredBy&&this.setActiveElement(triggeredBy);const cartDrawerNote=this.querySelector('[id^="Details-"] summary');cartDrawerNote&&!cartDrawerNote.hasAttribute("role")&&this.setSummaryAccessibility(cartDrawerNote),this.hideBackgroundFromScreenReaders(),this.toggleAttribute("data-stylitics-enabled",!!window.STYLITICS_CLIENT),setTimeout(()=>{this.classList.add("animate","active"),requestAnimationFrame(()=>{window.__enableStyliticsMiniCart&&initStyliticsInMiniCart(this)}),requestIdleCallback(()=>{const dataBrand=document.querySelector("html")?.getAttribute("data-brand"),dataLocale=document.querySelector("html")?.getAttribute("data-locale");if(dataBrand){const widgetScript=document.createElement("script");widgetScript.src="https://static-recommendations.fastsimon.com/no-code-recommendations/fs-recommendations-init.js?uuid="+window.FS_UUID+"&store_id="+window.FS_STORE_ID+"&platform=Shopify&widgetId="+window.FS_WIDGET_ID+"&v="+Date.now(),document.head.appendChild(widgetScript)}})}),this.addEventListener("transitionend",()=>{const containerToTrapFocusOn=this.classList.contains("is-empty")?this.querySelector(".drawer__inner-empty"):document.getElementById("CartDrawer"),drawerInner=this.querySelector(".drawer__inner");drawerInner&&drawerInner.focus();const getFocusables=()=>Array.from(containerToTrapFocusOn.querySelectorAll("summary, a[href], button:enabled, [tabindex]:not([tabindex^='-']), [draggable], area, input:not([type=hidden]):enabled, select:enabled, textarea:enabled, object, iframe"));let focusableElements=getFocusables();if(focusableElements.length===0)return;const focusinHandler=event=>{!containerToTrapFocusOn.contains(event.target)&&this.classList.contains("active")&&(event.preventDefault(),focusableElements=getFocusables(),focusableElements.length>0&&focusableElements[0].focus())},keydownHandler=event=>{if(event.code.toUpperCase()!=="TAB"||!this.classList.contains("active"))return;focusableElements=getFocusables();const firstFocusable=focusableElements[0],lastFocusable=focusableElements[focusableElements.length-1],activeElement=document.activeElement;activeElement===lastFocusable&&!event.shiftKey&&(event.preventDefault(),firstFocusable.focus()),activeElement===firstFocusable&&event.shiftKey&&(event.preventDefault(),lastFocusable.focus())};this.focusTrapHandler=keydownHandler,this.focusinTrapHandler=focusinHandler,document.addEventListener("keydown",keydownHandler),document.addEventListener("focusin",focusinHandler)},{once:!0});const setupFocusTrap=()=>{const containerToTrapFocusOn=this.classList.contains("is-empty")?this.querySelector(".drawer__inner-empty"):document.getElementById("CartDrawer"),focusElement=this.querySelector(".drawer__close")||this.querySelector(".drawer__inner");containerToTrapFocusOn&&focusElement&&trapFocus(containerToTrapFocusOn,focusElement)};this.addEventListener("transitionend",setupFocusTrap,{once:!0}),setTimeout(()=>{this.classList.contains("active")&&setupFocusTrap()},500),clearTimeout(this.cartAnnouncementOpenTimeout),this.lastCartAnnouncement="",this.cartAnnouncementOpenTimeout=setTimeout(()=>{this.classList.contains("active")&&this.updateCartAnnouncement()},1200),document.body.classList.add("overflow-hidden")}updateCartAnnouncement(){const announceDiv=document.getElementById("CartDrawer-Announce");announceDiv&&setTimeout(()=>{const itemCountElement=document.getElementById("CartDrawer-ItemCount"),itemCount=itemCountElement?itemCountElement.textContent.trim():"0",cartText=`Your cart has ${itemCount} ${itemCount==="1"?"item":"items"}.`,shippingMsg=document.getElementById("CartShippingProgressMsg"),rawShippingText=shippingMsg?shippingMsg.textContent.trim():"",shippingText=rawShippingText&&rawShippingText.length>
10?rawShippingText+".":"",totalValue=document.querySelector(".totals__total-value"),totalText=totalValue?`Estimated total ${totalValue.textContent.trim()}.`:"",fullAnnouncement=[cartText,shippingText,totalText].filter(text=>text&&text.trim().length>0).join(" ");announceDiv.textContent=fullAnnouncement},600)}close(){window.__isMiniCartOpen=!1,localStorage.removeItem("spanDrawerVisible");const spanDrawer=document.querySelector(".initial-count-units-drawer");spanDrawer&&(spanDrawer.style.display="none"),this.classList.remove("active"),this.focusTrapHandler&&(document.removeEventListener("keydown",this.focusTrapHandler),this.focusTrapHandler=null),this.focusinTrapHandler&&(document.removeEventListener("focusin",this.focusinTrapHandler),this.focusinTrapHandler=null),this.showBackgroundToScreenReaders(),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.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:this.getCartDrawerSectionId(),selector:"#CartDrawer"},{id:"cart-icon-bubble"}]}getCartDrawerSectionId(){if(!this.classList.contains("drawer--kg"))return"cart-drawer";const sectionContainer=this.closest(".shopify-section[id]");return sectionContainer&&sectionContainer.id.replace(/^shopify-section-/,"")||"cart-drawer"}getSectionDOM(html,selector=".shopify-section"){return new DOMParser().parseFromString(html,"text/html").querySelector(selector)}setActiveElement(element){this.activeElement=element}hideBackgroundFromScreenReaders(){const elementsToHide=[document.getElementById("MainContent"),document.querySelector(".header-wrapper"),document.querySelector("header"),document.querySelector("footer"),document.querySelector(".shopify-section-group-header-group"),document.querySelector(".shopify-section-group-footer-group")].filter(Boolean);this.hiddenElements=elementsToHide,elementsToHide.forEach(element=>{element.setAttribute("aria-hidden","true")})}showBackgroundToScreenReaders(){this.hiddenElements&&(this.hiddenElements.forEach(element=>{element.removeAttribute("aria-hidden")}),this.hiddenElements=null)}}customElements.define("cart-drawer",CartDrawer);class CartDrawerItems extends CartItems{getSectionsToRender(){const cartDrawer=document.querySelector("cart-drawer");return[{id:"CartDrawer",section:cartDrawer&&typeof cartDrawer.getCartDrawerSectionId=="function"?cartDrawer.getCartDrawerSectionId():"cart-drawer",selector:".drawer__inner"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"}]}}customElements.define("cart-drawer-items",CartDrawerItems);const STYLITICS_COMPOSER_SRC="https://web-assets.stylitics.com/loader/latest/composer.js";function loadStyliticsComposerOnce(){return window.__styliticsComposerPromise||(window.__styliticsComposerPromise=new Promise((resolve,reject)=>{if(window.StyliticsComposer?.initialize)return resolve(!0);const existing=document.querySelector('script[data-stylitics-composer="true"]');if(existing){existing.addEventListener("load",()=>resolve(!0),{once:!0}),existing.addEventListener("error",reject,{once:!0});return}const s=document.createElement("script");s.src=STYLITICS_COMPOSER_SRC,s.async=!0,s.defer=!0,s.dataset.styliticsComposer="true",s.onload=()=>resolve(!0),s.onerror=reject,document.head.appendChild(s)})),window.__styliticsComposerPromise}async function fetchCart(){const res=await fetch("/cart.js",{credentials:"same-origin"});if(!res.ok)throw new Error("Failed to fetch /cart.js");return res.json()}function mapToStyliticsItemNumber(cartItem){if(!cartItem)return"";const upc=String(cartItem?.properties?.UPC||"").trim();if(upc)return upc;const sku=String(cartItem.sku||"").trim(),colorCode=String(cartItem?.options_with_values?.find(o=>
1o.name==="Color Code")?.value||"").trim()||String(cartItem?.variant_options?.[2]||"").trim();if(sku&&colorCode)return`${sku}_${colorCode}`;const handle=String(cartItem.handle||cartItem.product_handle||"").trim();if(handle)return handle;const m=(cartItem.url||"").match(/\/products\/([^?\/]+)/);return m?.[1]?m[1]:""}function getFsFallbackEl(drawerRoot){return drawerRoot?.querySelector('[class^="fast-simon-"], [class*="fast-simon-"]')}function setFsFallbackVisible(drawerRoot,visible){const el=getFsFallbackEl(drawerRoot);el&&(el.style.display=visible?"":"none")}function setStyliticsVisible(drawerRoot,visible){const block=drawerRoot?.querySelector("[data-stylitics]");block&&(block.style.display=visible?"":"none")}function isRowClearance(rowEl){return rowEl&&String(rowEl.dataset?.isClearance)==="true"}function findRowForVariant(drawerRoot,variantId){return variantId?drawerRoot.querySelector(`.cart-item[data-variant-id="${variantId}"], tr.cart-item[data-variant-id="${variantId}"]`):null}function setStyliticsMode(drawerRoot,mode){drawerRoot&&(drawerRoot.toggleAttribute("data-stylitics-enabled",!!window.STYLITICS_CLIENT),mode==="stylitics"?drawerRoot.setAttribute("data-stylitics-active","true"):drawerRoot.removeAttribute("data-stylitics-active"))}function getCartItemNumbers(cart,{max=6}={}){const items=cart?.items||[],out=[],seen=new Set,lastId=Number(window.__lastAddedVariantId||0),lastItem=lastId?items.find(it=>Number(it.variant_id)===lastId):null;if(lastItem){const n=mapToStyliticsItemNumber(lastItem);n&&(seen.add(n),out.push(n))}for(const it of items){const n=mapToStyliticsItemNumber(it);if(!(!n||seen.has(n))&&(seen.add(n),out.push(n),out.length>=max))break}return out}async function initStyliticsInMiniCart(drawerRoot){if(!drawerRoot||!window.STYLITICS_CLIENT)return;const block=drawerRoot.querySelector("[data-stylitics]"),targetEl=drawerRoot.querySelector("[data-stylitics-target]");if(!(!block||!targetEl||!(targetEl.offsetWidth||targetEl.offsetHeight||targetEl.getClientRects().length))){setFsFallbackVisible(drawerRoot,!1),setStyliticsVisible(drawerRoot,!0);try{const cart=await fetchCart(),itemNumbers=getCartItemNumbers(cart,{max:3}),lastId=Number(window.__lastAddedVariantId||0),anchorRow=findRowForVariant(drawerRoot,lastId);if(isRowClearance(anchorRow)){setStyliticsMode(drawerRoot,"fallback"),setStyliticsVisible(drawerRoot,!1),setFsFallbackVisible(drawerRoot,!0),targetEl.dataset.styliticsMounted="false",targetEl.dataset.styliticsItem="";return}await loadStyliticsComposerOnce();const item_number=itemNumbers.join(",");if(!item_number){setStyliticsMode(drawerRoot,"fallback"),setStyliticsVisible(drawerRoot,!1),setFsFallbackVisible(drawerRoot,!0),targetEl.dataset.styliticsMounted="false",targetEl.dataset.styliticsItem="";return}setFsFallbackVisible(drawerRoot,!1),setStyliticsVisible(drawerRoot,!0);const lastRendered=targetEl.dataset.styliticsItem;if(targetEl.dataset.styliticsMounted==="true"&&lastRendered===item_number)return;targetEl.id||(targetEl.id=`stylitics-composer-${Math.random().toString(16).slice(2)}`),targetEl.innerHTML="",targetEl.dataset.styliticsItem=item_number,targetEl.dataset.styliticsMounted="true",setStyliticsMode(drawerRoot,"stylitics"),setStyliticsVisible(drawerRoot,!0),setFsFallbackVisible(drawerRoot,!1);const timerKey="__styliticsFallbackTimer";targetEl[timerKey]&&clearTimeout(targetEl[timerKey]),targetEl[timerKey]=null,await(await window.StyliticsComposer.initialize({client:window.STYLITICS_CLIENT,target:targetEl.id,config:{modules:[{type:"classic",params:{api:{item_number,min:0,max:12},display:{hideAnchorItem:!1}}}],on:{"load.data":data=>{const timerKey2="__styliticsFallbackTimer";targetEl[timerKey2]&&clearTimeout(targetEl[timerKey2]),targetEl[timerKey2]=null;const itemsLen=Array.isArray(data?.items)?data.items.length:0,outfitsLen=Array.isArray(data?.outfits)?data.outfits.length:0;if(itemsLen>0||outfitsLen>0){setStyliticsMode(drawerRoot,"stylitics"),setStyliticsVisible(drawerRoot,!0),setFsFallbackVisible(drawerRoot,!1);return}targetEl[timerKey2]=setTimeout(()=>{const stillItemsLen=Array.isArray(data?.items)?data.items.length:0,stillOutfitsLen=Array.isArray(data?.outfits)?data.outfits.length:0;(data?.hidden===!0||stillItemsLen===0&&stillOutfitsLen===0)&&(setStyliticsMode(drawerRoot,"fallback"),setStyliticsVisible(drawerRoot,!1),setFsFallbackVisible(drawerRoot,!0))},800)},error:()=>{setStyliticsMode(drawerRoot,"fallback"),setStyliticsVisible(drawerRoot,!1),setFsFallbackVisible(drawerRoot,!0)}},sharedParams:{analytics:{placement:"mini-cart"}},override:{"click.item":payload=>{window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"stylitics item click",
1styliticsData:payload,_clear:!0});const affiliateLink=payload?.item?.affiliate_link,productPath=getProductPathFromAffiliateLink(affiliateLink),quickViewUrl=buildQuickViewUrlFromProductPath(productPath);quickViewUrl&&(window.addToCartLocationOverride="Stylitics",openQuickViewFromProductUrl(quickViewUrl))}}}})).start()}catch(e){console.warn("[Stylitics mini-cart] init failed:",e),setStyliticsMode(drawerRoot,"fallback"),setStyliticsVisible(drawerRoot,!1),setFsFallbackVisible(drawerRoot,!0);const targetEl2=drawerRoot.querySelector("[data-stylitics-target]");targetEl2&&(targetEl2.dataset.styliticsMounted="false");const timerKey="__styliticsFallbackTimer";targetEl2?.[timerKey]&&clearTimeout(targetEl2[timerKey])}}}(function(){window.__styliticsCartUpdatedBound||(window.__styliticsCartUpdatedBound=!0,document.addEventListener("cart:updated",()=>{const drawer=document.querySelector("cart-drawer");if(!drawer||!drawer.classList.contains("active"))return;let tries=0;const tick=()=>{tries++,initStyliticsInMiniCart(drawer),tries<6&&setTimeout(tick,80)};setTimeout(tick,0)}))})();function getProductPathFromAffiliateLink(affiliateLink){if(!affiliateLink)return null;const idx=affiliateLink.indexOf("/products/");return idx===-1?null:"/products/"+affiliateLink.slice(idx+10).split("?")[0]}function buildQuickViewUrlFromProductPath(productPath){return productPath?`${window.__localePrefix||""}${productPath}?view=quick_view`:null}function openQuickViewFromProductUrl(quickViewUrl){quickViewUrl&&$.get(quickViewUrl,function(data){$(".product_quickview").html(data),$(".product_quickview, .overlay").addClass("active"),$("body").addClass("Fixed");const $carousel=$("#quick-view-carousel");$carousel.length&&typeof $.fn.slick=="function"&&!$carousel.hasClass("slick-initialized")&&$carousel.slick(window.slider_settings||{}),setTimeout(()=>$(".main-quick").focus(),100),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"quick_view_open",_clear:!0})})}
2//# sourceMappingURL=/cdn/shop/t/1305/assets/cart-drawer.js.map?v=31215585978535086161788851375

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.