PageSourceSearch

https://cdn.motowatch.com/theme/edf1f57d1dc038a14bdf7a17bff619a9/j…/storefront.offcanvas-cart.plugin.4ce3ce.js

js motowatch.com collected 2026-09-24 12:23:24 UTC 5,678 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[88155],{8155:(t,e,i)=>{i.r(e),i.d(e,{default:()=>u});var s=i(4335),n=i(9068),o=i(8948),r=i(4632),a=i(1088),c=i(6105),h=i(3343),d=i(4059);class u extends s.A{static #t=this.options={removeProductTriggerSelector:".js-offcanvas-cart-remove-product",changeProductQuantityTriggerSelector:".js-offcanvas-cart-change-quantity",changeProductQuantityTriggerNumberSelector:".js-offcanvas-cart-change-quantity-number",changeQuantityInputDelay:800,addPromotionTriggerSelector:".js-offcanvas-cart-add-promotion",cartItemSelector:".js-cart-item",cartPromotionSelector:".js-offcanvas-cart-promotion",offcanvasPosition:"right",shippingContainerSelector:".offcanvas-shipping-preference",shippingToggleSelector:".js-toggle-shipping-selection",additionalOffcanvasClass:"cart-offcanvas",autoFocus:!1,focusHandlerKey:"offcanvas-cart"};init(){this.client=new n.A,this._registerOpenTriggerEvents()}openOffCanvas(t,e,i){o.A.open(t,e,this._onOffCanvasOpened.bind(this,i),this.options.offcanvasPosition,!0),o.A.setAdditionalClassName(this.options.additionalOffcanvasClass)}_registerOpenTriggerEvents(){let t=r.A.isTouchDevice()?"touchstart":"click";this.el.addEventListener(t,this._onOpenOffCanvasCart.bind(this))}_onOpenOffCanvasCart(t){t.preventDefault(),this.openOffCanvas(window.router["frontend.cart.offcanvas"],!1)}_registerRemoveProductTriggerEvents(){let t=document.querySelectorAll(this.options.removeProductTriggerSelector);t&&t.forEach(t=>t.addEventListener("submit",this._onRemoveProductFromCart.bind(this)))}_registerChangeQuantityProductTriggerEvents(){let t=document.querySelectorAll(this.options.changeProductQuantityTriggerSelector),e=document.querySelectorAll(this.options.changeProductQuantityTriggerNumberSelector);t&&t.forEach(t=>t.addEventListener("change",this._onChangeProductQuantity.bind(this))),e&&e.forEach(t=>{t.addEventListener("change",d.A.debounce(this._onChangeProductQuantity.bind(this),this.options.changeQuantityInputDelay))})}_registeraddPromotionTriggerEvents(){let t=document.querySelectorAll(this.options.addPromotionTriggerSelector);t&&t.forEach(t=>t.addEventListener("submit",this._onAddPromotionToCart.bind(this)))}_registerUpdateShippingEvents(){let{shippingContainerSelector:t}=this.options,e=document.querySelector(`${t} select`);e&&e.addEventListener("input",this._onChangeShippingMethod.bind(this))}_registerToggleShippingSelection(){let{shippingToggleSelector:t,shippingContainerSelector:e}=this.options,i=document.querySelector(t);i&&i.addEventListener("click",()=>{let t=document.querySelector(e),i="offcanvas-shipping-preference--hidden";t.classList.contains(i)?t.classList.remove(i):t.classList.add(i)})}_registerEvents(){this._registerRemoveProductTriggerEvents(),this._registerChangeQuantityProductTriggerEvents(),this._registeraddPromotionTriggerEvents(),this._isShippingAvailable()&&(this._registerUpdateShippingEvents(),this._registerToggleShippingSelection()),this.$emitter.publish("registerEvents")}_onOffCanvasOpened(t,e){"function"==typeof t&&t(e),this.$emitter.publish("offCanvasOpened",{response:e}),this._fetchCartWidgets(),this._registerEvents()}_fireRequest(t,e,i){h.A.create(t.closest(e));let s=i?i.bind(this):this._onOffCanvasOpened.bind(this,this._updateOffCanvasContent.bind(this)),n=t.getAttribute("action"),o=a.A.serialize(t);this.$emitter.publish("beforeFireRequest"),fetch(n,{method:"POST",body:o,headers:{"X-Requested-With":"XMLHttpRequest"}}).then(t=>t.text()).then(t=>s(t))}_onRemoveProductFromCart(t){t.preventDefault();let e=t.target,i=this.options.cartItemSelector;this.$emitter.publish("onRemoveProductFromCart"),this._fireRequest(e,i)}_onChangeProductQuantity(t){let e=t.target,i=e.closest("form"),s=this.options.cartItemSelector;this.$emitter.publish("onChangeProductQuantity"),this._saveFocusState(e),this._fireRequest(i,s)}_onAddPromotionToCart(t){t.preventDefault();let e=t.target,i=this.options.cartPromotionSelector;this.$emitter.publish("onAddPromotionToCart"),this._saveFocusState("#addPromotionOffcanvasCart"),this._fireRequest(e,i)}_fetchCartWidgets(){window.PluginManager.getPluginInstances("CartWidget").forEach(t=>t.fetch()),this.$emitter.publish("fetchCartWidgets")}_updateOffCanvasContent(t){c.A.setContent(t,!0,this._registerEvents.bind(this)),window.PluginManager.initializePlugins(),this._resumeFocusState()}_isShippingAvailable(){let{shippingContainerSelector:t}=this.options;return!!document.querySelector(t)}_onChangeShippingMethod(t){t.preventDefault(),this.$emitter.publish("onShippingMethodChange");let e=window.router["frontend.cart.offcanvas"];this._fireRequest(t.target.form,".offcanvas-summary",()=>{fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(t=>t.text()).then(t=>{this._updateOffCanvasContent(t),this._registerEvents()})})}_saveFocusState(t){if(this.options.autoFocus){if("string"==typeof t){window.focusHandler.saveFocusState(this.options.focusHandlerKey,t);return}window.focusHandler.saveFocusState(this.options.focusHandlerKey,`[data-focus-id="${t.dataset.focusId}"]`)}}_resumeFocusState(){this.options.autoFocus&&window.focusHandler.resumeFocusState(this.options.focusHandlerKey)}}},1088:(t,e,i)=>{i.d(e,{A:()=>s});class s{static serialize(t){let e=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("FORM"!==t.nodeName){if(e)throw Error("The passed element is not a form!");return{}}return new FormData(t)}static serializeJson(t){let e=!(arguments.length>1)||void 0===arguments[1]||arguments[1],i=s.serialize(t,e);if(!(i instanceof FormData)&&0===Object.keys(i).length||i instanceof FormData&&0===Array.from(i.entries()).length)return{};let n={};for(let[t,e]of i.entries())n[t]=e;return n}}}}]);

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.