CoreFiles by mySites.guru
edit-images.es6.min.js1 lines, 4,993 bytes, from Joomla_4.0.0-beta2-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta
md5
e022d2b9296fc28edb6850853c4d9330
sha1
803964339ffbaa10d3afe8b5285afe208b8d0490
sha256
26b5b2d96fe68ec19342c3fc92280111d8af30ed0ab8e1290416aee7a8e428e8
Joomla=window.Joomla||{},Joomla.MediaManager=Joomla.MediaManager||{},(()=>{'use strict';const a=Joomla.getOptions("com_media",{});if(!a)throw new Error("Initialization error \"edit-images.js\"");Joomla.MediaManager.Edit.original={filename:a.uploadPath.split("/").pop(),extension:a.uploadPath.split(".").pop(),contents:`data:image/${a.uploadPath.split(".").pop()};base64,${a.contents}`},Joomla.MediaManager.Edit.history={},Joomla.MediaManager.Edit.current={};const b=(a,b)=>{if(!b.contents)return;const c=document.getElementById("media-manager-edit-container"),d=document.createElement("div"),e=document.createElement("div"),f=document.createElement("img"),g=document.createElement("img");c.innerHTML="",f.src=b.contents,f.id="image-source",f.style.maxWidth="100%",g.src=b.contents,g.id="image-preview",g.style.maxWidth="100%",d.classList.add("hidden"),d.appendChild(f),c.appendChild(d),e.appendChild(g),c.appendChild(e),Joomla.MediaManager.Edit[a.toLowerCase()].Activate(b)};Joomla.MediaManager.Edit.Reset=a=>{(!a||a&&"initial"===a)&&(Joomla.MediaManager.Edit.current.contents=Joomla.MediaManager.Edit.original.contents);const c=document.getElementById("media-manager-edit-container");c.innerHTML="";const d=document.getElementById("myTab").firstElementChild;if("UL"===d.tagName){const c=[].slice.call(d.querySelectorAll("a"));c.forEach(c=>{if(!c.hasAttribute("active"))return;Joomla.MediaManager.Edit[c.id.replace("tab-attrib-","").toLowerCase()].Deactivate();let d=Joomla.MediaManager.Edit.current;(!a||a&&!0!==a)&&(d=Joomla.MediaManager.Edit.original),c.click();const e=document.getElementById("media-manager-edit-container"),f=document.getElementById(c.id.replace("tab-",""));f.insertAdjacentElement("afterbegin",e),b(c.id.replace("tab-attrib-",""),d)})}},window.addEventListener("mediaManager.history.point",()=>{if(Joomla.MediaManager.Edit.original!==Joomla.MediaManager.Edit.current.contents){const a=Object.keys(Joomla.MediaManager.Edit.history).length;if(Joomla.MediaManager.Edit.history[a]&&Joomla.MediaManager.Edit.history[a-1]&&Joomla.MediaManager.Edit.history[a]===Joomla.MediaManager.Edit.history[a-1])return;Joomla.MediaManager.Edit.history[a+1]=Joomla.MediaManager.Edit.current.contents}}),Joomla.MediaManager.Edit.Undo=()=>{},Joomla.MediaManager.Edit.Redo=()=>{},Joomla.MediaManager.Edit.createProgressBar=()=>{},Joomla.MediaManager.Edit.updateProgressBar=()=>{},Joomla.MediaManager.Edit.removeProgressBar=()=>{},Joomla.submitbutton=b=>{const c="jpg"===Joomla.MediaManager.Edit.original.extension?"jpeg":Joomla.MediaManager.Edit.original.extension,d=window.location.pathname.replace(/&view=file.*/g,""),e=a.uploadPath.split("/").pop(),f={name:e,content:Joomla.MediaManager.Edit.current.contents.replace(`data:image/${c};base64,`,"")},g=a.uploadPath,h=`${a.apiBaseUrl}&task=api.files&path=${g}`,i="application/json";f[a.csrfToken]="1";let j=g.split("/");switch(j.pop(),j=j.join("/"),j.endsWith(":")&&(j=`${j}/`),b){case"apply":Joomla.UploadFile.exec(e,JSON.stringify(f),g,h,i),Joomla.MediaManager.Edit.Reset(!0);break;case"save":Joomla.UploadFile.exec(e,JSON.stringify(f),g,h,i),window.location=`${d}?option=com_media&path=${j}`;break;case"cancel":window.location=window.self===window.top?`${d}?option=com_media&path=${j}`:`${d}?option=com_media&path=${j}&tmpl=component`;break;case"reset":Joomla.MediaManager.Edit.Reset("initial");break;case"undo":break;case"redo":break;default:}},Joomla.UploadFile={},Joomla.UploadFile.exec=(a,b,c,d,e)=>{const f=new XMLHttpRequest;f.upload.onprogress=a=>{Joomla.MediaManager.Edit.updateProgressBar(100*(a.loaded/a.total))},f.onload=()=>{let a;try{a=JSON.parse(f.responseText)}catch(b){a=null}a?200===f.status&&(!0===a.success&&Joomla.MediaManager.Edit.removeProgressBar(),"1"===a.status&&(Joomla.renderMessages({success:[a.message]},"true"),Joomla.MediaManager.Edit.removeProgressBar())):Joomla.MediaManager.Edit.removeProgressBar()},f.onerror=()=>{Joomla.MediaManager.Edit.removeProgressBar()},f.open("PUT",d,!0),f.setRequestHeader("Content-Type",e),Joomla.MediaManager.Edit.createProgressBar(),f.send(b)},document.addEventListener("DOMContentLoaded",()=>{const a=()=>{const c=document.getElementById("myTab").firstElementChild;if("UL"!==c.tagName)return void setTimeout(a,50);const d=[].slice.call(c.querySelectorAll("a"));d[0]&&b(d[0].id.replace("tab-attrib-",""),Joomla.MediaManager.Edit.original),d.forEach(a=>{a.addEventListener("joomla.tab.shown",({relatedTarget:a,target:c})=>{const d=document.getElementById("media-manager-edit-container");a&&(Joomla.MediaManager.Edit[a.id.replace("tab-attrib-","").toLowerCase()].Deactivate(),d.innerHTML="");let e=Joomla.MediaManager.Edit.current;"contents"in Joomla.MediaManager.Edit.current||(e=Joomla.MediaManager.Edit.original);const f=document.getElementById(c.id.replace("tab-",""));f.insertAdjacentElement("afterbegin",d),b(c.id.replace("tab-attrib-",""),e)}),a.click()}),d[0]&&(d[0].click(),b(d[0].id.replace("tab-attrib-",""),Joomla.MediaManager.Edit.original))};setTimeout(a,50)})})();

The same content is in 3 releases, Joomla 4.0.0-beta to 4.0.0-beta3. See them all, or every version of this file.