caisse-bliss/public/bundles/easyadmin/form.fc39362b.js

1 line
6.6 KiB
JavaScript

(()=>{var e={6035:function(e){var t;t=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t){function n(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.form=t,this.isDirty=!1,this.initialValues={},this.fields=[].concat(n(this.form.elements),n(this.form.querySelectorAll("trix-editor"))),this.message=r.message||"You have unsaved changes!",this.setupFields(),this.setFormHandlers()}var t,i,o;return t=e,(i=[{key:"setupFields",value:function(){var e=this;this.fields.forEach((function(t){t.name&&"submit"!=t.type&&"button"!=t.type&&"hidden"!=t.type&&(e.initialValues[t.name]=t.value,"TRIX-EDITOR"==t.nodeName?t.addEventListener("trix-change",e.checkValue.bind(e)):(t.addEventListener("change",e.checkValue.bind(e)),t.addEventListener("input",e.checkValue.bind(e))))}))}},{key:"setFormHandlers",value:function(){var e=this;window.addEventListener("submit",this.handleSubmit.bind(this)),this.form.addEventListener("submit",this.handleSubmit.bind(this)),window.onbeforeunload=function(){if(e.isDirty)return e.message},"undefined"!=typeof Turbolinks&&document.addEventListener("turbolinks:before-visit",(function(t){e.isDirty&&!confirm(e.message)?t.preventDefault():e.isDirty=!1}))}},{key:"checkValue",value:function(e){var t=e.target;this.initialValues[t.name]!=t.value&&(this.isDirty=!0)}},{key:"handleSubmit",value:function(){this.isDirty=!1}}])&&r(t.prototype,i),o&&r(t,o),e}();e.exports=i}])},e.exports=t()}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(6035),t=n.n(e);function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(o=i.key,a=void 0,a=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===r(a)?a:String(a)),i)}var o,a}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t){!function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(e,t),t.add(e)}function u(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}document.addEventListener("DOMContentLoaded",(function(){new f}));var c=new WeakSet,l=new WeakSet,s=new WeakSet,f=o((function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),a(this,s),a(this,l),a(this,c),u(this,c,d).call(this),u(this,l,m).call(this),u(this,s,v).call(this)}));function d(){[".ea-new-form",".ea-edit-form"].forEach((function(e){var n=document.querySelector(e);null!==n&&new(t())(n)}))}function m(){[".ea-new-form",".ea-edit-form"].forEach((function(e){var t=document.querySelector(e);null!==t&&function(e,t){document.querySelector(".ea-edit, .ea-new").querySelectorAll('[type="submit"]').forEach((function(t){t.addEventListener("click",(function(t){var n=!1;document.querySelectorAll(".form-tabs .nav-item .badge-danger.badge").forEach((function(e){e.parentElement.removeChild(e)})),null===e.getAttribute("novalidate")&&(e.querySelectorAll("input,select,textarea").forEach((function(e){if(!e.disabled&&!e.validity.valid){n=!0;var t=e.closest("div.tab-pane");if(t){var r=document.querySelector('[data-bs-target="#'.concat(t.id,'"], a[href="#').concat(t.id,'"]'));if(r){var i=r.querySelector(".badge");if(i)i.textContent=(parseInt(i.textContent)+1).toString();else{var o=document.createElement("span");o.classList.add("badge","badge-danger"),o.title="form.tab.error_badge_title",o.textContent="1",r.appendChild(o)}r.addEventListener("click",(function e(){r.querySelectorAll(".badge-danger.badge").forEach((function(e){e.parentElement.removeChild(e)})),r.removeEventListener("click",e)}))}}var a=e.closest("div.form-group");a.classList.add("has-error"),a.addEventListener("click",(function e(){a.classList.remove("has-error"),a.removeEventListener("click",e)}))}})),n&&(t.preventDefault(),t.stopPropagation()))}))})),e.addEventListener("submit",(function(n){var r=new CustomEvent("ea.form.submit",{cancelable:!0,detail:{page:t,form:e}});!1===document.dispatchEvent(r)&&(n.preventDefault(),n.stopPropagation())}))}(t,e.includes("-new-")?"new":"edit")}))}function v(){[".ea-new-form",".ea-edit-form"].forEach((function(e){var t=document.querySelector(e);null!==t&&t.addEventListener("submit",(function(){setTimeout((function(){document.querySelector(".ea-edit, .ea-new").querySelectorAll('[type="submit"]').forEach((function(e){e.setAttribute("disabled","disabled")}))}),1)}),!1)}))}})()})();