- md5
- 897cc31f5b1192bdb336eb8bfc4e748e
- sha1
- 5f607b26205b084cf7ba61428afc9e1bd615336b
- sha256
- 2a34f0ce5c7d68e10fe5c24f0cbe179b2a26f1146cdfa13c180303fd047b9622
"use strict";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 _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(a,b){if(!b)throw new Error("Joomla API is not properly initiated");var c={};window.document.addEventListener("onMediaFileSelected",function(a){c=a.detail});var d=function(a,d,e){if(!0===a.success){if(!a.data[0].url)c.url=!1;else if(/local-/.test(a.data[0].adapter)){var f=b.getOptions("system.paths"),g=f.rootFull;c.url=a.data[0].url.split(g)[1],c.thumb=!!a.data[0].thumb_path&&a.data[0].thumb_path}else a.data[0].thumb_path&&(c.thumb=a.data[0].thumb_path);var h=function(a){return"object"===("undefined"==typeof HTMLElement?"undefined":_typeof(HTMLElement))?a instanceof HTMLElement:a&&"object"===_typeof(a)&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName};c.url&&(h(d)||"object"===_typeof(d)?!h(d)&&"object"===_typeof(d)&&d.id?window.parent.Joomla.editors.instances[d.id].replaceSelection("<img loading=\"lazy\" src=\"".concat(c.url,"\" alt=\"\"/>")):(d.value=c.url,e.updatePreview()):b.editors.instances[d].replaceSelection("<img loading=\"lazy\" src=\"".concat(c.url,"\" alt=\"\"/>")))}},e=function(a,e,f){return new Promise(function(g,h){if(!a||"object"===_typeof(a)&&(!a.path||""===a.path))return c={},void h(new Error("Nothing selected"));var i="".concat(b.getOptions("system.paths").rootFull,"administrator/index.php?option=com_media&format=json");b.request({url:"".concat(i,"&task=api.files&url=true&path=").concat(a.path,"&").concat(b.getOptions("csrf.token"),"=1&format=json"),method:"GET",perform:!0,headers:{"Content-Type":"application/json"},onSuccess:function onSuccess(a){var b=JSON.parse(a);g(d(b,e,f))},onError:function onError(a){h(a)}})})},f=function(a){function d(){var a;return _classCallCheck(this,d),a=f.call(this),a.onSelected=a.onSelected.bind(_assertThisInitialized(a)),a.show=a.show.bind(_assertThisInitialized(a)),a.clearValue=a.clearValue.bind(_assertThisInitialized(a)),a}_inherits(d,a);var f=_createSuper(d);return _createClass(d,[{key:"connectedCallback",value:function connectedCallback(){this.button=this.querySelector(this.buttonSelect),this.buttonClearEl=this.querySelector(this.buttonClear),this.show=this.show.bind(this),this.modalClose=this.modalClose.bind(this),this.clearValue=this.clearValue.bind(this),this.setValue=this.setValue.bind(this),this.updatePreview=this.updatePreview.bind(this),this.button.addEventListener("click",this.show),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.querySelector("[role=\"dialog\"]").open(),this.querySelector(this.buttonSaveSelected).addEventListener("click",this.onSelected)}},{key:"modalClose",value:function modalClose(){var a=this.querySelector(this.input);e(c,a,this).then(function(){b.Modal.getCurrent().close()}).catch(function(){b.Modal.getCurrent().close(),b.renderMessages({error:[b.Text._("JLIB_APPLICATION_ERROR_SERVER")]})})}},{key:"setValue",value:function setValue(a){this.querySelector(this.input).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.preview){var a=this.querySelector(this.input),c=a.value,d=this.querySelector(".field-media-preview");if(!c)d.innerHTML="<span class=\"field-media-preview-icon\"></span>";else{d.innerHTML="";var e=new Image;switch(this.type){case"image":e.src=/http/.test(c)?c:b.getOptions("system.paths").rootFull+c,e.setAttribute("alt","");break;default:}d.style.width=this.previewWidth,d.appendChild(e)}}}},{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"]}}]),d}(_wrapNativeSuper(HTMLElement));a.define("joomla-field-media",f)})(customElements,Joomla);
No other release has this exact content. See every version of this file.