CoreFiles by mySites.guru
joomla-field-media.min.js1 lines, 4,823 bytes, from Joomla_4.0.0-alpha6-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha5
md5
6c3866e98fccc80b49ac2177e16a7271
sha1
0314c0adc9c05212385d2eaa454ba812899dd170
sha256
559b4a89a90a82bf4451e71e8f0c3f127607e8dc2de224d42d276311029ecdf6
"use strict";((a,b)=>{if(!b)throw new Error("Joomla API is not properly initiated");b.selectedFile={},window.document.addEventListener("onMediaFileSelected",a=>{b.selectedFile=a.detail}),b.doIt=(a,c,d)=>{if(!0===a.success){if(!a.data[0].url)b.selectedFile.url=!1;else if(/local-/.test(a.data[0].adapter)){const c=b.getOptions("system.paths").rootFull;b.selectedFile.url=a.data[0].url.split(c)[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);const e=a=>"object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName;b.selectedFile.url&&(e(c)||"object"==typeof c?!e(c)&&"object"==typeof c&&c.id?window.parent.Joomla.editors.instances[c.id].replaceSelection(`<img src="${b.selectedFile.url}" alt=""/>`):(c.value=b.selectedFile.url,d.updatePreview()):b.editors.instances[c].replaceSelection(`<img src="${b.selectedFile.url}" alt=""/>`))}},b.getImage=(a,c,d)=>new Promise((e,f)=>{const g=`${b.getOptions("system.paths").rootFull}administrator/index.php?option=com_media&format=json`;b.request({url:`${g}&task=api.files&url=true&path=${a.path}&${b.getOptions("csrf.token")}=1&format=json`,method:"GET",perform:!0,headers:{"Content-Type":"application/json"},onSuccess:a=>{const f=JSON.parse(a);e(b.doIt(f,c,d))},onError:()=>{f()}})});class c extends HTMLElement{static get observedAttributes(){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"]}get type(){return this.getAttribute("type")}set type(a){this.setAttribute("type",a)}get basePath(){return this.getAttribute("base-path")}set basePath(a){this.setAttribute("base-path",a)}get rootFolder(){return this.getAttribute("root-folder")}set rootFolder(a){this.setAttribute("root-folder",a)}get url(){return this.getAttribute("url")}set url(a){this.setAttribute("url",a)}get modalContainer(){return this.getAttribute("modal-container")}set modalContainer(a){this.setAttribute("modal-container",a)}get input(){return this.getAttribute("input")}set input(a){this.setAttribute("input",a)}get buttonSelect(){return this.getAttribute("button-select")}set buttonSelect(a){this.setAttribute("button-select",a)}get buttonClear(){return this.getAttribute("button-clear")}set buttonClear(a){this.setAttribute("button-clear",a)}get buttonSaveSelected(){return this.getAttribute("button-save-selected")}set buttonSaveSelected(a){this.setAttribute("button-save-selected",a)}get modalWidth(){return this.getAttribute(parseInt("modal-width",10))}set modalWidth(a){this.setAttribute("modal-width",a)}get modalHeight(){return this.getAttribute(parseInt("modal-height",10))}set modalHeight(a){this.setAttribute("modal-height",a)}get previewWidth(){return this.getAttribute(parseInt("preview-width",10))}set previewWidth(a){this.setAttribute("preview-width",a)}get previewHeight(){return this.getAttribute(parseInt("preview-height",10))}set previewHeight(a){this.setAttribute("preview-height",a)}get preview(){return this.getAttribute("preview")}set preview(a){this.setAttribute("preview",a)}get previewContainer(){return this.getAttribute("preview-container")}connectedCallback(){const 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()}disconnectedCallback(){const a=this.querySelector(this.buttonClear);a.removeEventListener("click",this)}show(){const a=this;this.querySelector("[role=\"dialog\"]").open(),this.querySelector(this.buttonSaveSelected).addEventListener("click",b=>(b.preventDefault(),b.stopPropagation(),this.selectedPath&&a.setValue(this.selectedPath),a.modalClose(),!1))}modalClose(){const a=this.querySelector(this.input);b.getImage(b.selectedFile,a,this),b.Modal.getCurrent().close()}setValue(a){this.querySelector(this.input).value=a,this.updatePreview()}clearValue(){this.setValue("")}updatePreview(){if(-1!==["true","static"].indexOf(this.preview)&&"false"!==this.preview&&this.preview){const 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="";const a=new Image;switch(this.type){case"image":a.src=a.src=/http/.test(c)?c:b.getOptions("system.paths").rootFull+c;break;default:}d.style.width=this.previewWidth,d.appendChild(a)}}}}a.define("joomla-field-media",c)})(customElements,Joomla);

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