PageSourceSearch

https://www.pier14.de/shop/theme/142924cc12aece7b80337ef85866e75d/…/storefront.add-to-cart.plugin.923ff3.js

js pier14.de collected 2026-09-28 12:34:02 UTC 3,864 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[72701],{1088(t,e,r){r.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],r=s.serialize(t,e);if(!(r instanceof FormData)&&0===Object.keys(r).length||r instanceof FormData&&0===Array.from(r.entries()).length)return{};let o={};for(let[t,e]of r.entries())o[t]=e;return o}}},2701(t,e,r){r.r(e),r.d(e,{default:()=>i});var s=r(4335),o=r(1088);class i extends s.A{static #t=this.options={redirectSelector:'[name="redirectTo"]',redirectParamSelector:'[data-redirect-parameters="true"]',redirectTo:"frontend.cart.offcanvas",alertTemplateSelector:".js-add-to-cart-alert-template",alertDismissDelay:3e3,stockAlertTemplateSelector:".js-quantity-stock-adjusted-template",stockAlertClass:"quantity-stock-adjusted-alert",stockAdjustedText:null,outOfStockText:null,buyButtonSelector:'button[type="submit"].btn-buy'};init(){if(this._getForm(),!this._form)throw Error(`No form found for the plugin: ${this.constructor.name}`);this._prepareFormRedirect(),this._registerEvents()}_prepareFormRedirect(){try{let t=this._form.querySelector(this.options.redirectSelector),e=this._form.querySelector(this.options.redirectParamSelector);t.value=this.options.redirectTo,e.disabled=!0}catch(t){}}_getForm(){this.el&&"FORM"===this.el.nodeName?this._form=this.el:this._form=this.el.closest("form")}_registerEvents(){this.el.addEventListener("submit",this._formSubmit.bind(this)),this._form.addEventListener("QuantitySelector/StockAdjusted",this._handleStockAdjusted.bind(this)),this._form.addEventListener("QuantitySelector/OutOfStock",this._handleOutOfStock.bind(this))}_formSubmit(t){t.preventDefault();let e=this._form.getAttribute("action"),r=o.A.serialize(this._form);this.$emitter.publish("beforeFormSubmit",r),this._shouldOpenOffcanvas()?this._openOffCanvasCarts(e,r):this._addToCartWithoutOffcanvas(e,r)}_shouldOpenOffcanvas(){return"0"!==window.openOffcanvasAfterAddToCart}_addToCartWithoutOffcanvas(t,e){fetch(t,{method:"POST",body:e}).then(t=>{if(!t.ok)throw Error("Add to cart failed");window.PluginManager.getPluginInstances("CartWidget")?.forEach(t=>{t.fetch()}),this._showSuccessAlert(),this.$emitter.publish("addToCartWithoutOffcanvas")}).catch(()=>{this._openOffCanvasCarts(t,e)})}_showSuccessAlert(){let t=document.querySelector(this.options.alertTemplateSelector);if(!t||!this._form)return;let e=this._form.parentElement.querySelector(".add-to-cart-alert");e&&e.remove();let r=t.content.firstElementChild.cloneNode(!0);r.classList.add("show","add-to-cart-alert"),this._form.insertAdjacentElement("afterend",r),setTimeout(()=>{r.addEventListener("transitionend",()=>r.remove(),{once:!0}),r.classList.remove("show")},this.options.alertDismissDelay)}_openOffCanvasCarts(t,e){window.PluginManager.getPluginInstances("OffCanvasCart").forEach(r=>{this._openOffCanvasCart(r,t,e)})}_openOffCanvasCart(t,e,r){t.openOffCanvas(e,r,()=>{this.$emitter.publish("openOffCanvasCart")})}_handleStockAdjusted(t){let e=this.options.stockAdjustedText||"";e=e.replace("%quantity%",t.detail.quantity),this._showStockAlert(e)}_handleOutOfStock(){this._showStockAlert(this.options.outOfStockText||"");let t=this._form.querySelector(this.options.buyButtonSelector);t&&(t.disabled=!0)}_showStockAlert(t){let e=this._form.querySelector(this.options.stockAlertTemplateSelector);if(!e)return;let r=e.parentElement.querySelector(`.${this.options.stockAlertClass}`);r&&r.remove();let s=e.content.firstElementChild.cloneNode(!0);s.classList.add(this.options.stockAlertClass);let o=s.querySelector(".alert-content-container");o&&(o.textContent=t),e.insertAdjacentElement("afterend",s)}}}}]);

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.