CoreFiles by mySites.guru
joomla-field-media.min.js1 lines, 4,895 bytes, from Joomla_4.0.0-alpha3-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha2
md5
24f925e2fb52629c13cda6e2042c1853
sha1
77d4f24c97e89033a88abb7cb51757be262e87ce
sha256
e60f482c42e9fd23e8f55458af72bb23ca7d12f9abfc4440b63b9f2873b8e915
((t,e,i)=>{if(!e)throw new Error("Joomla API is not properly initiated");e.selectedFile={},window.document.addEventListener("onMediaFileSelected",t=>{e.selectedFile=t.detail}),e.doIt=function(t,i,s){"use strict";if(!0===t.success){if(t.data[0].url)if(/local-/.test(t.data[0].adapter)){var r=e.getOptions("system.paths").rootFull;e.selectedFile.url=t.data[0].url.split(r)[1],t.data[0].thumb_path?e.selectedFile.thumb=t.data[0].thumb_path:e.selectedFile.thumb=!1}else t.data[0].thumb_path&&(e.selectedFile.thumb=t.data[0].thumb_path);else e.selectedFile.url=!1;const l=t=>"object"==typeof HTMLElement?t instanceof HTMLElement:t&&"object"==typeof t&&null!==t&&1===t.nodeType&&"string"==typeof t.nodeName;e.selectedFile.url&&(l(i)||"object"==typeof i?!l(i)&&"object"==typeof i&&i.id?parent.window.Joomla.editors.instances[i.id].replaceSelection('<img src="'+e.selectedFile.url+'" alt=""/>'):(i.value=e.selectedFile.url,s.updatePreview()):e.editors.instances[i].replaceSelection('<img src="'+e.selectedFile.url+'" alt=""/>'))}},e.getImage=function(t,i,s){return new Promise((r,l)=>{var o=e.getOptions("csrf.token"),a=e.getOptions("system.paths").rootFull+"administrator/index.php?option=com_media&format=json";e.request({url:a+"&task=api.files&url=true&path="+t.path+"&"+o+"=1&format=json",method:"GET",perform:!0,headers:{"Content-Type":"application/json"},onSuccess:function(t){const l=JSON.parse(t);r(e.doIt(l,i,s))},onError:function(){l()}})})};t.define("joomla-field-media",class 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(t){this.setAttribute("type",t)}get basePath(){return this.getAttribute("base-path")}set basePath(t){this.setAttribute("base-path",t)}get rootFolder(){return this.getAttribute("root-folder")}set rootFolder(t){this.setAttribute("root-folder",t)}get url(){return this.getAttribute("url")}set url(t){this.setAttribute("url",t)}get modalContainer(){return this.getAttribute("modal-container")}set modalContainer(t){this.setAttribute("modal-container",t)}get input(){return this.getAttribute("input")}set input(t){this.setAttribute("input",t)}get buttonSelect(){return this.getAttribute("button-select")}set buttonSelect(t){this.setAttribute("button-select",t)}get buttonClear(){return this.getAttribute("button-clear")}set buttonClear(t){this.setAttribute("button-clear",t)}get buttonSaveSelected(){return this.getAttribute("button-save-selected")}set buttonSaveSelected(t){this.setAttribute("button-save-selected",t)}get modalWidth(){return this.getAttribute(parseInt("modal-width",10))}set modalWidth(t){this.setAttribute("modal-width",t)}get modalHeight(){return this.getAttribute(parseInt("modal-height",10))}set modalHeight(t){this.setAttribute("modal-height",t)}get previewWidth(){return this.getAttribute(parseInt("preview-width",10))}set previewWidth(t){this.setAttribute("preview-width",t)}get previewHeight(){return this.getAttribute(parseInt("preview-height",10))}set previewHeight(t){this.setAttribute("preview-height",t)}get preview(){return this.getAttribute("preview")}set preview(t){this.setAttribute("preview",t)}get previewContainer(){return this.getAttribute("preview-container")}connectedCallback(){const t=this.querySelector(this.buttonSelect),e=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),t.addEventListener("click",this.show),e&&e.addEventListener("click",this.clearValue),this.updatePreview()}disconnectedCallback(){this.querySelector(this.buttonClear).removeEventListener("click",this)}show(){const t=this;i(this.querySelector('[role="dialog"]')).modal("show"),i(this.querySelector(this.buttonSaveSelected)).on("click",e=>(e.preventDefault(),e.stopPropagation(),this.selectedPath&&t.setValue(this.selectedPath),t.modalClose(),!1))}modalClose(){const t=this.querySelector(this.input);e.getImage(e.selectedFile,t,this),i(this.querySelector('[role="dialog"]')).modal("hide")}setValue(t){i(this.querySelector(this.input)).val(t).trigger("change"),this.updatePreview()}clearValue(){this.setValue("")}updatePreview(){if(-1!==["true","static"].indexOf(this.preview)&&"false"!==this.preview&&this.preview){const t=this.querySelector(this.input).value,i=this.querySelector(".field-media-preview");if(t){i.innerHTML="";const s=new Image;switch(this.type){case"image":s.src=s.src=/http/.test(t)?t:e.getOptions("system.paths").rootFull+t}i.style.width=this.previewWidth,i.appendChild(s)}else i.innerHTML='<span class="field-media-preview-icon fa fa-picture-o"></span>'}}})})(customElements,Joomla,jQuery);

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