CoreFiles by mySites.guru
joomla-field-media-es5.min.js1 lines, 9,359 bytes, from Joomla_4.0.0-beta3-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta2
md5
e525ed829b71716f53fc33e1a6df86d0
sha1
5dd1d026f8569712c0992ee99f9426212e622fd9
sha256
08f5e3368782f887ca1498bf04f7b829330e78df2700b44ce96ccf48c8eb9f3c
"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");b.selectedFile={},window.document.addEventListener("onMediaFileSelected",function(a){b.selectedFile=a.detail});var c=function(a,c,d){if(!0===a.success){if(!a.data[0].url)b.selectedFile.url=!1;else if(/local-/.test(a.data[0].adapter)){var e=b.getOptions("system.paths"),f=e.rootFull;b.selectedFile.url=a.data[0].url.split(f)[1],b.selectedFile.thumb=!!a.data[0].thumb_path&&a.data[0].thumb_path}else a.data[0].thumb_path&&(b.selectedFile.thumb=a.data[0].thumb_path);var g=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};b.selectedFile.url&&(g(c)||"object"===_typeof(c)?!g(c)&&"object"===_typeof(c)&&c.id?window.parent.Joomla.editors.instances[c.id].replaceSelection("<img loading=\"lazy\" src=\"".concat(b.selectedFile.url,"\" alt=\"\"/>")):(c.value=b.selectedFile.url,d.updatePreview()):b.editors.instances[c].replaceSelection("<img loading=\"lazy\" src=\"".concat(b.selectedFile.url,"\" alt=\"\"/>")))}};b.getImage=function(a,d,e){return new Promise(function(f,g){if(!a||"object"===_typeof(a)&&(!a.path||""===a.path))return b.selectedFile={},void f({resp:{success:!1}});var h="".concat(b.getOptions("system.paths").rootFull,"administrator/index.php?option=com_media&format=json");b.request({url:"".concat(h,"&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);f(c(b,d,e))},onError:function onError(a){g(a)}})})};var d=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}_inherits(c,a);var d=_createSuper(c);return _createClass(c,[{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(),b.selectedFile={},this.querySelector(this.buttonSaveSelected).addEventListener("click",this.onSelected)}},{key:"modalClose",value:function modalClose(){var a=this.querySelector(this.input);b.getImage(b.selectedFile,a,this).then(function(){b.Modal.getCurrent().close(),b.selectedFile={}}).catch(function(){b.Modal.getCurrent().close(),b.selectedFile={},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"]}}]),c}(_wrapNativeSuper(HTMLElement));a.define("joomla-field-media",d)})(customElements,Joomla);

No other release has this exact content. See every version of this file.