PageSourceSearch

https://myxtur.com/cdn/shop/t/75/assets/cart.js?v=108484348913538146341775406829

js myxtur.com collected 2026-10-02 16:03:15 UTC 13,149 bytes, 2 lines download raw bytes

1class CartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault(),(this.closest("cart-items")||this.closest("cart-drawer-items")).updateQuantity(this.dataset.index,0)})}}customElements.define("cart-remove-button",CartRemoveButton);function applyDiscount(offerContainer){this.removeAppliedDiscount();const percent=offerContainer.getAttribute("data-offer-percent");offerContainer.innerHTML=`<span class="applied-coupon">${percent}%discount code applied!</span>`;let discountApplyUrl="/discount/"+offerContainer.getAttribute("data-offer-code"),i=document.createElement("iframe");i.style.display="none",i.onload=function(){i.parentNode.removeChild(i)},i.src=discountApplyUrl,document.body.appendChild(i)}function removeAppliedDiscount(){document.querySelectorAll(".myx-product-details-offers.active").forEach(discountAppliedRow=>{let eligibleOffer=discountAppliedRow.getAttribute("data-offer-eligible"),offerCode=discountAppliedRow.getAttribute("data-offer-code");applyOfferTemplate(eligibleOffer,offerCode,discountAppliedRow)})}class CartOfferButton extends HTMLElement{constructor(){super(),this.addEventListener("click",async event=>{event.preventDefault(),await applyDiscount(this);const cartItems=this.closest("cart-items")||this.closest("cart-drawer-items");setTimeout(()=>{cartItems.updateQuantity(this.dataset.index,this.dataset.quantity,"plus")},1e3)})}}customElements.define("cart-offer",CartOfferButton);class CartItems extends HTMLElement{constructor(){super(),this.lineItemStatusElement=document.getElementById("shopping-cart-line-item-status")||document.getElementById("CartDrawer-LineItemStatus");const debouncedOnChange=debounce(event=>{this.onChange(event)},ON_CHANGE_DEBOUNCE_TIMER);this.addEventListener("change",debouncedOnChange.bind(this))}cartUpdateUnsubscriber=void 0;connectedCallback(){this.cartUpdateUnsubscriber=subscribe(PUB_SUB_EVENTS.cartUpdate,event=>{event.source!=="cart-items"&&this.onCartUpdate()})}disconnectedCallback(){this.cartUpdateUnsubscriber&&this.cartUpdateUnsubscriber()}onChange(event){const{target}=event,index=target.dataset.index,value=target.value,name=document.activeElement.getAttribute("name");this.updateQuantity(index,value,name),setTimeout(()=>{this.updateQuantity(index,value,name)},1800)}updateCartCount(itemCount){const cartCountBubbleRef=document.querySelectorAll(".count-bubble");itemCount>0?cartCountBubbleRef.forEach(bubble=>{bubble.removeAttribute("hidden"),bubble.innerHTML=`<span>${itemCount}</span>`}):cartCountBubbleRef.forEach(bubble=>bubble.setAttribute("hidden","hidden"))}onCartUpdate(){fetch(`${routes.cart_url}?section_id=main-cart-items`).then(response=>response.text()).then(responseText=>{const sourceQty=new DOMParser().parseFromString(responseText,"text/html").querySelector("cart-items");this.innerHTML=sourceQty.innerHTML}).catch(e=>{console.error(e)}),fetch(`${location.origin}/cart.js`).then(response=>response.json()).then(data=>this.updateCartCount(data.item_count))}getSectionsToRender(){return[{id:"main-cart-items",section:document.getElementById("main-cart-items").dataset.id,selector:".js-contents"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"},{id:"cart-live-region-text",section:"cart-live-region-text",selector:".shopify-section"},{id:"main-cart-footer",section:document.getElementById("main-cart-footer").dataset.id,selector:".js-contents"}]}updateQuantity(line,quantity,name){this.enableLoading(line);const body=JSON.stringify({line,quantity,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});fetch(`${routes.cart_change_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);this.updateCartCount(parsedState.item_count);const quantityElement=document.getElementById(`Quantity-${line}`)||document.getElementById(`Drawer-quantity-${line}`),items=document.querySelectorAll(".cart-item");if(parsedState.errors){quantityElement.value=quantityElement.getAttribute("value"),this.updateLiveRegions(line,parsedState.errors);return}this.classList.toggle("is-empty",parsedState.item_count===0);const cartDrawerWrapper=document.querySelector("cart-drawer"),cartFooter=document.getElementById("main-cart-footer");cartFooter&&cartFooter.classList.toggle("is-empty",parsedState.item_count===0),c
1artDrawerWrapper&&cartDrawerWrapper.classList.toggle("is-empty",parsedState.item_count===0),this.getSectionsToRender().forEach(section=>{const elementToReplace=document.getElementById(section.id).querySelector(section.selector)||document.getElementById(section.id);elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector)});const updatedValue=parsedState.items[line-1]?parsedState.items[line-1].quantity:void 0;let message="";items.length===parsedState.items.length&&updatedValue!==parseInt(quantityElement.value)&&(typeof updatedValue>"u"?message=window.cartStrings.error:message=window.cartStrings.quantityError.replace("[quantity]",updatedValue)),this.updateLiveRegions(line,message);const tbodyElement=document.querySelector("#main-cart-items tbody")||cartDrawerWrapper.querySelector("tbody");sortAndAppendCartItems(tbodyElement);const lineItem=document.getElementById(`CartItem-${line}`)||document.getElementById(`CartDrawer-Item-${line}`);lineItem&&lineItem.querySelector(`[name="${name}"]`)?cartDrawerWrapper?trapFocus(cartDrawerWrapper,lineItem.querySelector(`[name="${name}"]`)):lineItem.querySelector(`[name="${name}"]`).focus():parsedState.item_count===0&&cartDrawerWrapper?trapFocus(cartDrawerWrapper.querySelector(".drawer__inner-empty"),cartDrawerWrapper.querySelector("a")):document.querySelector(".cart-item")&&cartDrawerWrapper&&trapFocus(cartDrawerWrapper,document.querySelector(".cart-item__name")),publish(PUB_SUB_EVENTS.cartUpdate,{source:"cart-items"})}).catch(()=>{this.querySelectorAll(".loading-overlay").forEach(overlay=>overlay.classList.add("hidden"));const errors=document.getElementById("cart-errors")||document.getElementById("CartDrawer-CartErrors");errors.textContent=window.cartStrings.error}).finally(()=>{this.disableLoading(line)})}updateLiveRegions(line,message){const lineItemError=document.getElementById(`Line-item-error-${line}`)||document.getElementById(`CartDrawer-LineItemError-${line}`);lineItemError&&(lineItemError.querySelector(".cart-item__error-text").innerHTML=message),this.lineItemStatusElement.setAttribute("aria-hidden",!0);const cartStatus=document.getElementById("cart-live-region-text")||document.getElementById("CartDrawer-LiveRegionText");cartStatus.setAttribute("aria-hidden",!1),setTimeout(()=>{cartStatus.setAttribute("aria-hidden",!0)},1e3)}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}enableLoading(line){(document.getElementById("main-cart-items")||document.getElementById("CartDrawer-CartItems")).classList.add("cart__items--disabled");const cartItemElements=this.querySelectorAll(`#CartItem-${line}.loading-overlay`),cartDrawerItemElements=this.querySelectorAll(`#CartDrawer-Item-${line}.loading-overlay`);
1[...cartItemElements,...cartDrawerItemElements].forEach(overlay=>overlay.classList.remove("hidden")),document.activeElement.blur(),this.lineItemStatusElement.setAttribute("aria-hidden",!1)}disableLoading(line){(document.getElementById("main-cart-items")||document.getElementById("CartDrawer-CartItems")).classList.remove("cart__items--disabled");const cartItemElements=this.querySelectorAll(`#CartItem-${line}.loading-overlay`),cartDrawerItemElements=this.querySelectorAll(`#CartDrawer-Item-${line}.loading-overlay`);cartItemElements.forEach(overlay=>overlay.classList.add("hidden")),cartDrawerItemElements.forEach(overlay=>overlay.classList.add("hidden"))}}customElements.define("cart-items",CartItems),customElements.get("cart-note")||customElements.define("cart-note",class extends HTMLElement{constructor(){super(),this.addEventListener("change",debounce(event=>{const body=JSON.stringify({note:event.target.value});fetch(`${routes.cart_update_url}`,{...fetchConfig(),body})},ON_CHANGE_DEBOUNCE_TIMER))}});const productOfferJson={"Smartphone Cover":{2:{code:"SHOWCASE",offer:10,eligible:"Eligible for 10% discount.",more_offer:"Buy 2 phone cases or more"},3:{code:"BRIEFCASE",offer:15,eligible:"Eligible for 15% discount.",more_offer:"Buy 3 phone cases or more"},5:{code:"SUITCASE",offer:20,eligible:"Eligible for 20% discount",more_offer:"Buy 5 phone cases or more"}},Poster:{3:{code:"POSTERCHILD",offer:10,eligible:"Eligible for 10% discount.",more_offer:"Buy Any 3 Metal or Art posters"},5:{code:"POSTERBOY",offer:20,eligible:"Eligible for 20% discount.",more_offer:"Buy Any 5 Metal or Art posters"},8:{code:"GREATWALL",offer:30,eligible:"Eligible for 30% discount.",more_offer:"Buy Any 8 Metal or Art posters"}},Apparel:{2:{code:"TEETIME",offer:10,eligible:"Eligible for 10% discount.",more_offer:"Buy any 2 T-Shirts or Hoodies"},3:{code:"HIGHTEE",offer:15,eligible:"Eligible for 15% discount.",more_offer:"Buy any 3 T-Shirts or Hoodies"},5:{code:"TEEPARTY",offer:20,eligible:"Eligible for 20% discount.",more_offer:"Buy any 5 T-Shirts or Hoodies"},8:{code:"EIGHTEE",offer:25,eligible:"Eligible for 25% discount.",more_offer:"Buy any 8 T-Shirts or Hoodies"}},Accessories:{2:{code:"PAIRUP",offer:10,eligible:"Eligible for 10% discount.",more_offer:"Buy 2 mobile or computer accessories"},3:{code:"TRIPLES",offer:20,eligible:"Eligible for 20% discount.",more_offer:"Buy 3 mobile or computer accessories"},6:{code:"SIXPACK",offer:30,eligible:"Eligible for 30% discount.",more_offer:"Buy 6 mobile or computer accessories"}}};function sortAndAppendCartItems(tbodyElement){const cartItems=Array.from(tbodyElement.querySelectorAll(".cart-item"));cartItems.sort(function(itemA,itemB){let titleA=itemA.getAttribute("data-product-type"),titleB=itemB.getAttribute("data-product-type");return titleA.localeCompare(titleB)}),cartItems.forEach(function(item){tbodyElement.appendChild(item)}),addingOfferTags(cartItems)}function addingOfferTags(cartItems){let productTypeCounts={};cartItems.forEach(function(cartItem){const selector=cartItem.dataset.productType,qty=cartItem.querySelector(".quantity__input").value;productTypeCounts[selector]?productTypeCounts[selector]+=parseInt(qty):productTypeCounts[selector]=parseInt(qty)});for(let productType in productTypeCounts){const productRows=cartItems.filter(item=>item.getAttribute("data-product-type")===productType);if(!productRows.length)return;const availableOfferContainer=productRows[productRows.length-1];setAvailableOfferTemplate(availableOfferContainer,productType,productTypeCounts[productType]),setEligibleOfferTemplate(productRows[0],productType,productTypeCounts[productType])}}function setAvailableOfferTemplate(offerContainer,type,count){let index;type==="Smartphone Cover"?(count===1&&(index=2),count===2?index=3:count>=3&&count<=4&&(index=5)):type==="Poster"?count>=1&&count<=2?index=3:count>=3&&count<=4?index=5:count>=5&&count<=7&&(index=8):type==="Apparel"?count===1?index=2:count===2?index=3:count>=3&&count<=4?index=5:count>=5&&count<=7&&(index=8):type==="Accessories"&&(count===1?index=2:count===2?index=3:count>=3&&count<=5&&(index=6)),index&&(offerContainer.querySelector(".myx-product-offers").innerHTML=`<td class="myx-product-offers"><span>${productOfferJson[type][index].more_offer},<span class="red-label">get ${productOfferJson[type][index].offer}
1%off.</span></span></td>`)}function setEligibleOfferTemplate(productRows,productType,count){const offerContainer=productRows.querySelector(".myx-product-details-offers");let appliedDiscounts=productRows.querySelector(".cart-item__details .discounts__discount"),index;if(productType==="Smartphone Cover"?count===2?index=2:count>=3&&count<=4?index=3:count>=5&&(index=5):productType==="Poster"?count>=3&&count<=4?index=3:count>=5&&count<=7?index=5:count>=8&&(index=8):productType==="Apparel"?count===2?index=2:count>=3&&count<=4?index=3:count>=5&&count<=7?index=5:count>=8&&(index=8):productType==="Accessories"&&(count===2?index=2:count>=3&&count<=5?index=3:count>=6&&(index=6)),!index)return;let offerCode=productOfferJson[productType][index].code,eligibleOffer=productOfferJson[productType][index].eligible,percent=productOfferJson[productType][index].offer;if(offerContainer.setAttribute("data-offer-code",offerCode),offerContainer.setAttribute("data-offer-percent",percent),offerContainer.setAttribute("data-offer-eligible",eligibleOffer),offerContainer.classList.add("active"),appliedDiscounts){applyDiscount(offerContainer);return}applyOfferTemplate(eligibleOffer,offerCode,offerContainer)}function applyOfferTemplate(eligibleOffer,offerCode,eligibleRow){eligibleRow.innerHTML=`<span class="eligible-coupon">${eligibleOffer}<span class="red-label">Click here:</span><strong class="use_code">${offerCode}</strong></span>`}function cartItemSort(){const tbodyElement=document.querySelector("#main-cart-items tbody");sortAndAppendCartItems(tbodyElement)}
2//# sourceMappingURL=/cdn/shop/t/75/assets/cart.js.map?v=108484348913538146341775406829

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.