CoreFiles by mySites.guru
joomla-field-media-es5.min.js1 lines, 8,327 bytes, from Joomla_4.0.0-alpha6-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha5
md5
b6b352b24318525ceaa9cb5282fcb487
sha1
5c5750fd2eacff8db26f6d63de771ab5eb215ead
sha256
e5b72b0fd451ac5148e78f8c62c790b99efa8100e5b5e13f7c6beb1343c6b3ee
"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 _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 _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 _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 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 _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 _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){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}),b.doIt=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").rootFull;b.selectedFile.url=a.data[0].url.split(e)[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 f=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&&(f(c)||"object"===_typeof(c)?!f(c)&&"object"===_typeof(c)&&c.id?window.parent.Joomla.editors.instances[c.id].replaceSelection("<img src=\"".concat(b.selectedFile.url,"\" alt=\"\"/>")):(c.value=b.selectedFile.url,d.updatePreview()):b.editors.instances[c].replaceSelection("<img src=\"".concat(b.selectedFile.url,"\" alt=\"\"/>")))}},b.getImage=function(a,c,d){return new Promise(function(e,f){var g="".concat(b.getOptions("system.paths").rootFull,"administrator/index.php?option=com_media&format=json");b.request({url:"".concat(g,"&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 g(a){var f=JSON.parse(a);e(b.doIt(f,c,d))},onError:function a(){f()}})})};var c=function(a){function c(){return _classCallCheck(this,c),_possibleConstructorReturn(this,_getPrototypeOf(c).apply(this,arguments))}return _inherits(c,a),_createClass(c,[{key:"connectedCallback",value:function c(){var a=this.querySelector(this.buttonSelect),b=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),a.addEventListener("click",this.show),b&&b.addEventListener("click",this.clearValue),this.updatePreview()}},{key:"disconnectedCallback",value:function b(){var a=this.querySelector(this.buttonClear);a.removeEventListener("click",this)}},{key:"show",value:function c(){var a=this,b=this;this.querySelector("[role=\"dialog\"]").open(),this.querySelector(this.buttonSaveSelected).addEventListener("click",function(c){return c.preventDefault(),c.stopPropagation(),a.selectedPath&&b.setValue(a.selectedPath),b.modalClose(),!1})}},{key:"modalClose",value:function c(){var a=this.querySelector(this.input);b.getImage(b.selectedFile,a,this),b.Modal.getCurrent().close()}},{key:"setValue",value:function b(a){this.querySelector(this.input).value=a,this.updatePreview()}},{key:"clearValue",value:function a(){this.setValue("")}},{key:"updatePreview",value:function e(){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 fa fa-picture-o\"></span>";else{d.innerHTML="";var f=new Image;switch(this.type){case"image":f.src=f.src=/http/.test(c)?c:b.getOptions("system.paths").rootFull+c;break;default:}d.style.width=this.previewWidth,d.appendChild(f)}}}},{key:"type",get:function a(){return this.getAttribute("type")},set:function b(a){this.setAttribute("type",a)}},{key:"basePath",get:function a(){return this.getAttribute("base-path")},set:function b(a){this.setAttribute("base-path",a)}},{key:"rootFolder",get:function a(){return this.getAttribute("root-folder")},set:function b(a){this.setAttribute("root-folder",a)}},{key:"url",get:function a(){return this.getAttribute("url")},set:function b(a){this.setAttribute("url",a)}},{key:"modalContainer",get:function a(){return this.getAttribute("modal-container")},set:function b(a){this.setAttribute("modal-container",a)}},{key:"input",get:function a(){return this.getAttribute("input")},set:function b(a){this.setAttribute("input",a)}},{key:"buttonSelect",get:function a(){return this.getAttribute("button-select")},set:function b(a){this.setAttribute("button-select",a)}},{key:"buttonClear",get:function a(){return this.getAttribute("button-clear")},set:function b(a){this.setAttribute("button-clear",a)}},{key:"buttonSaveSelected",get:function a(){return this.getAttribute("button-save-selected")},set:function b(a){this.setAttribute("button-save-selected",a)}},{key:"modalWidth",get:function a(){return this.getAttribute(parseInt("modal-width",10))},set:function b(a){this.setAttribute("modal-width",a)}},{key:"modalHeight",get:function a(){return this.getAttribute(parseInt("modal-height",10))},set:function b(a){this.setAttribute("modal-height",a)}},{key:"previewWidth",get:function a(){return this.getAttribute(parseInt("preview-width",10))},set:function b(a){this.setAttribute("preview-width",a)}},{key:"previewHeight",get:function a(){return this.getAttribute(parseInt("preview-height",10))},set:function b(a){this.setAttribute("preview-height",a)}},{key:"preview",get:function a(){return this.getAttribute("preview")},set:function b(a){this.setAttribute("preview",a)}},{key:"previewContainer",get:function a(){return this.getAttribute("preview-container")}}],[{key:"observedAttributes",get:function a(){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.