- md5
- f9ce301f22e129058a6563e33d4ddbca
- sha1
- f441b230b59a6256b8c1a5cd4219df84ca55769c
- sha256
- 6d99e43f5335a3985161764ffc99e86acbbccd053770e330fadc445f68b0589f
"use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),b&&_setPrototypeOf(a,b)}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _possibleConstructorReturn(a,b){return b&&("object"===_typeof(b)||"function"==typeof b)?b:_assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _wrapNativeSuper(a){var b="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(a){function c(){return _construct(a,arguments,_getPrototypeOf(this).constructor)}if(null===a||!_isNativeFunction(a))return a;if("function"!=typeof a)throw new TypeError("Super expression must either be null or a function");if("undefined"!=typeof b){if(b.has(a))return b.get(a);b.set(a,c)}return c.prototype=Object.create(a.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(c,a)},_wrapNativeSuper(a)}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct:function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}function _isNativeFunction(a){return-1!==Function.toString.call(a).indexOf("[native code]")}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}(function(){var a=function(a){function b(){var a;return _classCallCheck(this,b),a=c.call(this),a.onUserSelect="",a.onchangeStr="",a.buttonClick=a.buttonClick.bind(_assertThisInitialized(a)),a.iframeLoad=a.iframeLoad.bind(_assertThisInitialized(a)),a}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"connectedCallback",value:function connectedCallback(){this.modal=this.querySelector(this.modalClass),this.modalBody=this.querySelector(".modal-body"),this.input=this.querySelector(this.inputId),this.inputName=this.querySelector(this.inputNameClass),this.buttonSelect=this.querySelector(this.buttonSelectClass),this.modalClose=this.modalClose.bind(this),this.setValue=this.setValue.bind(this),this.buttonSelect&&(this.buttonSelect.addEventListener("click",this.modalOpen.bind(this)),this.modal.addEventListener("hide",this.removeIframe.bind(this)),this.onchangeStr=this.input.getAttribute("data-onchange"),this.onchangeStr&&(this.onUserSelect=new Function(this.onchangeStr),this.input.addEventListener("change",this.onUserSelect)))}},{key:"disconnectedCallback",value:function disconnectedCallback(){this.onchangeStr&&this.input&&this.input.removeEventListener("change",this.onUserSelect),this.buttonSelect&&this.buttonSelect.removeEventListener("click",this),this.modal&&this.modal.removeEventListener("hide",this)}},{key:"buttonClick",value:function buttonClick(a){var b=a.target;this.setValue(b.getAttribute("data-user-value"),b.getAttribute("data-user-name")),this.modalClose()}},{key:"iframeLoad",value:function iframeLoad(){var a=this,b=this.iframeEl.contentWindow.document,c=[].slice.call(b.querySelectorAll(".button-select"));c.forEach(function(b){b.addEventListener("click",a.buttonClick)})}},{key:"modalOpen",value:function modalOpen(){this.removeIframe();var a=document.createElement("iframe");a.setAttribute("name","field-user-modal"),a.src=this.url.replace("{field-user-id}",this.input.getAttribute("id")),a.setAttribute("width",this.modalWidth),a.setAttribute("height",this.modalHeight),this.modalBody.appendChild(a),this.modal.open(),this.iframeEl=this.modalBody.querySelector("iframe"),this.iframeEl.addEventListener("load",this.iframeLoad)}},{key:"modalClose",value:function modalClose(){Joomla.Modal.getCurrent().close(),this.modalBody.innerHTML=""}},{key:"removeIframe",value:function removeIframe(){this.modalBody.innerHTML=""}},{key:"setValue",value:function setValue(a,b){this.input.setAttribute("value",a),this.inputName.setAttribute("value",b||a),this.input.dispatchEvent(new Event("change"))}},{key:"url",get:function get(){return this.getAttribute("url")},set:function set(a){this.setAttribute("url",a)}},{key:"modalClass",get:function get(){return this.getAttribute("modal")},set:function set(a){this.setAttribute("modal",a)}},{key:"modalWidth",get:function get(){return this.getAttribute("modal-width")},set:function set(a){this.setAttribute("modal-width",a)}},{key:"modalHeight",get:function get(){return this.getAttribute("modal-height")},set:function set(a){this.setAttribute("modal-height",a)}},{key:"inputId",get:function get(){return this.getAttribute("input")},set:function set(a){this.setAttribute("input",a)}},{key:"inputNameClass",get:function get(){return this.getAttribute("input-name")},set:function set(a){this.setAttribute("input-name",a)}},{key:"buttonSelectClass",get:function get(){return this.getAttribute("button-select")},set:function set(a){this.setAttribute("button-select",a)}}],[{key:"observedAttributes",get:function get(){return["url","modal-class","modal-width","modal-height","input","input-name","button-select"]}}]),b}(_wrapNativeSuper(HTMLElement));customElements.define("joomla-field-user",a)})();
The same content is in 3 releases, Joomla 4.0.0-beta2 to 4.0.0-beta4. See them all, or every version of this file.