CoreFiles by mySites.guru
edit-images.es6.min.js1 lines, 5,227 bytes, from Joomla_4.0.0-beta7-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta6
md5
a7cc585d307b9aece027ff5ebe3cb084
sha1
c9b661a8992c8e3146b21182bde6cbc92a51b745
sha256
d3fb73b7626012c1124f72534a163ac314e12173f619fcc2e86e60404b5382fe
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("beforeend",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,function(){this.readyState===XMLHttpRequest.DONE&&(window.self===window.top?window.location=`${d}?option=com_media&view=media&path=${j}`:window.location=`${d}?option=com_media&view=media&path=${j}&tmpl=component`)});break;case"cancel":window.location=window.self===window.top?`${d}?option=com_media&view=media&path=${j}`:`${d}?option=com_media&view=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,f)=>{const g=new XMLHttpRequest;g.upload.onprogress=a=>{Joomla.MediaManager.Edit.updateProgressBar(100*(a.loaded/a.total))},"function"==typeof f&&(g.onreadystatechange=f),g.onload=()=>{let a;try{a=JSON.parse(g.responseText)}catch(b){a=null}a?200===g.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()},g.onerror=()=>{Joomla.MediaManager.Edit.removeProgressBar()},g.open("PUT",d,!0),g.setRequestHeader("Content-Type",e),Joomla.MediaManager.Edit.createProgressBar(),g.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("beforeend",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 2 releases, Joomla 4.0.0-beta6 to 4.0.0-beta7. See them all, or every version of this file.