PageSourceSearch

https://onewheel.com/cdn/shop/t/416/assets/cart-ajax.js?v=164093949014870726061788874451

js onewheel.com collected 2026-10-03 21:37:49 UTC 18,859 bytes, 2 lines download raw bytes

1window.OWCartPageAjax=window.OWCartPageAjax||(function(){var isUpdating=!1,cartLoadingLocks=0,subtotalLoadingLocks=0,cartSectionRefreshGeneration=0,qtySubmitTimer=null,QTY_DEBOUNCE_MS=500,UI_TOGGLE_SELECTOR=".read-shoppay, .read-shipping, .read-warranty, .read-remove, .close-me, .qty-badge";function cartUrl(path){var root=window.Shopify&&window.Shopify.routes&&window.Shopify.routes.root||"/";return root+path.replace(/^\//,"")}function getCartEl(){return document.getElementById("cart")}function setCartBusy(busy){var cart=getCartEl();cart&&(cart.classList.toggle("is-updating",busy),cart.setAttribute("aria-busy",String(busy)))}function applyLoadingUi(){var _a,_b;var cartLoading=cartLoadingLocks>0,subtotalLoading=cartLoading||subtotalLoadingLocks>0,subtotal=document.querySelector("#cart .checkout-cart-summary--sub-total--display-price"),insuranceCost=document.querySelector("#cart #insurance-cost"),summary=document.querySelector("#cart #checkout-cart-summary");summary==null||summary.setAttribute("aria-busy",String(subtotalLoading)),subtotal==null||subtotal.classList.toggle("is-loading",subtotalLoading);var shipPlusOnlyBusy=(_b=(_a=window.OWShipPlus)==null?void 0:_a.isInsuranceBusy)==null?void 0:_b.call(_a);insuranceCost==null||insuranceCost.classList.toggle("is-loading",cartLoading&&!shipPlusOnlyBusy)}function setCartLoadingState(loading){cartLoadingLocks+=loading?1:-1,cartLoadingLocks<0&&(cartLoadingLocks=0),applyLoadingUi()}function setSubtotalLoadingState(loading){subtotalLoadingLocks+=loading?1:-1,subtotalLoadingLocks<0&&(subtotalLoadingLocks=0),applyLoadingUi()}function parseJsonResponse(response){return response.json().catch(function(){return{}})}function postJson(path,body){return fetch(cartUrl(path),{method:"POST",headers:{"Content-Type":"application/json; charset=UTF-8"},credentials:"same-origin",body:JSON.stringify(body||{})}).then(parseJsonResponse)}function postFormEncoded(path,body){var params=new URLSearchParams;return Object.keys(body||{}).forEach(function(key){params.append(key,body[key])}),fetch(cartUrl(path),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},credentials:"same-origin",body:params.toString()}).then(parseJsonResponse)}function fetchCartJson(){return fetch(cartUrl("cart.js"),{credentials:"same-origin"}).then(parseJsonResponse)}function fetchCartSectionHtml(){return fetch(cartUrl("cart?section_id=cart"),{credentials:"same-origin"}).then(function(response){return response.text()})}function getCartChangeParams(href){var url=new URL(href,window.location.origin),quantity=url.searchParams.get("quantity");return{id:url.searchParams.get("id"),quantity:quantity===null?null:Number(quantity)}}function getVisibleCartCount(cart){return window.OWShipPlus&&typeof window.OWShipPlus.getRealCartItemCount=="function"?window.OWShipPlus.getRealCartItemCount(cart):cart.items.reduce(function(count,item){return count+item.quantity},0)}function getCurrentHeaderCartCount(){var cartCount=document.querySelector(".cart-count");return cartCount&&parseInt(cartCount.textContent,10)||0}function renderHeaderCartCount(count){document.querySelectorAll(".cart-frame").forEach(function(cartFrame){var cartCount=cartFrame.querySelector(".cart-count");if(count<=0){cartCount==null||cartCount.remove();return}cartCount||(cartCount=document.createElement("span"),cartCount.className="cart-count",cartFrame.appendChild(cartCount)),cartCount.textContent=count,cartCount.classList.toggle("tight",count>9)})}function optimisticallyUpdateHeaderCartCount(delta){renderHeaderCartCount(Math.max(0,getCurrentHeaderCartCount()+delta))}function refreshHeaderCartCount(){return fetchCartJson().then(function(cart){renderHeaderCartCount(getVisibleCartCount(cart))})}function syncShipPlusPropsFromHtml(html){var match=html.match(/['"]__preTaxPrice['"]\s*:\s*([0-9.]+)/);match&&(window.__shipPlusScpProps={__preTaxPrice:Number(match[1])})}function syncShipPlusPropsFromCart(cart){var _a;if(!(!cart||!cart.items)){(_a=window.OWShipPlus)!=null&&_a.rememberCart&&window.OWShipPlus.rememberCart(cart);var insuranceItem=window.OWShipPlus&&window.OWShipPlus.getInsuranceItem(cart),preTaxCents=0;
1cart.items.forEach(function(item){insuranceItem&&item.key===insuranceItem.key||(preTaxCents+=item.final_line_price)}),window.__shipPlusScpProps={__preTaxPrice:preTaxCents/100}}}function isCartPayload(value){return!!(value&&Array.isArray(value.items))}function beginCartSectionRefresh(){return cartSectionRefreshGeneration+=1,cartSectionRefreshGeneration}function isCurrentCartSectionRefresh(generation){return generation===cartSectionRefreshGeneration}function replaceFromSectionHtml(html,selectors){var doc=new DOMParser().parseFromString(html,"text/html");selectors.forEach(function(selector){var fresh=doc.querySelector(selector),current=document.querySelector(selector);fresh&&current&&current.replaceWith(fresh)})}function syncShopPayFromSectionHtml(html){var doc=new DOMParser().parseFromString(html,"text/html"),freshListItem=doc.querySelector("li.klarna-p"),currentListItem=document.querySelector("li.klarna-p"),list=document.querySelector(".checkout-disclaimers ul");if(freshListItem&&currentListItem){currentListItem.replaceWith(freshListItem);return}if(freshListItem&&!currentListItem&&list){list.appendChild(freshListItem);return}!freshListItem&&currentListItem&&currentListItem.remove()}function afterInsuranceOnlyChange(cart){return isCartPayload(cart)&&syncShipPlusPropsFromCart(cart),fetchCartSectionHtml().then(function(html){html&&(syncShipPlusPropsFromHtml(html),replaceFromSectionHtml(html,[".ow-ship",".checkout-cart-summary--sub-total--display-price"]),syncShopPayFromSectionHtml(html))}).then(function(){if(isCartPayload(cart)){renderHeaderCartCount(getVisibleCartCount(cart));return}return refreshHeaderCartCount()}).then(function(){var _a;(_a=window.OWShipPlus)!=null&&_a.setToggleEnabled&&!window.OWShipPlus.isInsuranceBusy()&&window.OWShipPlus.setToggleEnabled(!0)})}function replaceCartSection(html,generation){if(generation!==void 0&&!isCurrentCartSectionRefresh(generation))return!1;var doc=new DOMParser().parseFromString(html,"text/html"),freshCart=doc.getElementById("cart"),currentCart=getCartEl(),freshCartContent=freshCart==null?void 0:freshCart.querySelector("#checkout-cart--cart");return!freshCart||!currentCart?!1:(freshCartContent!=null&&freshCartContent.querySelector("tr.bundle-upsell")&&freshCartContent.classList.add("show-bundle-cross"),currentCart.replaceWith(freshCart),isUpdating&&(setCartBusy(!0),applyLoadingUi()),!0)}function reconcileShipPlus(cart){var _a;var options={suppressUi:!0};return isCartPayload(cart)&&(options.cart=cart),(_a=window.OWShipPlus)!=null&&_a.runInsuranceCheck?window.OWShipPlus.runInsuranceCheck(options):Promise.resolve(!1)}function afterCartChange(cart,options){if(options=options||{},options.insuranceOnly)return afterInsuranceOnlyChange(cart);var refreshGeneration=beginCartSectionRefresh(),latestCart=isCartPayload(cart)?cart:null;return latestCart&&syncShipPlusPropsFromCart(latestCart),reconcileShipPlus(latestCart).then(function(insuranceChanged){if(isCurrentCartSectionRefresh(refreshGeneration)&&!(!insuranceChanged||!latestCart))return fetchCartJson().then(function(freshCart){isCurrentCartSectionRefresh(refreshGeneration)&&(latestCart=freshCart,syncShipPlusPropsFromCart(latestCart))})}).then(function(){if(isCurrentCartSectionRefresh(refreshGeneration))return fetchCartSectionHtml()}).then(function(html){!isCurrentCartSectionRefresh(refreshGeneration)||!html||(syncShipPlusPropsFromHtml(html),replaceCartSection(html,refreshGeneration))}).then(function(){if(isCurrentCartSectionRefresh(refreshGeneration)){if(latestCart){renderHeaderCartCount(getVisibleCartCount(latestCart));return}return refreshHeaderCartCount()}}).then(function(){var _a;(_a=window.OWShipPlus)!=null&&_a.setToggleEnabled&&!window.OWShipPlus.isInsuranceBusy()&&window.OWShipPlus.setToggleEnabled(!0)})}function runCartUpdate(operation,options){return isUpdating?Promise.reject(new Error("Cart update already in progress")):(isUpdating=!0,setCartLoadingState(!0),setCartBusy(!0),Promise.resolve().then(operation).then(function(cart){return afterCartChange(cart,options)}).finally(function(){isUpdating=!1,setCartLoadingState(!1),setCartBusy(!1)}))}function changeByUrl(href){var params=getCartChangeParams(href);return!params.id||params.quantity===null?Promise.reject(new Error("Missing cart line update parameters.")):postJson("cart/change.js",{id:params.id,quantity:params.quantity})}function changeLineQuantity(lineKey,quantity){return postJson("cart/change.js",{id:lineKey,quantity:quantity})}function updateLinesToZero(keys){var updates={};return keys.forEach(function(key){updates[key]=0}),postJson("cart/update.js",{updates:updates})}function submitCartForm(form){var params=new URLSearchParams(new FormData(form));return params.delete("checkout"),fetch(cartUrl("cart/update.js"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},credentials:"same-origin",body:params.toString()}).then(parseJsonResponse)}function handleCartUpdateFailure(error,fallbackHref){if(console.error("Cart update failed:",error),fallbackHref){window.location.assign(fallbackHref);return}window.location.reload()}function optimisticallyRemoveLine(trigger){var group=trigger.closest("tbody.bundle-group, tr.bundle-group");if(group){var table=group.closest("table.cart-items-table");if(group.remove(),!(!table||!table.isConnected||table.querySelector("tbody.bundle-group, tr.bundle-group"))){var label=table.previousElementSibling;table.remove(),label&&label.classList.contains("tab-label")&&label.remove()}}}function findQtyBadgeTextNode(badge){return Array.prototype.find.call(badge.childNodes,function(node){return node.nodeType===Node.TEXT_NODE&&node.nodeValue.trim()!==""})}function setQtyBadgeText(badge,quantity){if(badge){var textNode=findQtyBadgeTextNode(badge);textNode?textNode.nodeValue=textNode.nodeValue.replace(/\S+/,quantity):badge.insertBefore(document.createTextNode(quantity),badge.firstChild)}}function getQtyBadgeValue(badge){if(!badge)return 0;var textNode=findQtyBadgeTextNode(badge);return parseInt(textNode==null?void 0:textNode.nodeValue,10)||0}function optimisticallyUpdateQuantity(trigger,quantity){if(quantity){var row=trigger.closest("tr"),quantityMenu=trigger.closest(".toggle-quantity"),activeBadge=quantityMenu==null?void 0:quantityMenu.closest(".qty-badge"),priceTotal=row==null?void 0:row.querySelector(".price-total"),oldQuantity=parseInt(row==null?void 0:row.getAttribute("data-qty"),10)||getQtyBadgeValue(activeBadge);row&&(row.setAttribute("data-qty",String(quantity)),setQtyBadgeText(row.querySelector(".qty-badge.show-small"),quantity)),optimisticallyUpdateHeaderCartCount(quantity-oldQuantity),setQtyBadgeText(activeBadge,quantity),activeBadge==null||activeBadge.classList.remove("active"),quantityMenu==null||quantityMenu.classList.remove("show"),row==null||row.classList.remove("qty-menu-open"),quantityMenu==null||quantityMenu.querySelectorAll("a").forEach(function(link){var linkHref=link.getAttribute("href"),linkQuantity=linkHref?getCartChangeParams(linkHref).quantity:Number(link.textContent.trim());link.classList.toggle("strong",linkQuantity===quantity)}),priceTotal==null||priceTotal.classList.add("is-loading")}}function scheduleCartFormSubmit(){clearTimeout(qtySubmitTimer),qtySubmitTimer=setTimeout(function(){var form=document.getElementById("cartform");!form||isUpdating||runCartUpdate(function(){return submitCartForm(form)}).catch(handleCartUpdateFailure)},QTY_DEBOUNCE_MS)}function adjustQtyInput(input,delta){var value=parseInt(input.value,10);isNaN(value)&&(value=0),value=Math.max(0,value+delta),input.value=value,scheduleCartFormSubmit()}function isCheckoutSubmitter(submitter){var _a;return submitter?submitter.name==="checkout"||!!((_a=submitter.closest)!=null&&_a.call(submitter,".mobile-frame-checkout")):!1}function isCartMutationInteraction(target){return!(target instanceof Element)||!target.closest("#cart")||target.closest(UI_TOGGLE_SELECTOR)?!1:!!(target.closest(".clear-cart, .bundle-remove-link, .toggle-quantity a, .qtyplus, .qtyminus, .line-variant-switcher select")||target.closest('input[name="checkout"], button[name="checkout"], .cart
1-page--checkout-button, .mobile-frame-checkout')||target.matches('input[id^="updates"]')&&target.closest("#cartform"))}function swapVariant(wrap,newVariantId){var lineKey=wrap.getAttribute("data-line-key"),currentVariantId=wrap.getAttribute("data-current-variant"),quantity=parseInt(wrap.getAttribute("data-qty"),10)||1,status=wrap.querySelector(".switcher-status"),properties={};if(String(newVariantId)!==String(currentVariantId)){try{properties=JSON.parse(wrap.getAttribute("data-props")||"{}")||{}}catch(error){properties={}}status&&(status.hidden=!1,status.textContent="Updating\u2026"),runCartUpdate(function(){return postFormEncoded("cart/change.js",{id:lineKey,quantity:0}).then(function(){return postJson("cart/add.js",{id:Number(newVariantId),quantity:quantity,properties:properties})})}).catch(function(){status&&(status.textContent="Sorry\u2014couldn\u2019t update. Try again.")})}}function handleBundleRemove(btn){var keys=(btn.getAttribute("data-bundle-keys")||"").split("|").filter(Boolean),updateKeys=keys.slice(),removeBoth=btn.getAttribute("data-remove-both")==="1",boardKey=btn.getAttribute("data-board-key");if(removeBoth&&boardKey&&updateKeys.push(boardKey),!keys.length&&!(removeBoth&&boardKey)){var href=btn.getAttribute("href");if(!href)return;runCartUpdate(function(){return changeByUrl(href)}).catch(function(error){handleCartUpdateFailure(error,href)});return}runCartUpdate(function(){return updateLinesToZero(updateKeys)}).catch(handleCartUpdateFailure)}function initEventHandlers(){document.addEventListener("click",function(event){!isUpdating||!isCartMutationInteraction(event.target)||(event.preventDefault(),event.stopImmediatePropagation())},!0),document.addEventListener("click",function(event){var _a,_b,_c,_d;if(event.target instanceof Element){var target=event.target;if(target.closest(".read-shoppay")){(_a=document.querySelector(".show-shoppay"))==null||_a.classList.toggle("hide");return}if(target.closest(".read-shipping")){(_b=document.querySelector(".show-shipping"))==null||_b.classList.toggle("hide");return}if(target.closest(".read-warranty")){(_c=document.querySelector(".show-warranty"))==null||_c.classList.toggle("hide");return}if(target.closest(".close-me")){document.querySelectorAll(".read-remove.show-more").forEach(function(el){el.classList.remove("show-more")});return}if(target.closest(".read-remove")){(_d=target.closest(".read-remove"))==null||_d.classList.toggle("show-more"),document.querySelectorAll(".qty-badge.active").forEach(function(badge){badge.classList.remove("active")}),document.querySelectorAll("#cart .toggle-quantity.show").forEach(function(menu){menu.classList.remove("show")}),document.querySelectorAll("#cart tr.qty-menu-open").forEach(function(row){row.classList.remove("qty-menu-open")});return}var clearCart=target.closest(".clear-cart");if(clearCart){event.preventDefault();var clearHref=clearCart.getAttribute("href")||"/cart/clear";runCartUpdate(function(){return postJson("cart/clear.js")}).catch(function(error){handleCartUpdateFailure(error,clearHref)});return}var bundleRemove=target.closest(".bundle-remove-link");if(bundleRemove){event.preventDefault(),optimisticallyRemoveLine(bundleRemove),handleBundleRemove(bundleRemove);return}var dataQtyLink=target.closest(".toggle-quantity a[data-q]");if(dataQtyLink){event.preventDefault();var lineKey=dataQtyLink.getAttribute("data-line-key"),qty=parseInt(dataQtyLink.getAttribute("data-q"),10)||1;optimisticallyUpdateQuantity(dataQtyLink,qty),runCartUpdate(function(){return changeLineQuantity(lineKey,qty)}).catch(handleCartUpdateFailure);return}var quantityLink=target.closest(".toggle-quantity a.cart.remove-link");if(quantityLink){event.preventDefault();var quantityHref=quantityLink.getAttribute("href");optimisticallyUpdateQuantity(quantityLink,getCartChangeParams(quantityHref).quantity),runCartUpdate(function(){return changeByUrl(quantityHref)}).catch(function(error){handleCartUpdateFailure(error,quantityHref)});return}var qtyBadge=target.closest(".qty-badge");if(qtyBadge&&qtyBadge.closest("#cart")&&!target.closest(".toggle-quantity a")){event.preventDefault();var qtyRow=qtyBadge.closest("tr"),wasActive=qtyBadge.classList.contains("active");document.querySelectorAll("#cart .toggle-quantity.show").forEach(function(menu){menu.classList.remove("show")}),document.querySelectorAll("#cart .qty-badge.active").forEach(function(badge){badge.classList.remove("active")}),document.querySelectorAll("#cart tr.qty-menu-open").forEach(function(row){row.classList.remove("qty-menu-open")}),wasActive||(qtyBadge.querySelectorAll("span").forEach(function(span){span.classList.add("show")}),qtyBadge.classList.add("active"),qtyRow==null||qtyRow.classList.add("qty-menu-open"));return}var qtyPlus=target.closest(".qtyplus");if(qtyPlus){event.preventDefault();var plusInput=document.getElementById(qtyPlus.getAttribute("field"));plusInput&&adjustQtyInput(plusInput,1);return}var qtyMinus=target.closest(".qtyminus");if(qtyMinus){event.preventDefault();
1var minusInput=document.getElementById(qtyMinus.getAttribute("field"));minusInput&&adjustQtyInput(minusInput,-1)}}}),document.addEventListener("input",function(event){event.target instanceof HTMLInputElement&&event.target.matches('#cart input[id^="updates"]')&&scheduleCartFormSubmit()}),document.addEventListener("change",function(event){var _a,_b,_c;var select=(_b=(_a=event.target).closest)==null?void 0:_b.call(_a,".line-variant-switcher .switcher-select");if(!(!select||isUpdating)){var wrap=select.closest(".line-variant-switcher"),variantId=select.value;!variantId||(_c=select.options[select.selectedIndex])!=null&&_c.disabled||(select.disabled=!0,swapVariant(wrap,variantId))}}),document.addEventListener("submit",function(event){var _a;if(((_a=event.target)==null?void 0:_a.id)==="cartform"){var submitter=event.submitter||document.activeElement;if(!isCheckoutSubmitter(submitter)){if(isUpdating){event.preventDefault();return}event.preventDefault(),runCartUpdate(function(){return submitCartForm(event.target)}).catch(handleCartUpdateFailure)}}})}return initEventHandlers(),{afterCartChange:afterCartChange,changeByUrl:changeByUrl,changeLineQuantity:changeLineQuantity,isCartUpdating:function(){return isUpdating},optimisticallyRemoveLine:optimisticallyRemoveLine,optimisticallyUpdateQuantity:optimisticallyUpdateQuantity,refreshHeaderCartCount:refreshHeaderCartCount,runCartUpdate:runCartUpdate,setLoadingState:setCartLoadingState,setSubtotalLoadingState:setSubtotalLoadingState,updateLinesToZero:updateLinesToZero}})();
2//# sourceMappingURL=/cdn/shop/t/416/assets/cart-ajax.js.map?v=164093949014870726061788874451

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.