1 line
1.9 KiB
JavaScript
1 line
1.9 KiB
JavaScript
|
(()=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(e,n){for(var i=0;i<n.length;i++){var o=n[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(r=o.key,c=void 0,c=function(e,n){if("object"!==t(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var o=i.call(e,n||"default");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(r,"string"),"symbol"===t(c)?c:String(c)),o)}var r,c}function n(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function i(t,e){!function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}(t,e),e.add(t)}function o(t,e,n){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return n}document.addEventListener("DOMContentLoaded",(function(){document.querySelectorAll('td.field-boolean .form-switch input[type="checkbox"]').forEach((function(t){new a(t)}))}));var r=new WeakSet,c=new WeakSet,a=n((function t(e){"use strict";!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),i(this,c),i(this,r),this.field=e,this.field.addEventListener("change",o(this,r,f).bind(this))}));function f(){var t=this,e=this.field.checked,n=this.field.getAttribute("data-toggle-url")+"&newValue="+e.toString();fetch(n,{method:"PATCH",headers:{"X-Requested-With":"XMLHttpRequest"}}).then((function(e){return e.ok||o(t,c,l).call(t),e.text()})).then((function(){})).catch((function(){return o(t,c,l).call(t)}))}function l(){this.field.checked=!this.field.checked,this.field.disabled=!0,this.field.closest(".form-switch").classList.add("disabled")}})();
|