PageSourceSearch

https://meissnersewing.com/cdn/shop/t/140/assets/custom.js?v=134701539273654876581779948036

js meissnersewing.com collected 2026-09-26 05:19:29 UTC 21,037 bytes, 2 lines download raw bytes

1function toggleButtonLoading(button,isLoading){if(button){if(isLoading){button.setAttribute("disabled",!0),button.classList.add("loading");return}button.classList.remove("loading"),button.removeAttribute("disabled")}}function mergeCartState(source){if(!source||typeof source!="object")return window.globalVariables?.cart;const{sections,...cartFields}=source;return!cartFields.items&&!cartFields.token?window.globalVariables?.cart:(window.globalVariables.cart={...window.globalVariables.cart,...cartFields},window.globalVariables.cart)}function getSectionHtml(sections,sectionId){if(!sections||!sectionId)return null;if(sections[sectionId])return sections[sectionId];const match=Object.keys(sections).find(key=>key===sectionId||key.endsWith(`__${sectionId}`));return match?sections[match]:null}function parseSectionDocument(sectionHTML){return sectionHTML?new DOMParser().parseFromString(sectionHTML,"text/html"):null}function updateCartDrawerFromSection(sectionHTML,cartData){const miniCart=document.querySelector("ajax-cart-mini");if(!miniCart||!sectionHTML)return!1;cartData&&mergeCartState(cartData);const doc=parseSectionDocument(sectionHTML),newMiniCart=doc?.querySelector("ajax-cart-mini"),cartJSONEle=doc?.querySelector("[data-cartScriptJSON]");if(newMiniCart&&(miniCart.innerHTML=newMiniCart.innerHTML),cartJSONEle){const liquidCart=JSON.parse(cartJSONEle.textContent);window.globalVariables.cart={...liquidCart,...window.globalVariables.cart}}return window.globalVariables?.cart&&document.querySelectorAll(".cart-count").forEach(item=>{item.innerText=window.globalVariables.cart.item_count,item.setAttribute("data-cart-count",window.globalVariables.cart.item_count)}),!!newMiniCart}function isDiscountAppliedInCart(cart,code){if(!code||!cart)return!1;const normalizedCode=code.toLowerCase();return(cart.discount_codes||[]).some(discount=>discount.applicable&&discount.code?.toLowerCase()===normalizedCode)||(cart.cart_level_discount_applications||[]).some(discount=>discount.title?.toLowerCase()===normalizedCode)?!0:(cart.discount_applications||[]).some(discount=>discount.type==="discount_code"&&discount.title?.toLowerCase()===normalizedCode)}function updateHeaderFromSection(headerHTML){if(!headerHTML)return;const doc=parseSectionDocument(headerHTML);if(!doc)return;const cartIconDesktop=document.querySelector("#cart-icon-desktop"),cartIconMobile=document.querySelector("#cart-icon-mobile"),desktopIcon=doc.getElementById("cart-icon-desktop"),mobileIcon=doc.getElementById("cart-icon-mobile");cartIconDesktop&&desktopIcon&&(cartIconDesktop.innerHTML=desktopIcon.innerHTML),cartIconMobile&&mobileIcon&&(cartIconMobile.innerHTML=mobileIcon.innerHTML)}function getCartDrawerSectionsUrl(){const pathname=window.location.pathname||"/";return pathname.startsWith("/")?pathname:`/${pathname}`}function closeSheetDrawerInstant(drawer,toggle){if(!drawer)return;const panel=drawer.querySelector(".cart-discount-sheet__panel, .cart-note-sheet__panel");drawer.classList.remove("is-open","is-closing","is-opening"),panel?.style.removeProperty("transition"),panel?.style.removeProperty("transform"),drawer.setAttribute("inert",""),drawer.setAttribute("aria-hidden","true"),toggle?.setAttribute("aria-expanded","false")}function openSheetDrawer(drawer,toggle,onOpened){if(!drawer||drawer.classList.contains("is-open")||drawer.classList.contains("is-closing"))return;const panel=drawer.querySelector(".cart-discount-sheet__panel, .cart-note-sheet__panel");panel&&(drawer.classList.remove("is-closing"),drawer.removeAttribute("inert"),drawer.setAttribute("aria-hidden","false"),toggle?.setAttribute("aria-expanded","true"),drawer.classList.add("is-opening"),panel.style.transition="none",panel.style.transform="translate3d(0, 100%, 0)",panel.offsetHeight,requestAnimationFrame(()=>{panel.style.removeProperty("transition"),panel.style.removeProperty("transform"),drawer.classList.remove("is-opening"),drawer.classList.add("is-open"),requestAnimationFrame(()=>{onOpened?.()})}))}function closeSheetDrawer(drawer,toggle,onClosed){if(!drawer||!drawer.classList.contains("is-open")||drawer.classList.contains("is-closing")){onClosed?.();return}const panel=drawer.querySelector(".cart-discount-sheet__panel, .cart-note-sheet__panel");drawer.classList.add("is-closing"),drawer.classList.remove("is-open"),toggle?.setAttribute("aria-expanded","fal
1se");const finishClose=()=>{drawer.classList.remove("is-closing"),drawer.setAttribute("inert",""),drawer.setAttribute("aria-hidden","true"),panel?.style.removeProperty("transition"),panel?.style.removeProperty("transform"),panel?.removeEventListener("transitionend",onTransitionEnd),onClosed?.()},onTransitionEnd=event=>{event.target!==panel||event.propertyName!=="transform"||finishClose()};panel?.addEventListener("transitionend",onTransitionEnd),setTimeout(finishClose,550)}function handleCartIconClick(event){if(window.globalVariables?.template==="cart"||!window.globalVariables?.cart_drawer)return;const cartIcon=event.target.closest(".header__icon--cart");if(!cartIcon)return;const miniCart=document.querySelector("ajax-cart-mini");!miniCart||typeof miniCart.toggleCart!="function"||(event.preventDefault(),event.stopPropagation(),miniCart.toggleCart(cartIcon))}function handleOutsideCartClick(event){const miniCart=document.querySelector("ajax-cart-mini");if(!miniCart?.classList.contains("cart-show")||miniCart.classList.contains("is-closing"))return;const target=event.type==="touchend"?document.elementFromPoint(event.changedTouches[0].clientX,event.changedTouches[0].clientY):event.target;target&&(target.closest("ajax-cart-mini")||target.closest(".header__icon--cart")||(event.preventDefault(),event.stopPropagation(),miniCart.closeCart(event)))}let cartIconClickBound=!1,outsideCartClickBound=!1;function bindCartIconClickHandler(){cartIconClickBound||(cartIconClickBound=!0,document.addEventListener("click",handleCartIconClick,!0))}function bindOutsideCartClickHandler(){outsideCartClickBound||(outsideCartClickBound=!0,document.addEventListener("click",handleOutsideCartClick,!0),document.addEventListener("touchend",handleOutsideCartClick,!0))}class AjaxCartMini extends HTMLElement{constructor(){super(),this._autoCloseTimer=null,this._closeFallbackTimer=null,this._isClosing=!1}connectedCallback(){this.style.removeProperty("display"),window.globalVariables?.template!=="cart"&&(this.bindEvents(),this.syncQtyControls())}static get observedAttributes(){return["updating"]}attributeChangedCallback(name,oldValue,newValue){name==="updating"&&newValue==="false"&&oldValue!=null&&this.syncQtyControls()}bindEvents(){this._onClick=this.onClick.bind(this),this._onKeyUp=this.onKeyUp.bind(this),this.addEventListener("click",this._onClick),this.addEventListener("keyup",this._onKeyUp)}disconnectedCallback(){this.removeEventListener("click",this._onClick),this.removeEventListener("keyup",this._onKeyUp),this._clearCloseTimers()}_clearCloseTimers(){this._autoCloseTimer&&(clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null),this._closeFallbackTimer&&(clearTimeout(this._closeFallbackTimer),this._closeFallbackTimer=null),this._onCloseTransitionEnd&&(this.removeEventListener("transitionend",this._onCloseTransitionEnd),this._onCloseTransitionEnd=null)}_finishClose(){this._clearCloseTimers(),this.classList.remove("is-closing"),this._isClosing=!1,siteOverlay.prototype.hideOverlay()}onClick(event){if(event.target.closest(".cart-close-btn")){event.preventDefault(),event.stopPropagation(),this.closeCart();return}const qtyBtn=event.target.closest("[data-qty-btn]");if(qtyBtn){event.preventDefault(),event.stopPropagation(),this.manageQtyBtn(qtyBtn);return}const removeBtn=event.target.closest("[data-itemRemove]");removeBtn&&(event.preventDefault(),this.removeItem(removeBtn))}onKeyUp(event){event.code?.toUpperCase()==="ESCAPE"&&this.closeCart()}toggleCart(trigger){this.classList.contains("cart-show")?this.closeCart():this.openCart(trigger)}openCart(trigger){document.querySelector("#mobile-menu-drawer")?.classList.contains("opened-drawer")&&document.querySelector(".close-mobile--navbar")?.dispatchEvent(new Event("click")),this._clearCloseTimers(),this._isClosing=!1,this.classList.remove("is-closing"),this.classList.add("cart-show"),siteOverlay.prototype.showOverlay(),trigger?.setAttribute&&trigger.setAttribute("aria-expanded","true"),this.getCartData()}closeCart(event){if(event?.preventDefault?.(),event?.stopPropagation?.(),this._autoCloseTimer&&(clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null),!this.classList.contains("cart-show")||this._isClosing)return;this._isClosing=!0;const footer=this.querySelector(".cart-footer");closeSheetDrawerInstant(footer?.querySelector("[data-discount-drawer]"),footer?.querySelector("[data-discount-toggle]")),closeSheetDrawerInstant(footer?.querySelector("[data-note-drawer]"),footer?.querySelector("[data-note-toggle]")),document.querySelectorAll(".header__icon--cart").forEach(btn=>
1{btn.setAttribute("aria-expanded","false")}),this.classList.add("is-closing"),this.classList.remove("cart-show"),this._onCloseTransitionEnd=transitionEvent=>{transitionEvent.target!==this||transitionEvent.propertyName!=="transform"||this._finishClose()},this.addEventListener("transitionend",this._onCloseTransitionEnd),this._closeFallbackTimer=setTimeout(()=>this._finishClose(),700)}getCartData(action){if(window.globalVariables?.template==="cart")return Promise.resolve();const cartRoute=`${routes.cart_fetch_url}?sections=template-cart-drawer,header`;return fetch(cartRoute).then(response=>response.json()).then(response=>this._updateCart(response,action)).catch(error=>console.error(error))}_updateCart(response,action){this.setAttribute("updating","true");const sectionHTML=response["template-cart-drawer"];if(!sectionHTML){this.setAttribute("updating","false");return}updateCartDrawerFromSection(sectionHTML),this._updateCartCount(),updateHeaderFromSection(response.header),this.setAttribute("updating","false"),action==="open"&&(this.classList.add("cart-show"),siteOverlay.prototype.showOverlay(),this._autoCloseTimer&&clearTimeout(this._autoCloseTimer),this._autoCloseTimer=setTimeout(()=>{this.closeCart()},3e3))}_updateCartCount(){document.querySelectorAll(".cart-count").forEach(item=>{item.innerText=window.globalVariables.cart.item_count,item.setAttribute("data-cart-count",window.globalVariables.cart.item_count)})}updateItemQty(line,quantity){const lineItem=this.querySelectorAll("[data-cart-item]")[line-1];lineItem&&lineItem.classList.add("updating"),fetch(`${routes.cart_change_url}`,{...fetchConfig(),body:JSON.stringify({line,quantity})}).then(response=>response.text()).then(()=>{this.getCartData(this.classList.contains("cart-show")?"keep-open":null)}).catch(error=>console.error(error)).finally(()=>{setTimeout(()=>{lineItem?.classList.remove("updating")},500)})}removeItem(removeBtn){const productTitle=removeBtn.getAttribute("data-product-title"),productPrice=removeBtn.getAttribute("data-product-price"),productQuantity=removeBtn.getAttribute("data-product-quantity"),variantId=removeBtn.getAttribute("data-variant-id"),itemIndex=removeBtn.dataset.index;typeof gtag=="function"&&gtag("event","remove_from_cart",{currency:"USD",value:productPrice,items:[{item_id:`"${variantId}"`,item_name:`"${productTitle}"`,quantity:`"${productQuantity}"`}]}),itemIndex&&this.updateItemQty(itemIndex,0)}manageQtyBtn(qtyBtn){const qtyContainer=qtyBtn.closest("[data-qty-container]"),qtyInput=qtyContainer?.querySelector("[data-qty-input]"),decreaseBtn=qtyContainer?.querySelector('[data-for="decrease"]');if(!qtyInput)return;const action=qtyBtn.dataset.for||"increase",itemIndex=qtyInput.dataset.index,currentQty=parseInt(qtyInput.value,10)||1;let finalQty=currentQty;if(action==="decrease"){if(currentQty<=1){decreaseBtn?.classList.add("disabled");return}finalQty=currentQty-1}else finalQty=currentQty+1;decreaseBtn&&decreaseBtn.classList.toggle("disabled",finalQty<=1),itemIndex&&this.updateItemQty(itemIndex,finalQty)}syncQtyControls(){this.querySelectorAll("[data-qty-container]").forEach(container=>{const qtyInput=container.querySelector("[data-qty-input]"),decreaseBtn=container.querySelector('[data-for="decrease"]');if(!qtyInput||!decreaseBtn)return;const qty=parseInt(qtyInput.value,10)||1;decreaseBtn.classList.toggle("disabled",qty<=1)})}}customElements.define("ajax-cart-mini",AjaxCartMini),bindCartIconClickHandler(),bindOutsideCartClickHandler();class CartDiscount extends HTMLElement{connectedCallback(){queueMicrotask(()=>this.bindEvents())}disconnectedCallback(){this.unbindEvents(),document.removeEventListener("keyup",this._onKeyUp)}queryElements(){this.footer=this.closest(".cart-footer"),this.form=this.footer?.querySelector("[data-discount-form]"),this.errorEl=this.footer?.querySelector("[data-discount-error]"),this.footerDiscountsList=this.footer?.querySelector("[data-cart-footer-discounts]"),this.input=this.footer?.querySelector("[data-discount-input]"),this.applyBtn=this.footer?.querySelector("[data-apply-discount]"),this.drawer=this.footer?.querySelector("[data-discount-drawer]"),this.toggle=this.querySelector("[data-discount-toggle]")}bindEvents(){this.isConnected&&(this.unbindEvents(),this.queryElements(),this._onKeyUp=this.onKeyUp.bind(this),this._onClick=this.onClick.bind(this),this._onSubmit=this.applyDiscount.bind(this),this._onToggleClick=this.openDrawer.bind(this),this._onCloseClick=this.closeDrawer.bind(this),this._onDelegatedClick=this.onClick.bind(this),this.form?.addEventListener("submit",this._onSubmit),this.toggle?.addEventListener("click",this._onToggleClick),this.drawer?.querySelectorAll("[data-discount-close]").forEach(button=>{button.addEventListener("click",this._onCloseClick)}),this._cartMini=document.querySelector("ajax-cart-mini"),this._cartMini?.addEventListener("click",this._onDelegatedClick),this._bound=!0)}unbindEvents(){this._bound&&(this.form?.removeEventListener("submit",this._onSubmit),this.toggle?.removeEventListener("click",this._onToggleClick),this.drawer?.querySelectorAll("[data-discount-close]").forEach(button=>{button.removeEventListener("click",this._onCloseClick)}),this._cartMini?.removeEventListener("click",this._onDelegatedClick),this._bound=!1)}openDrawer(){if(this.drawer||this.queryElements(),!this.drawer)return;const noteDrawer=this.footer?.querySelector("[data-note-drawer]"),noteToggle=this.footer?.querySelector("[data-note-toggle]");noteDrawer?.classList.contains("is-open")&&closeSheetDrawerInstant(noteDrawer,noteToggle),openSheetDrawer(this.drawer,this.toggle,()=>{this.input?.focus()}),document.addEventListener("keyup",this._onKeyUp)}closeDrawer(){this.drawer||this.queryElements(),this.drawer&&closeSheetDrawer(this.drawer,this.toggle,()=>{document.removeEventListener("keyup",this._onKeyUp),this.toggle?.focus()})}onKeyUp(event){event.code?.toUpperCase()==="ESCAPE"&&this.closeDrawer()}onClick(event){const removeBtn=event.target.closest("[data-remove-discount]");if(!removeBtn||removeBtn.classList.contains("loading"))return;event.preventDefault();const code=removeBtn.closest("[data-discount-code]")?.dataset.discountCode;
1code&&this.removeDiscount(code,removeBtn)}async fetchCartJson(){const response=await fetch(`${routes.cart_fetch_url}.js`);if(!response.ok)throw new Error(`Cart request failed (${response.status})`);return response.json()}async removeDiscount(code,removeBtn){toggleButtonLoading(removeBtn,!0);try{const cart=await this.fetchCartJson(),normalizedCode=code.toLowerCase(),codes=(cart.discount_codes||[]).filter(discount=>discount.applicable).map(discount=>discount.code).filter(item=>item.toLowerCase()!==normalizedCode);this.updateDiscountCodes(codes,{triggerButton:removeBtn})}catch(error){console.error(error),this.showError(),toggleButtonLoading(removeBtn,!1)}}showError(){this.errorEl||this.queryElements(),this.errorEl?.classList.remove("d-none")}hideError(){this.errorEl||this.queryElements(),this.errorEl?.classList.add("d-none")}applyDiscount(event){event.preventDefault(),this.form||this.queryElements();const code=this.input?.value.trim();!code||this.applyBtn?.classList.contains("loading")||(this.hideError(),toggleButtonLoading(this.applyBtn,!0),this.fetchCartJson().then(cart=>{const existingDiscounts=(cart.discount_codes||[]).filter(discount=>discount.applicable).map(discount=>discount.code);if(existingDiscounts.some(item=>item.toLowerCase()===code.toLowerCase())){this.input&&(this.input.value=""),toggleButtonLoading(this.applyBtn,!1);return}this.updateDiscountCodes([...existingDiscounts,code],{triggerButton:this.applyBtn})}).catch(error=>{console.error(error),this.showError(),toggleButtonLoading(this.applyBtn,!1)}))}updateDiscountCodes(codes,{triggerButton}={}){const discountValue=codes.length?codes.join(","):"";fetch(routes.cart_update_url,{...fetchConfig(),body:JSON.stringify({discount:discountValue,sections:["template-cart-drawer","header"],sections_url:getCartDrawerSectionsUrl()})}).then(response=>{if(!response.ok)throw new Error(`Discount update failed (${response.status})`);return response.json()}).then(data=>this.handleDiscountResponse(data,codes,triggerButton)).catch(error=>{console.error(error),this.showError(),toggleButtonLoading(triggerButton,!1)})}handleDiscountResponse(data,submittedCodes,triggerButton){const latestCode=submittedCodes[submittedCodes.length-1],latestDiscount=data.discount_codes?.find(discount=>discount.code.toLowerCase()===latestCode?.toLowerCase());if(latestCode&&latestDiscount?.applicable===!1){this.input&&(this.input.value=""),this.showError(),toggleButtonLoading(triggerButton,!1);return}if(latestCode&&!isDiscountAppliedInCart(data,latestCode)){this.input&&(this.input.value=""),this.showError(),toggleButtonLoading(triggerButton,!1);return}this.refreshCartDrawer(data,{triggerButton})}refreshCartDrawer(data,{triggerButton}={}){const drawerSectionHtml=getSectionHtml(data.sections,"template-cart-drawer"),didRefresh=updateCartDrawerFromSection(drawerSectionHtml,data);updateHeaderFromSection(getSectionHtml(data.sections,"header")),didRefresh||document.querySelector("ajax-cart-mini")?.getCartData?.(),this.hideError(),this.input&&(this.input.value=""),toggleButtonLoading(triggerButton,!1)}}customElements.define("cart-discount",CartDiscount);class CartNote extends HTMLElement{connectedCallback(){queueMicrotask(()=>this.bindEvents())}disconnectedCallback(){this.unbindEvents(),document.removeEventListener("keyup",this._onKeyUp)}queryElements(){this.footer=this.closest(".cart-footer"),this.drawer=this.footer?.querySelector("[data-note-drawer]"),this.toggle=this.querySelector("[data-note-toggle]"),this.input=this.footer?.querySelector("[data-cart-note-input]"),this.saveBtn=this.footer?.querySelector("[data-note-save]"),this.successEl=this.footer?.querySelector("[data-note-success]")}bindEvents(){this.isConnected&&(this.unbindEvents(),this.queryElements(),this._onKeyUp=this.onKeyUp.bind(this),this._onToggleClick=this.openDrawer.bind(this),this._onCloseClick=this.closeDrawer.bind(this),this._onSaveClick=this.saveNote.bind(this),this.toggle?.addEventListener("click",this._onToggleClick),this.drawer?.querySelectorAll("[data-note-close]").forEach(button=>{button.addEventListener("click",this._onCloseClick)}),this.saveBtn?.addEventListener("click",this._onSaveClick),this._bound=!0)}unbindEvents(){this._bound&&(this.toggle?.removeEventListener("click",this._onToggleClick),this.drawer?.querySelectorAll("[data-note-close]").forEach(button=>{button.removeEventListener("click",this._onCloseClick)}),this.saveBtn?.removeEventListener("click",this._onSaveClick),this._bound=!1)}openDrawer(){if(this.drawer||this.queryElements(),!this.drawer)return;const discountDrawer=this.footer?.querySelector("[data-discount-drawer]"),discountToggle=this.footer?.querySelector("[data-discount-toggle]");discountDrawer?.classList.contains("is-open")&&closeSheetDrawerInstant(discountDrawer,discountToggle),openSheetDrawer(this.drawer,this.toggle,()=>{this.input?.focus()}),document.addEventListener("keyup",this._onKeyUp)}closeDrawer(){this.drawer||this.queryElements(),this.drawer&&closeSheetDrawer(this.drawer,this.toggle,()=>{this.resetNote(),document.removeEventListener("keyup",this._onKeyUp),this.toggle?.focus()})}resetNote(){this.input&&(this.input.value=this.input.dataset.default||"",this.successEl?.classList.add("d-none"))}onKeyUp(event){event.code?.toUpperCase()==="ESCAPE"&&this.closeDrawer()}saveNote(){if(!this.input||!this.saveBtn||this.saveBtn.classList.contains("loading"))return;const note=this.input.value.trim(),defaultNote=this.input.dataset.default||"";note!==defaultNote&&(toggleButtonLoading(this.saveBtn,!0),fetch(routes.cart_update_url,{...fetchConfig(),body:JSON.stringify({note})}).then(response=>response.json()).then(()=>{this.input.dataset.default=note,this.successEl?.classList.remove("d-none"),setTimeout(()=>this.successEl?.classList.add("d-none"),2e3)}
1).catch(error=>console.error(error)).finally(()=>{toggleButtonLoading(this.saveBtn,!1)}))}}customElements.define("cart-note",CartNote);
2//# sourceMappingURL=/cdn/shop/t/140/assets/custom.js.map?v=134701539273654876581779948036

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.