PageSourceSearch

https://bierbink.nl/theme/3b64559ad0ec43166e8e4cca07924c80/js/easy-withdrawal/easy-withdrawal.js?1790156912

js bierbink.nl collected 2026-09-25 10:11:43 UTC 12,167 bytes, 37 lines download raw bytes

1(()=>{"use strict";var t={156(t){var e=function(t){var e;return!!t&&"object"==typeof t&&"[object RegExp]"!==(e=Object.prototype.toString.call(t))&&"[object Date]"!==e&&t.$$typeof!==r},r="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(t,e){return!1!==e.clone&&e.isMergeableObject(t)?a(Array.isArray(t)?[]:{},t,e):t}function n(t,e,r){return t.concat(e).map(function(t){return i(t,r)})}function o(t){return Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[])}function l(t,e){try{return e in t}catch(t){return!1}}function a(t,r,s){(s=s||{}).arrayMerge=s.arrayMerge||n,s.isMergeableObject=s.isMergeableObject||e,s.cloneUnlessOtherwiseSpecified=i;var c,u,h=Array.isArray(r);return h!==Array.isArray(t)?i(r,s):h?s.arrayMerge(t,r,s):(u={},(c=s).isMergeableObject(t)&&o(t).forEach(function(e){u[e]=i(t[e],c)}),o(r).forEach(function(e){(!l(t,e)||Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))&&(l(t,e)&&c.isMergeableObject(r[e])?u[e]=(function(t,e){if(!e.customMerge)return a;var r=e.customMerge(t);return"function"==typeof r?r:a})(e,c)(t[e],r[e],c):u[e]=i(r[e],c))}),u)}a.all=function(t,e){if(!Array.isArray(t))throw Error("first argument should be an array");return t.reduce(function(t,r){return a(t,r,e)},{})},t.exports=a}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,r),o.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var i=r(156),n=r.n(i);class o{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=o.toUpperCamelCase(t,e);return o.lcFirst(r)}static toUpperCamelCase(t,e){return e?t.split(e).map(t=>o.ucFirst(t.toLowerCase())).join(""):o.ucFirst(t.toLowerCase())}static parsePrimitive(t){try{return/^\d+(.|,)\d+$/.test(t)&&(t=t.replace(",",".")),JSON.parse(t)}catch(e){return t.toString()}}}class l{constructor(t=document){this._el=t,t.$emitter=this,this._listeners=[]}publish(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=new CustomEvent(t,{detail:e,cancelable:r});return this.el.dispatchEvent(i),i}subscribe(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this,n=t.split("."),o=r.scope?e.bind(r.scope):e;if(r.once&&!0===r.once){let e=o;o=function(r){i.unsubscribe(t),e(r)}}return this.el.addEventListener(n[0],o),this.listeners.push({splitEventName:n,opts:r,cb:o}),!0}unsubscribe(t){arguments.length>1&&"function"==typeof arguments[1]&&console.warn(`[NativeEventEmitter] Unsubscribing by passing the subscriber function as a second argument is not supported. By default, all listeners for the event will be removed. Use a suffix (separated by a dot) on the event name when subscribing/unsubscribing to identify/target your specific listener only, e.g. "${t}.MyCustomPlugin"`);let e=t.split(".");return this.listeners=this.listeners.reduce((t,r)=>([...r.splitEventName].sort().toString()===e.sort().toString()?this.el.removeEventListener(r.splitEventName[0],r.cb):t.push(r),t),[]),!0}reset(){return this.listeners.forEach(t=>{this.el.removeEventListener(t.splitEventName[0],t.cb)}),this.listeners=[],!0}get el(){return this._el}set el(t){this._el=t}get listeners(){return this._listeners}set listeners(t){this._listeners=t}}class a{constructor(t,e={},r=!1){if(!(t instanceof Node)){console.warn(`There is no valid element given while trying to create a plugin instance for "${r}".`);return}this.el=t,this.$emitter=new l(this.el),this._pluginName=this._getPluginName(r),this.options=this._mergeOptions(e),this._initialized=!1,this._registerInstance(),this._init()}init(){console.warn(`The "init" method for the plugin "${this._pluginName}" is not defined. The plugin will not be initialized.`)}update(){}destroy(){}
1_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(t){let e=[this.constructor.options,this.options,t];return e.push(this._getConfigFromDataAttribute()),e.push(this._getOptionsFromDataAttribute()),n().all(e.filter(t=>t instanceof Object&&!(t instanceof Array)).map(t=>t||{}))}_getConfigFromDataAttribute(){let t={};if("function"!=typeof this.el.getAttribute)return t;let e=o.toDashCase(this._pluginName),r=this.el.getAttribute(`data-${e}-config`);return r?window.PluginConfigManager.get(this._pluginName,r):t}_getOptionsFromDataAttribute(){let t={};if("function"!=typeof this.el.getAttribute)return t;let e=o.toDashCase(this._pluginName),r=this.el.getAttribute(`data-${e}-options`);if(r)try{return JSON.parse(r)}catch(t){console.error(`The data attribute "data-${e}-options" could not be parsed to json: ${t.message}`)}return t}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(t){return t||(t=this.constructor.name),t}}class s extends a{static #t=this.options={confirmButtonSelector:'.withdrawal-form button[type="submit"]',quantityInputSelector:".withdrawal-quantity",checkboxSelector:".withdrawal-checkbox",lineItemRowSelector:".withdrawal-line-item",selectAllSelector:".withdrawal-select-all"};init(){if(this.form=this.el,this.confirmButton=this.form.querySelector(this.options.confirmButtonSelector),!this.confirmButton)return;this.form.querySelectorAll(this.options.lineItemRowSelector).forEach(t=>{let e=t.querySelector(this.options.checkboxSelector),r=t.querySelector(this.options.quantityInputSelector);e&&(this._syncRow(t),e.addEventListener("change",()=>this._onCheckboxChange(t)),r&&r.addEventListener("input",()=>this._updateSubmitState()))});let t=this.form.querySelector(this.options.selectAllSelector);t&&t.addEventListener("click",this._onSelectAll.bind(this)),this._updateSubmitState(),this.form.addEventListener("submit",this._onSubmit.bind(this))}_onSelectAll(){let t=this._getAllItemsAtFull();0!==t.length&&this._showModal(t,!0,()=>this._applyFullSelection())}_getAllItemsAtFull(){let t=[];return this.form.querySelectorAll(this.options.lineItemRowSelector).forEach(e=>{let r=e.querySelector(this.options.quantityInputSelector);if(!r)return;let i=e.querySelectorAll("td")[1],n=e.querySelectorAll("td")[2],o=i?i.textContent.trim().split("\n")[0].trim():"-",l=parseInt(n?n.textContent.trim():"0",10),a=parseInt(r.max,10)||l;t.push({label:o,orderedQty:l,withdrawQty:a,remainingQty:Math.max(0,l-a)})}),t}_applyFullSelection(){this.form.querySelectorAll(this.options.lineItemRowSelector).forEach(t=>{let e=t.querySelector(this.options.checkboxSelector),r=t.querySelector(this.options.quantityInputSelector);e&&(e.checked=!0),r&&(r.value=r.max||r.value),this._syncRow(t)}),this._updateSubmitState()}_onCheckboxChange(t){let e=t.querySelector(this.options.checkboxSelector),r=t.querySelector(this.options.quantityInputSelector);e&&r&&(e.checked?r.value||(r.value=r.max||""):r.value=""),this._syncRow(t),this._updateSubmitState()}_syncRow(t){let e=t.querySelector(this.options.checkboxSelector),r=t.querySelector(this.options.quantityInputSelector);e&&r&&(r.disabled=!e.checked,t.style.opacity=e.checked?"":"0.5")}_updateSubmitState(){let t=this.form.querySelectorAll(this.options.lineItemRowSelector),e=!1;t.forEach(t=>{let r=t.querySelector(this.options.checkboxSelector),i=t.querySelector(this.options.quantityInputSelector);r&&r.checked&&i&&parseInt(i.value,10)>0&&(e=!0)}),this.confirmButton.disabled=!e}_onSubmit(t){t.preventDefault(),this._openConfirm()}_openConfirm(){let t=this._getWithdrawalItems();if(0===t.length)return;let e=this.form.querySelectorAll(this.options.lineItemRowSelector).length,r=t.length===e&&t.every(t=>t.withdrawQty>=t.orderedQty);this._showModal(t,r)}_getWithdrawalItems(){let t=this.form.querySelectorAll(this.options.lineItemRowSelector),e=[];return t.forEach(t=>{let r=t.querySelector(this.options.checkboxSelector),i=t.querySelector(this.options.quantityInputSelector);if(!r||!i)return;let n=parseInt(i.value,10);if(!r.checked||n<=0)return;let o=t.querySelectorAll("td")[1],l=t.querySelectorAll("td")[2],a=o?o.textContent.trim().split("\n")[0].trim():"-",s=parseInt(l?l.textContent.trim():"0",10);e.push({label:a,orderedQty:s,withdrawQty:n,remainingQty:Math.max(0,s-n)})}),e}_showModal(t,e,r){let i=document.getElementById("withdrawalConfirmModal");i&&i.remove();let n=e?document.querySelector("[data-withdrawal-full-title]")?.value||"Confirm full cancellation":document.querySelector("[data-withdrawal-partial-title]")?.value||"Confirm withdrawal",o=e?document.querySelector("[data-withdrawal-full-body]")?.value||"You are withdrawing all items. This will cancel the entire order.":document.querySelector("[data-withdrawal-partial-body]")?.value||"The following changes will be made to your order:",l="";t.forEach(t=>{let e=0===t.remainingQty?"text-decoration: line-through; color: #999;":"";l+=`
2                <tr>
3                    <td style="${e}">${t.label}</td>
4                    <td class="text-center">${t.orderedQty}</td>
5                    <td class="text-center text-danger">-${t.withdrawQty}</td>
6                    <td class="text-center fw-bold">${t.remainingQty}</td>
7                </tr>
8            `});let a=document.querySelector("[data-withdrawal-cancel-label]")?.value||"Cancel",s=e?document.querySelector("[data-withdrawal-confirm-full-label]")?.value||"Confirm cancellation":document.querySelector("[data-withdrawal-confirm-label]")?.value||"Confirm withdrawal",c=document.querySelector("[data-withdrawal-ordered-label]")?.value||"Ordered",u=document.querySelector("[data-withdrawal-withdraw-label]")?.value||"Withdraw",h=document.querySelector("[data-withdrawal-remaining-label]")?.value||"Remaining",d=document.querySelector("[data-withdrawal-product-label]")?.value||"Product",m=`
9            <div class="modal fade" id="withdrawalConfirmModal" tabindex="-1" aria-hidden="true">
10                <div class="modal-dialog">
11                    <div class="modal-content">
12                        <div class="modal-header">
13                            <div class="modal-title h5">${n}</div>
14                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
15                        </div>
16                        <div class="modal-body">
17                            <p>${o}</p>
18                            <table class="table table-sm">
19                                <thead>
20                                    <tr>
21                                        <th>${d}</th>
22                                        <th class="text-center">${c}</th>
23                                        <th class="text-center">${u}</th>
24                                        <th class="text-center">${h}</th>
25                                    </tr>
26                                </thead>
27                                <tbody>${l}</tbody>
28                            </table>
29                        </div>
30                        <div class="modal-footer">
31                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">${a}</button>
32                            <button type="button" class="btn btn-primary" id="withdrawalConfirmBtn">${s}</button>
33                        </div>
34                    </div>
35                </div>
36            </div>
37        `;document.body.insertAdjacentHTML("beforeend",m);let p=document.getElementById("withdrawalConfirmModal"),b=new bootstrap.Modal(p);document.getElementById("withdrawalConfirmBtn").addEventListener("click",()=>{b.hide(),"function"==typeof r&&r(),this.form.submit()}),p.addEventListener("hidden.bs.modal",()=>{p.remove()}),b.show()}}window.PluginManager.register("WithdrawalConfirm",s,".withdrawal-form")})();

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.