- md5
- 32cac496352a8cfe71e62a0ac268d408
- sha1
- 1b36d1ea395cb35b01df9680b5900a9b8209a7de
- sha256
- 6bcad61bb061c2a8dc020d3eb804d0407fff76ec7d3a8b6e78c28a2286293430
"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 asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}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(a,b){'use strict';if(!b)throw new Error("Joomla API is not properly initiated");var c=function(a){function c(){var a;return _classCallCheck(this,c),a=d.call(this),a.onSelected=a.onSelected.bind(_assertThisInitialized(a)),a.show=a.show.bind(_assertThisInitialized(a)),a.clearValue=a.clearValue.bind(_assertThisInitialized(a)),a.modalClose=a.modalClose.bind(_assertThisInitialized(a)),a.setValue=a.setValue.bind(_assertThisInitialized(a)),a.updatePreview=a.updatePreview.bind(_assertThisInitialized(a)),a}_inherits(c,a);var d=_createSuper(c);return _createClass(c,[{key:"connectedCallback",value:function connectedCallback(){if(this.button=this.querySelector(this.buttonSelect),this.inputElement=this.querySelector(this.input),this.buttonClearEl=this.querySelector(this.buttonClear),this.modalElement=this.querySelector(".joomla-modal"),this.buttonSaveSelectedElement=this.querySelector(this.buttonSaveSelected),this.previewElement=this.querySelector(".field-media-preview"),!this.button||!this.inputElement||!this.buttonClearEl||!this.modalElement||!this.buttonSaveSelectedElement)throw new Error("Misconfiguaration...");this.button.addEventListener("click",this.show),this.modalElement&&window.bootstrap&&window.bootstrap.Modal&&void 0===window.bootstrap.Modal.getInstance(this.modalElement)&&b.initialiseModal(this.modalElement,{isJoomla:!0}),this.buttonClearEl&&this.buttonClearEl.addEventListener("click",this.clearValue),this.updatePreview()}},{key:"disconnectedCallback",value:function disconnectedCallback(){this.button&&this.button.removeEventListener("click",this.show),this.buttonClearEl&&this.buttonClearEl.removeEventListener("click",this.clearValue)}},{key:"onSelected",value:function onSelected(a){return a.preventDefault(),a.stopPropagation(),this.modalClose(),!1}},{key:"show",value:function show(){this.modalElement.open(),b.selectedMediaFile={},this.buttonSaveSelectedElement.addEventListener("click",this.onSelected)}},{key:"modalClose",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function a(){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,b.getImage(b.selectedMediaFile,this.inputElement,this);case 3:a.next=8;break;case 5:a.prev=5,a.t0=a["catch"](0),b.renderMessages({error:[b.Text._("JLIB_APPLICATION_ERROR_SERVER")]});case 8:b.selectedMediaFile={},b.Modal.getCurrent().close();case 10:case"end":return a.stop();}},a,this,[[0,5]])}));return function modalClose(){return a.apply(this,arguments)}}()},{key:"setValue",value:function setValue(a){this.inputElement.value=a,this.updatePreview()}},{key:"clearValue",value:function clearValue(){this.setValue("")}},{key:"updatePreview",value:function updatePreview(){if(-1!==["true","static"].indexOf(this.preview)&&"false"!==this.preview&&this.previewElement&&this.preview){var a=this.inputElement.value;if(!a)this.previewElement.innerHTML="<span class=\"field-media-preview-icon\"></span>";else{this.previewElement.innerHTML="";var c=new Image,d={image:function image(){c.src=/http/.test(a)?a:b.getOptions("system.paths").rootFull+a,c.setAttribute("alt","")}};d[this.type](),this.previewElement.style.width=this.previewWidth,this.previewElement.appendChild(c)}}}},{key:"type",get:function get(){return this.getAttribute("type")},set:function set(a){this.setAttribute("type",a)}},{key:"basePath",get:function get(){return this.getAttribute("base-path")},set:function set(a){this.setAttribute("base-path",a)}},{key:"rootFolder",get:function get(){return this.getAttribute("root-folder")},set:function set(a){this.setAttribute("root-folder",a)}},{key:"url",get:function get(){return this.getAttribute("url")},set:function set(a){this.setAttribute("url",a)}},{key:"modalContainer",get:function get(){return this.getAttribute("modal-container")},set:function set(a){this.setAttribute("modal-container",a)}},{key:"input",get:function get(){return this.getAttribute("input")},set:function set(a){this.setAttribute("input",a)}},{key:"buttonSelect",get:function get(){return this.getAttribute("button-select")},set:function set(a){this.setAttribute("button-select",a)}},{key:"buttonClear",get:function get(){return this.getAttribute("button-clear")},set:function set(a){this.setAttribute("button-clear",a)}},{key:"buttonSaveSelected",get:function get(){return this.getAttribute("button-save-selected")},set:function set(a){this.setAttribute("button-save-selected",a)}},{key:"modalWidth",get:function get(){return this.getAttribute(parseInt("modal-width",10))},set:function set(a){this.setAttribute("modal-width",a)}},{key:"modalHeight",get:function get(){return this.getAttribute(parseInt("modal-height",10))},set:function set(a){this.setAttribute("modal-height",a)}},{key:"previewWidth",get:function get(){return this.getAttribute(parseInt("preview-width",10))},set:function set(a){this.setAttribute("preview-width",a)}},{key:"previewHeight",get:function get(){return this.getAttribute(parseInt("preview-height",10))},set:function set(a){this.setAttribute("preview-height",a)}},{key:"preview",get:function get(){return this.getAttribute("preview")},set:function set(a){this.setAttribute("preview",a)}},{key:"previewContainer",get:function get(){return this.getAttribute("preview-container")}}],[{key:"observedAttributes",get:function get(){return["type","base-path","root-folder","url","modal-container","modal-width","modal-height","input","button-select","button-clear","button-save-selected","preview","preview-width","preview-height"]}}]),c}(_wrapNativeSuper(HTMLElement));a.define("joomla-field-media",c)})(customElements,Joomla);
No other release has this exact content. See every version of this file.