PageSourceSearch

https://well.dk/theme/7757fe77c415bf0326d51c6fd6babba4/js/cms/cms.add-multiple-to-cart-item.plugin.509d7a.js

js well.dk collected 2026-10-10 01:09:38 UTC 7,770 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[35886,24726],{886:(t,e,r)=>{r.r(e),r.d(e,{ADD_MULTIPLE_TO_CART_ITEM_PLUGIN_SELECTOR:()=>s,default:()=>a});var i=r(709),n=r(726);let{PluginBaseClass:o}=window,s="[data-add-multiple-to-cart-item]";class a extends o{init(){if(!this._getHandlerPlugin())throw Error("Handler plugin missing");this.id=Math.floor(9999999*Math.random()),this.options.price||(this.options.price=0),this.options.discountPrice||(this.options.discountPrice=this.options.price),this._getSelectInput(),this._handlerPlugin.registerItem(this),this._registerEvents()}isSelected(){return!1===this._selectInput||this._selectInput.checked}getPrice(){return parseFloat(this.options.price)}getDiscountPrice(){return parseFloat(this.options.discountPrice)}getId(){return this.id}_registerEvents(){this.el.addEventListener("change",this._onChange.bind(this))}_onChange(t){let e=t.target;this._selectInput&&e.isEqualNode(this._selectInput)&&this._publishHandlerEvent(n.ADD_MULTIPLE_TO_CART_PLUGIN_EVENT_SELECTION_CHANGE)}_getSelectInput(){this._selectInput=i.Z.querySelector(this.el,this.options.selectInputSelector)}_getHandlerPlugin(){let t=this.el.closest(n.ADD_MULTIPLE_TO_CART_PLUGIN_SELECTOR);return this._handlerPlugin=PluginManager.getPluginInstanceFromElement(t,"AddMultipleToCart"),this._handlerPlugin}_publishHandlerEvent(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._handlerPlugin.$emitter.publish(t,{item:this})}}a.options={selectInputSelector:"",price:0,discountPrice:0}},726:(t,e,r)=>{r.r(e),r.d(e,{ADD_MULTIPLE_TO_CART_PLUGIN_EVENT_SELECTION_CHANGE:()=>l,ADD_MULTIPLE_TO_CART_PLUGIN_SELECTOR:()=>a,default:()=>c});class i{static debounce(t,e){let r,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function(){for(var n=arguments.length,o=Array(n),s=0;s<n;s++)o[s]=arguments[s];i&&!r&&setTimeout(t.bind(t,...o),0),clearTimeout(r),r=setTimeout(t.bind(t,...o),e)}}}var n=r(709);class o{static iterate(t,e){if(t instanceof Map||Array.isArray(t))return t.forEach(e);if(t instanceof FormData){for(var r of t.entries())e(r[1],r[0]);return}if(t instanceof NodeList)return t.forEach(e);if(t instanceof HTMLCollection)return Array.from(t).forEach(e);if(t instanceof Object)return Object.keys(t).forEach(r=>{e(t[r],r)});throw Error("The element type ".concat(typeof t," is not iterable!"))}}let{PluginBaseClass:s}=window,a="[data-add-multiple-to-cart]",l="onMultipleCartSelection";class c extends s{init(){this._registry=[],this._registerEvents(),this._initializeForm(),this._allItemsRegisteredDebouncer=i.debounce(this._onAllItemsRegistered.bind(this),100)}registerItem(t){this._registry.push(t),this._allItemsRegisteredDebouncer()}_registerEvents(){this.$emitter.subscribe(l,this._onSelectionChange.bind(this))}_initializeForm(){try{let t=n.Z.querySelector(this.el,"button[type=submit]");t.disabled=!0;let e=document.createElement("input");e.type="hidden",e.name="redirectTo",e.value="frontend.cart.offcanvas";let r=document.createElement("form");r.action=window.router["frontend.checkout.line-item.add"],r.method="post",t.insertAdjacentElement("afterend",r),r.appendChild(t),r.appendChild(e),PluginManager.initializePlugin("AddToCart",r,{}),this._form=r,this._addToCartBtn=t}catch(t){throw console.log(t),Error("Form could not be created")}}_onSelectionChange(t){this._refreshContent()}_refreshContent(){let t=0,e=0;this._registry.forEach(r=>{this._refreshItemInForm(r),r.isSelected()&&(t+=r.getPrice(),e+=r.getDiscountPrice())});try{let r=n.Z.querySelector(this.el,"[data-price]"),i=n.Z.querySelector(this.el,"[data-discount-price]"),o=PluginManager.getPluginInstanceFromElement(r,"SnippetTranslator"),s=t.toFixed(2).toString().split(".");r.innerHTML=o.getTranslation("price",{"%price%":s[0],"%decimals%":s[1]||""});let a=PluginManager.getPluginInstanceFromElement(i,"SnippetTranslator"),l=e.toFixed(2).toString().split(".");i.innerHTML=a.getTranslation("price",{"%price%":l[0],"%decimals%":l[1]||""})}catch(t){console.log(t)}this._addToCartBtn.disabled=0>=this._getSelectedItemsCount()}_refreshItemInForm(t){let e=t.el,r=n.Z.querySelector(e,"[data-add-to-cart]",!1);if(r&&($(this._form).find("#".concat(t.getId())).remove(),t.isSelected()))try{let e=n.Z.querySelectorAll(r,'input[type=hidden][name^="lineItems["]'),i=document.createElement("span");i.id=t.getId().toString(),o.iterate(e,t=>{let e=t.cloneNode(!0);i.appendChild(e)}),this._form.appendChild(i)}catch(t){console.log(t)}}_onAllItemsRegistered(){this._allItemsRegisteredDebouncer=()=>{},this._refreshContent()}_getSelectedItemsCount(){let t=0;
1return this._registry.forEach(e=>{e.isSelected()&&t++}),t}}c.options={}},709:(t,e,r)=>{r.d(e,{Z:()=>n});class i{static ucFirst(t){return t.charAt(0).toUpperCase()+t.slice(1)}static lcFirst(t){return t.charAt(0).toLowerCase()+t.slice(1)}static toDashCase(t){return t.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(t,e){let r=i.toUpperCamelCase(t,e);return i.lcFirst(r)}static toUpperCamelCase(t,e){return e?t.split(e).map(t=>i.ucFirst(t.toLowerCase())).join(""):i.ucFirst(t.toLowerCase())}static parsePrimitive(t){try{return/^\d+(.|,)\d+$/.test(t)&&(t=t.replace(",",".")),JSON.parse(t)}catch(e){return t.toString()}}}class n{static isNode(t){return"object"==typeof t&&null!==t&&(t===document||t===window||t instanceof Node)}static hasAttribute(t,e){if(!n.isNode(t))throw Error("The element must be a valid HTML Node!");return"function"==typeof t.hasAttribute&&t.hasAttribute(e)}static getAttribute(t,e){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r&&!1===n.hasAttribute(t,e))throw Error('The required property "'.concat(e,'" does not exist!'));if("function"!=typeof t.getAttribute){if(r)throw Error("This node doesn't support the getAttribute function!");return}return t.getAttribute(e)}static getDataAttribute(t,e){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2],o=e.replace(/^data(|-)/,""),s=i.toLowerCamelCase(o,"-");if(!n.isNode(t)){if(r)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===t.dataset){if(r)throw Error("This node doesn't support the dataset attribute!");return}let a=t.dataset[s];if(void 0===a){if(r)throw Error('The required data attribute "'.concat(e,'" does not exist on ').concat(t,"!"));return a}return i.parsePrimitive(a)}static querySelector(t,e){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r&&!n.isNode(t))throw Error("The parent node is not a valid HTML Node!");let i=t.querySelector(e)||!1;if(r&&!1===i)throw Error('The required element "'.concat(e,'" does not exist in parent node!'));return i}static querySelectorAll(t,e){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r&&!n.isNode(t))throw Error("The parent node is not a valid HTML Node!");let i=t.querySelectorAll(e);if(0===i.length&&(i=!1),r&&!1===i)throw Error('At least one item of "'.concat(e,'" must exist in parent node!'));return i}static getFocusableElements(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return t.querySelectorAll('\n            input:not([tabindex^="-"]):not([disabled]):not([type="hidden"]),\n            select:not([tabindex^="-"]):not([disabled]),\n            textarea:not([tabindex^="-"]):not([disabled]),\n            button:not([tabindex^="-"]):not([disabled]),\n            a[href]:not([tabindex^="-"]):not([disabled]),\n            [tabindex]:not([tabindex^="-"]):not([disabled])\n        ')}static getFirstFocusableElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return this.getFocusableElements(t)[0]}static getLastFocusableElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=this.getFocusableElements(t);return e[e.length-1]}}}}]);

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.