芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/tixpeual2124.gob.mx/media/com_media/js/edit-images-es5.min.js
!function(){"use strict";function e(e,t,i,a,n,r,o){try{var s=e[r](o),d=s.value}catch(e){return void i(e)}s.done?t(d):Promise.resolve(d).then(a,n)}function t(t){return function(){var i=this,a=arguments;return new Promise((function(n,r){var o=t.apply(i,a);function s(t){e(o,n,r,s,d,"next",t)}function d(t){e(o,n,r,s,d,"throw",t)}s(void 0)}))}}if(!Joomla)throw new Error("Joomla API is not properly initialized");Joomla.MediaManager=Joomla.MediaManager||{},new(function(){function e(){var e=this;if(this.options=Joomla.getOptions("com_media",{}),!this.options)throw new Error('Initialization error "edit-images.js"');if(this.extension=this.options.uploadPath.split(".").pop(),this.fileType=["jpeg","jpg"].includes(this.extension)?"jpeg":this.extension,this.options.currentUrl=new URL(window.location.href),this.original={filename:this.options.uploadPath.split("/").pop(),extension:this.extension,contents:"data:image/"+this.fileType+";base64,"+this.options.contents},this.previousPluginDeactivated=new Promise((function(e){return e})),this.history={},this.current=this.original,this.plugins={},this.baseContainer=document.getElementById("media-manager-edit-container"),!this.baseContainer)throw new Error("The image preview container is missing");this.createImageContainer(this.original),Joomla.MediaManager.Edit=this,window.dispatchEvent(new CustomEvent("media-manager-edit-init")),customElements.whenDefined("joomla-tab").then(t(regeneratorRuntime.mark((function t(){var i,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=document.getElementById("myTab"),a=i.firstElementChild,[].slice.call(a.querySelectorAll("button[aria-controls]")).forEach((function(t,i){var a=document.getElementById(t.getAttribute("aria-controls"));0===i&&a.insertAdjacentElement("beforeend",e.baseContainer),t.addEventListener("joomla.tab.hidden",(function(t){var i=t.target;e.previousPluginDeactivated=new Promise(i?function(t,a){e.plugins[i.getAttribute("aria-controls").replace("attrib-","")].Deactivate(e.imagePreview).then(t).catch((function(e){console.log(e),a()}))}:function(e){return e})})),t.addEventListener("joomla.tab.shown",(function(t){var i=t.target;a.insertAdjacentElement("beforeend",e.baseContainer),e.previousPluginDeactivated.then((function(){return e.plugins[i.getAttribute("aria-controls").replace("attrib-","")].Activate(e.imagePreview)})).catch((function(e){console.log(e)}))}))})),i.activateTab(0,!1);case 5:case"end":return t.stop()}}),t)})))),this.addHistoryPoint=this.addHistoryPoint.bind(this),this.createImageContainer=this.createImageContainer.bind(this),this.Reset=this.Reset.bind(this),this.Undo=this.Undo.bind(this),this.Redo=this.Redo.bind(this),this.createProgressBar=this.createProgressBar.bind(this),this.updateProgressBar=this.updateProgressBar.bind(this),this.removeProgressBar=this.removeProgressBar.bind(this),this.upload=this.upload.bind(this),window.addEventListener("mediaManager.history.point",this.addHistoryPoint.bind(this))}var i=e.prototype;return i.addHistoryPoint=function(){if(this.original!==this.current){var e=Object.keys(this.history).length;if(this.history[e]&&this.history[e-1]&&this.history[e]===this.history[e-1])return;this.history[e+1]=this.current}},i.createImageContainer=function(e){if(!e.contents)throw new Error('Initialization error "edit-images.js"');this.imagePreview=document.createElement("img"),this.imagePreview.src=e.contents,this.imagePreview.id="image-preview",this.imagePreview.style.height="auto",this.imagePreview.style.maxWidth="100%",this.baseContainer.appendChild(this.imagePreview)},i.Reset=function(){var e=this;this.current.contents="data:image/"+this.fileType+";base64,"+this.options.contents,this.imagePreview.setAttribute("src",this.current.contents),requestAnimationFrame((function(){requestAnimationFrame((function(){e.imagePreview.setAttribute("width",e.imagePreview.naturalWidth),e.imagePreview.setAttribute("height",e.imagePreview.naturalHeight)}))}))},i.Undo=function(){},i.Redo=function(){},i.createProgressBar=function(){},i.updateProgressBar=function(){},i.removeProgressBar=function(){},i.upload=function(e,t){var i,a=this,n="jpg"===Joomla.MediaManager.Edit.original.extension?"jpeg":Joomla.MediaManager.Edit.original.extension;if(n||(n=/data:image\/(.+);/gm.exec(Joomla.MediaManager.Edit.original.contents)[1]),!n)throw new Error("Unable to determine image format");this.xhr=new XMLHttpRequest,"function"==typeof t&&(this.xhr.onreadystatechange=t),this.xhr.upload.onprogress=function(e){a.updateProgressBar(e.loaded/e.total*100)},this.xhr.onload=function(){var e;try{e=JSON.parse(a.xhr.responseText)}catch(t){e=null}e?200===a.xhr.status&&(!0===e.success&&a.removeProgressBar(),"1"===e.status&&(Joomla.renderMessages({success:[e.message]},"true"),a.removeProgressBar())):a.removeProgressBar(),a.xhr=null},this.xhr.onerror=function(){a.removeProgressBar(),a.xhr=null},this.xhr.open("PUT",e,!0),this.xhr.setRequestHeader("Content-Type","application/json"),this.createProgressBar(),this.xhr.send(JSON.stringify(((i={name:Joomla.MediaManager.Edit.options.uploadPath.split("/").pop(),content:Joomla.MediaManager.Edit.current.contents.replace("data:image/"+n+";base64,","")})[Joomla.MediaManager.Edit.options.csrfToken]=1,i)))},e}());var i=function(e){var t=Joomla.MediaManager.Edit.options.currentUrl,i=new URLSearchParams(t.search);i.set("view","media"),i.delete("path"),i.delete("mediatypes");var a=Joomla.MediaManager.Edit.options.uploadPath.split("/");a.pop(),(a=a.join("/")).endsWith(":")&&(a+="/"),i.set("path",a);var n=document.querySelector('input[name="mediatypes"]');return i.set("mediatypes",n&&n.value?n.value:"0"),e&&i.set("tmpl","component"),t.search=i,t};Joomla.submitbutton=function(e){var a=new URL(Joomla.MediaManager.Edit.options.apiBaseUrl+"&task=api.files&path="+Joomla.MediaManager.Edit.options.uploadPath);switch(e){case"apply":Joomla.MediaManager.Edit.upload(a,null),Joomla.MediaManager.Edit.imagePreview.src=Joomla.MediaManager.Edit.current.contents,Joomla.MediaManager.Edit.original=Joomla.MediaManager.Edit.current,Joomla.MediaManager.Edit.history={},t(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].slice.call(document.querySelectorAll("joomla-tab-element")).filter((function(e){return e.hasAttribute("active")})),e.prev=1,e.next=4,Joomla.MediaManager.Edit.plugins[t[0].id.replace("attrib-","")].Deactivate(Joomla.MediaManager.Edit.imagePreview);case 4:return e.next=6,Joomla.MediaManager.Edit.plugins[t[0].id.replace("attrib-","")].Activate(Joomla.MediaManager.Edit.imagePreview);case 6:e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.log(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})))();break;case"save":Joomla.MediaManager.Edit.upload(a,(function(){Joomla.MediaManager.Edit.xhr.readyState===XMLHttpRequest.DONE&&(window.self!==window.top?window.location=i(!0):window.location=i())}));break;case"cancel":window.self!==window.top?window.location=i(!0):window.location=i();break;case"reset":Joomla.MediaManager.Edit.Reset("initial")}}}();