PageSourceSearch

https://www.bratz.com/cdn/shop/t/42/assets/p80-ajax-cart.js?v=40753152398884675031790701078

js bratz.com collected 2026-10-02 04:10:27 UTC 13,844 bytes, 2 lines download raw bytes

1customElements.get("ajax-cart")||customElements.define("ajax-cart",class extends HTMLElement{constructor(){super(),this.notificationBanner&&!this.notificationBanner.initialized&&(this.notificationBanner.initialized=!0,this.notificationBanner.connectedCallback?.())}connectedCallback(){this.isOpen=!1;const tasks=[this.setConfiguration.bind(this),this.bindDynamic.bind(this),this.bindStatic.bind(this),this.setSubscriptions.bind(this),this.setHeaderCartIconAccessibility.bind(this)];this.yieldTasks(tasks)}disconnectedCallback(){this.cartUpdateUnsubscriber&&this.cartUpdateUnsubscriber(),this.removeEventListener("keyup",this.handleKeyUp),this.productContainer?.removeEventListener("change",this.debouncedOnChange),this.headerOpener?.removeEventListener("click",this.handleOpen),this.overlay?.removeEventListener("click",this.handleClose),this.headerCartLink?.removeEventListener("click",this.handleOpen),this.headerCartLink?.removeEventListener("keydown",this.handleKeyDown),this.closeButton?.removeEventListener("click",this.handleClose)}yieldToMain(){return new Promise(resolve=>{setTimeout(resolve,0)})}async yieldTasks(tasks){for(;tasks.length>0;)tasks.shift()(),await this.yieldToMain()}setConfiguration(){this.filterClass=".ajax-cart__js-replace",this.headerCartLink=document.querySelector("#cart-icon-bubble"),this.closeButton=this.querySelector(".ajax-cart__close"),this.overlay=this.querySelector(".ajax-cart__overlay"),this.handleClose=this.close.bind(this),this.handleOpen=this.open.bind(this),this.handleKeyUp=this.onKeyUp.bind(this),this.handleKeyDown=this.onKeyDown.bind(this),this.debouncedOnChange=debounce(event=>{this.onChange(event)},ON_CHANGE_DEBOUNCE_TIMER).bind(this),this.submitHandler=this.onSubmit.bind(this),window.cartOptions?.notificationType!=="slide-out"&&(this.cartNotificationModal=document.querySelector("cart-notification-modal"),this.cartNotificationShade=document.querySelector("cart-notification"))}setSubscriptions(){this.cartUpdateUnsubscriber=subscribe(PUB_SUB_EVENTS.cartUpdate,event=>{event.source==="ajax-cart"||event.source==="product-form"&&this.cartNotificationModal||this.onCartUpdate()})}setHeaderCartIconAccessibility(){this.headerCartLink?.setAttribute("role","button"),this.headerCartLink?.setAttribute("aria-haspopup","dialog"),this.headerCartLink?.addEventListener("click",this.handleOpen),this.headerCartLink?.addEventListener("keydown",this.handleKeyDown)}setAccessibilityOptions(){this.isOpen?(this.setAttribute("aria-hidden",!1),this.setAttribute("tabindex",0)):(this.setAttribute("aria-hidden",!0),this.setAttribute("tabindex",-1))}bindDynamic(){this.errorContainer=this.querySelector(".ajax-cart__errors"),this.errorText=this.errorContainer?.querySelector("span"),this.accessbilityStatus=this.querySelector(".ajax-cart__line-status"),this.productContainer=this.querySelector(".ajax-cart__lines"),this.productContainer?.addEventListener("change",this.debouncedOnChange),this.submitButton=this.querySelector(".ajax-cart__checkout"),this.submitButton?.addEventListener("click",this.submitHandler),this.complementaryProducts=this.querySelector(".ajax-cart__complementary embla-carousel")}unbindDynamic(){this.complementaryIndex=this.complementaryProducts?.emblaApi?.slidesInView(),this.productContainer?.removeEventListener("change",this.debouncedOnChange),this.submitButton?.removeEventListener("click",this.submitHandler)}bindStatic(){this.productContainer?.addEventListener("change",this.debouncedOnChange),this.headerOpener?.addEventListener("click",this.handleOpen),this.closeButton?.addEventListener("click",this.handleClose),this.addEventListener("keyup",this.handleKeyUp),this.overlay?.addEventListener("click",this.handleClose)}onSubmit(event){event?.preventDefault(),!(this.loading||event?.target.getAttribute("disabled"))&&(this.submitButton.setAttribute("disabled",!0),window.location.href="/checkout")}onKeyUp(event){event?.code==="Escape"&&this.close()}onKeyDown(event){event?.code.toUpperCase()==="SPACE"&&(event.preventDefault(),this.open())}onChange(event){event&&this.updateQuantity(event.target.dataset.index,event.target.value,event.target.getAttribute("name"),event.target.dataset.quantityVariantId)}onCartUpdate(){fetch(`${routes.cart_url}?section_id=p80-ajax-cart`).then(response=>response.text()).then(responseText=>{this.replaceNodes(responseText,this.filterClass)}).catch(event=>{console.error(event)})}open(event){event?.preventDefault(),this.cartNotificationModal?.close(),this.cartNotificationShade?.close(),setTimeout(()=>{this.isOpen=!0,this.classList.add("ajax-cart--visible"),document.body.classList.add("overflow-hidden"),this.setAccessibilityOptions()}),this.addEventListener("transitionend",()=>{trapFocus(this,this.closeButton)},{once:!0})}close(){this.isOpen=!1,this.classList.remove("ajax-cart--visible"),document.body.classList.remove("overflow-hidden"),this.setAccessibilityOptions(),this.resetStatus(),removeTrapFocus()}replaceNodes(section,filter){if(!section)return;const nodes=this.getSectionDOM(section,filter,!0);nodes.length&&(this.unbindDynamic(),this.querySelectorAll(filter).forEach((node,index)=>{typeof this.complementaryIndex<"u"&&node.classList.contains("ajax-cart__complementary")&&nodes[index].querySelector("embla-carousel")?.setAttribute("data-start-at",this.complementaryIndex),node.replaceWith(nodes[index])}),this.bindDynamic(),this.notificationBanner=this.querySelector("notification-banner"),this.notificationBanner&&!this.notificationBanner.initialized&&(this.notificationBanner.initialized=!0,this.notificationBanner.connectedCallback?.()))}renderContents(parsedState){parsedState&&(this.cartItemKey=parsedState.key,this.get
1SectionsToRender().forEach(section=>{const sectionElement=document.getElementById(section.id);if(sectionElement)if(section.type&&section.type==="DOM"){if(section.id==="p80-ajax-cart"){this.replaceNodes(parsedState.sections[section.id],section.filter);return}const node=this.getSectionDOM(parsedState.sections[section.id],section.selector);if(!node)return;sectionElement.replaceWith(node)}else{const html=this.getSectionInnerHTML(parsedState.sections[section.id],section.selector);if(!html)return;sectionElement.innerHTML=html}}),!this.cartItemKey&&!this.isOpen?this.open():window.cartOptions?.notificationType==="modal"&&this.cartNotificationModal&&!this.isOpen?this.cartNotificationModal.open():this.isOpen||this.open())}updateQuantity(line,quantity,name,variantId){if(this.loading)return;const ajaxCartRoot=this,requestedQty=parseInt(quantity,10)||0,customerCountry=(ajaxCartRoot.getAttribute("data-customer-country")||"").toUpperCase();this.notificationBanner=this.notificationBanner||this.querySelector("notification-banner");const quantityElement=document.getElementById(`ajax-cart__quantity--${line}`),variantInput=document.querySelector(`[data-quantity-variant-id="${variantId}"]`)||quantityElement,themeLimit=parseInt(ajaxCartRoot.getAttribute("data-default-max"),10)||1/0;let variantMax;if(variantInput?.dataset?.maxQty){const parsed=parseInt(variantInput.dataset.maxQty,10);isNaN(parsed)||(variantMax=parsed)}let allowedMax;if(customerCountry==="US"?allowedMax=variantMax??1/0:allowedMax=1/0,requestedQty>allowedMax){quantityElement&&allowedMax!==1/0&&(quantityElement.value=allowedMax),this.notificationBanner?.setCartValidationBanner(requestedQty,allowedMax===1/0?requestedQty:allowedMax,customerCountry);return}this.enableLoading(line);const body=JSON.stringify({line,quantity:requestedQty,sections:this.getSectionsToRender().map(section=>section.id),sections_url:window.location.pathname});fetch(`${routes.cart_change_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);this.renderContents(parsedState),publish(PUB_SUB_EVENTS.cartUpdate,{source:"ajax-cart",cartData:parsedState,variantId}),this.setAttribute("data-items-count",parsedState.items.length)}).catch(console.error).finally(()=>{this.disableLoading(line)})}_proceedUpdate(line,quantity,name,variantId){this.enableLoading(line);const body=JSON.stringify({line,quantity,sections:this.getSectionsToRender().map(section=>section.id),sections_url:window.location.pathname});fetch(`${routes.cart_change_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);this.renderContents(parsedState),publish(PUB_SUB_EVENTS.cartUpdate,{source:"ajax-cart",cartData:parsedState,variantId}),this.setAttribute("data-items-count",parsedState.items.length)}).catch(console.error).finally(()=>{this.disableLoading(line)})}enableLoading(line){if(!line)return;this.loading=!0,document.querySelector(".ajax-cart__products")?.classList.add("ajax-cart__products--disabled"),this.querySelectorAll(`.ajax-cart__product--${line} .loading__spinner`).forEach(overlay=>overlay.classList.remove("hidden")),this.querySelector(".ajax-cart__summary .loading__spinner")?.classList.add("hidden"),document.activeElement.blur(),this.accessbilityStatus?.setAttribute("aria-hidden",!1),this.submitButton?.classList.add("disabled"),this.submitButton?.setAttribute("disabled",!0)}disableLoading(line){if(!line)return;this.loading=!1,document.querySelector(".ajax-cart__products")?.classList.remove("ajax-cart__products--disabled"),this.querySelectorAll(".ajax-cart__product .loading__spinner").forEach(overlay=>overlay.classList.add("hidden")),this.querySelector(".ajax-cart__summary .loading__spinner")?.classList.add("hidden"),this.accessbilityStatus?.setAttribute("aria-hidden",!0),this.submitButton?.classList.remove("disabled"),this.submitButton?.removeAttribute("disabled")}updateStatus(message){!this.accessbilityStatus||!message||(this.accessbilityStatus.setAttribute("aria-hidden",!1),this.accessbilityStatus.innerHTML=message)}resetStatus(){this.accessbilityStatus&&(this.accessbilityStatus.setAttribute("aria-hidden",!0),this.accessbilityStatus.textContent="")}getSectionDOM(html,selector=".shopify-section",all=!1){if(!html){console.info("No markup passed to generate the DOM.");return}const parsedHtml=new DOMParser().parseFromString(html,"text/html");return all?parsedHtml.querySelectorAll(selector):parsedHtml.querySelector(selector)}getSectionInnerHTML(html,selector=".shopify-section"){if(!html){console.info("No markup passed to generate the HTML.");return}const matchingNode=new DOMParser().parseFromString(html,"text/html").querySelector(selector);if(matchingNode)return matchingNode.innerHTML}getSectionsToRender(){return[{id:"cart-notification-product",selector:`[id="cart-notification-product-${this.cartItemKey}"]`},{id:"cart-notification-button"},{id:"cart-icon-bubble"},{id:"p80-ajax-cart",filter:this.filterClass,type:"DOM"}]}setActiveElement(){}});class AjaxCartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault(),this.closest("ajax-cart").updateQuantity(this.dataset.index,0)})}}if(customElements.define("ajax-cart-remove-button",AjaxCartRemoveButton),customElements.get("ajax-cart-note")||customElements.define("ajax-cart-note",class extends HTMLElement{constructor(){super()}connectedCallback(){if(this.textArea=this.querySelector("textarea"),!this.textArea){this.classList.add("hidden");return}this.note=this.textArea.value,this.onInputHandler=debounce(event=>{this.onInput(event)},ON_CHANGE_DEBOUNCE_TIMER).bind(this),this.addEventListener("input",this.onInputHandler)}disconnectedCallback(){this.removeEventListener("input",this.onInputHandler)}onInput(event){const body=JSON.stringify({note:this.textArea?.value});fetch(`${routes.cart_update_url}`,{...fetchConfig(),body}).then(response=>response.json()).then(response=>{this.note=response.note,this.onUpdate()}).catch(event2=>{console.error(event2)})}onUpdate(){const input=document.getElementById("ajax-cart__note-status");input&&(this.note?input.checked=!0:input.checked=!1)}}),typeof AccordionItem=="function"&&typeof AccordionNoteItem!="function"){class AccordionNoteItem2 extends AccordionItem{
1constructor(element){super(element)}onClick(event){super.onClick(event),this.toggleCheckbox()}onKeyDown(event){(event?.code.toUpperCase()==="SPACE"||event?.code.toUpperCase()==="ENTER")&&(super.onKeyDown(event),this.toggleCheckbox())}toggleCheckbox(){const note=this.details.querySelector("ajax-cart-note"),input=document.getElementById("ajax-cart__note-status"),noteStatus=note.note;this.open?this.open&&!noteStatus&&(input.checked=!1):input.checked=!0}}window.AccordionNoteItem=AccordionNoteItem2}customElements.get("accordion-note")||customElements.define("accordion-note",class extends Accordion{constructor(){super()}connectedCallback(){const accordions=Array.from(this.querySelectorAll("details"));this.accordions=accordions.map(accordion=>new AccordionNoteItem(accordion)),this.currentMediaQuery=p80.mediaQueryService.currentMediaQuery,this.onMediaQueryChange(),this.mediaQueryChangeUnsubscriber=subscribe(PUB_SUB_EVENTS.mediaQueryChange,event=>{!event||!event.currentMedia||(this.currentMediaQuery=event.currentMedia,this.onMediaQueryChange())})}}),customElements.get("ajax-cart-toggle")||customElements.define("ajax-cart-toggle",class extends HTMLElement{constructor(){super()}connectedCallback(){this.setAttribute("tabindex",0),this.setAttribute("role","button"),this.handleKeyUp=this.onKeyUp.bind(this),this.handleClick=this.onClick.bind(this,!1),this.addEventListener("keyup",this.handleKeyUp),this.addEventListener("click",this.handleClick)}disconnectedCallback(){this.removeEventListener("keyup",this.handleKeyUp),this.removeEventListener("click",this.handleClick)}onClick(){const cart=document.querySelector("ajax-cart");cart?.isOpen?cart?.close():cart?.open()}onKeyUp(event){if(event?.code==="Enter"){const cart=document.querySelector("ajax-cart");cart?.isOpen?cart?.close():cart?.open()}}});
2//# sourceMappingURL=/cdn/shop/t/42/assets/p80-ajax-cart.js.map?v=40753152398884675031790701078

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.