PageSourceSearch

https://udggear.com/cdn/shop/t/62/assets/module.cart-form.js?v=21319002842506299681789634492

js udggear.com collected 2026-10-04 08:00:39 UTC 4,284 bytes, 2 lines download raw bytes

1import{executeJSmodules}from"util.misc";import{EVENTS}from"util.events";export default class CartForm{constructor(form){if(this.selectors={products:"[data-products]",discounts:"[data-discounts]",subTotal:"[data-subtotal]",header:"[data-header]",locales:"[data-locales]",termsCheckbox:".cart__terms-checkbox",checkoutBtn:".cart__checkout"},this.classes={btnLoading:"btn--loading"},this.config={requiresTerms:!1},!form)return;this.form=form,this.wrapper=form.parentNode,this.products=form.querySelector(this.selectors.products),this.submitBtn=form.querySelector(this.selectors.checkoutBtn),this.discounts=form.querySelector(this.selectors.discounts),this.subtotal=form.querySelector(this.selectors.subTotal),this.header=form.querySelector(this.selectors.header);const termsLabel=form.querySelector(this.selectors.termsCheckbox);this.termsCheckbox=termsLabel?termsLabel.querySelector('input[type="checkbox"]'):null,this.locales=JSON.parse(this.form.querySelector(this.selectors.locales).textContent),this.termsCheckbox&&(this.config.requiresTerms=!0),this.init()}init(){document.addEventListener("cart:quantity",this.quantityChanged.bind(this)),this.form.addEventListener("submit",this.onSubmit.bind(this)),document.addEventListener("cart:build",function(){this.buildCart()}.bind(this)),this.resetLoadingState(),window.addEventListener("pageshow",this.resetLoadingState.bind(this))}resetLoadingState(){this.submitBtn&&this.submitBtn.classList.remove(this.classes.btnLoading)}onSubmit(evt){if(this.submitBtn.classList.add(this.classes.btnLoading),document.documentElement.classList.contains("js-drawer-open")&&this.cartItemsUpdated||document.documentElement.classList.contains("cart-open")&&this.cartItemsUpdated)return this.submitBtn.classList.remove(this.classes.btnLoading),evt.preventDefault(),!1;if(this.config.requiresTerms&&!this.termsCheckbox.checked)return alert(this.locales.cartTermsConfirmation),this.submitBtn.classList.remove(this.classes.btnLoading),evt.preventDefault(),!1}_parseProductHTML(text){const html=document.createElement("div");return html.innerHTML=text,{items:html.querySelector(".cart__items"),discounts:html.querySelector(".cart__discounts"),subtotal:html.querySelector(".cart__subtotal"),count:html.querySelector(".cart-link__bubble"),header:html.querySelector(".cart__header")}}buildCart(){return this.getCartProductMarkup().then(this.cartMarkup.bind(this))}cartMarkup(text){const markup=this._parseProductHTML(text),items=markup.items,header=markup.header.innerHTML,count=parseInt(items.dataset.count),subtotal=markup.subtotal.innerHTML;this.updateCartDiscounts(markup.discounts),count>0?this.wrapper.classList.remove("is-empty"):this.wrapper.classList.add("is-empty"),this.products.innerHTML="",this.products.append(items);const scripts=this.products.querySelectorAll('script[type="module"]');executeJSmodules(scripts),this.subtotal.innerHTML=subtotal,this.header&&(this.header.innerHTML=header),Shopify&&Shopify.StorefrontExpressButtons&&Shopify.StorefrontExpressButtons.initialize()}updateCartDiscounts(markup){this.discounts&&(this.discounts.innerHTML="",this.discounts.append(markup))}quantityChanged(evt){const key=evt.detail[0],qty=evt.detail[1],el=evt.detail[2];!key||!qty||(el&&el.classList.add("is-loading"),this.changeItem({id:key,quantity:qty,sections:"cart-ajax"}).then(state=>{this.cartMarkup(state.sections["cart-ajax"]),document.dispatchEvent(new CustomEvent(EVENTS.cartUpdated,{detail:{cart:state}}))}).catch(async response=>{const data=await response.json();alert(data.description),el.classList.remove("is-loading");const input=el.querySelector(".element-quantity-selector__input");input.value=input.dataset.initialValue,el.style.setProperty("--digit-count",`${input.value.toString().length}ch`)}))}changeItem(body){return fetch(`${window.Shopify.routes.root}cart/change.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(body)}).then(response=>{if(!response.ok)throw response;return response.json()})}getCartProductMarkup(){let url=`${window.Shopify.routes.root}?section_id=cart-ajax`;return fetch(url,{credentials:"same-origin",method:"GET"}).then(response=>response.text()).catch(e=>console.error(e))}}
2//# sourceMappingURL=/cdn/shop/t/62/assets/module.cart-form.js.map?v=21319002842506299681789634492

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.