- md5
- a4ef718c84f201d921ebbfb447167038
- sha1
- 6f6945def0dac2e2d09df864179465a6dbe60a56
- sha256
- 95982c2f20db95536b1503eeba984d6d757b832e803640f76b7cd7f1b072ef19
!function(){"use strict";function t(){t=function(){return e};var e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,a=Object.create(o.prototype),s=new J(n||[]);return i(a,"_invoke",{value:P(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=h;var d={};function f(){}function p(){}function g(){}var m={};u(m,a,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(j([])));y&&y!==r&&n.call(y,a)&&(m=y);var w=g.prototype=f.prototype=Object.create(m);function b(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){function r(i,o,a,s){var c=l(t[i],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(h).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function P(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return B()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=M(a,r);if(s){if(s===d)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function M(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,M(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var i=l(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,d;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function J(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function j(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:B}}function B(){return{value:void 0,done:!0}}return p.prototype=g,i(w,"constructor",{value:g,configurable:!0}),i(g,"constructor",{value:p,configurable:!0}),p.displayName=u(g,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,u(t,c,"GeneratorFunction")),t.prototype=Object.create(w),t},e.awrap=function(t){return{__await:t}},b(E.prototype),u(E.prototype,s,(function(){return this})),e.AsyncIterator=E,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new E(h(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(w),u(w,c,"Generator"),u(w,a,(function(){return this})),u(w,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=j,J.prototype={constructor:J,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;L(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}function e(t,e,r,n,i,o,a){try{var s=t[o](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,i)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(i,o){var a=t.apply(r,n);function s(t){e(a,i,o,s,c,"next",t)}function c(t){e(a,i,o,s,c,"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(t){return t})),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(r(t().mark((function r(){var n,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=document.getElementById("myTab"),i=n.firstElementChild,[].slice.call(i.querySelectorAll("button[aria-controls]")).forEach((function(t,r){var n=document.getElementById(t.getAttribute("aria-controls"));0===r&&n.insertAdjacentElement("beforeend",e.baseContainer),t.addEventListener("joomla.tab.hidden",(function(t){var r=t.target;e.previousPluginDeactivated=new Promise(r?function(t,n){e.plugins[r.getAttribute("aria-controls").replace("attrib-","")].Deactivate(e.imagePreview).then(t).catch((function(t){console.log(t),n()}))}:function(t){return t})})),t.addEventListener("joomla.tab.shown",(function(t){var r=t.target;n.insertAdjacentElement("beforeend",e.baseContainer),e.previousPluginDeactivated.then((function(){return e.plugins[r.getAttribute("aria-controls").replace("attrib-","")].Activate(e.imagePreview)})).catch((function(t){console.log(t)}))}))})),n.activateTab(0,!1);case 5:case"end":return t.stop()}}),r)})))),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 n=e.prototype;return n.addHistoryPoint=function(){if(this.original!==this.current){var t=Object.keys(this.history).length;if(this.history[t]&&this.history[t-1]&&this.history[t]===this.history[t-1])return;this.history[t+1]=this.current}},n.createImageContainer=function(t){if(!t.contents)throw new Error('Initialization error "edit-images.js"');this.imagePreview=document.createElement("img"),this.imagePreview.src=t.contents,this.imagePreview.id="image-preview",this.imagePreview.style.height="auto",this.imagePreview.style.maxWidth="100%",this.baseContainer.appendChild(this.imagePreview)},n.Reset=function(){var t=this;this.current.contents="data:image/"+this.fileType+";base64,"+this.options.contents,this.imagePreview.setAttribute("src",this.current.contents),requestAnimationFrame((function(){requestAnimationFrame((function(){t.imagePreview.setAttribute("width",t.imagePreview.naturalWidth),t.imagePreview.setAttribute("height",t.imagePreview.naturalHeight)}))}))},n.Undo=function(){},n.Redo=function(){},n.createProgressBar=function(){},n.updateProgressBar=function(){},n.removeProgressBar=function(){},n.upload=function(t,e){var r,n=this,i="jpg"===Joomla.MediaManager.Edit.original.extension?"jpeg":Joomla.MediaManager.Edit.original.extension;if(i||(i=/data:image\/(.+);/gm.exec(Joomla.MediaManager.Edit.original.contents)[1]),!i)throw new Error("Unable to determine image format");this.xhr=new XMLHttpRequest,"function"==typeof e&&(this.xhr.onreadystatechange=e),this.xhr.upload.onprogress=function(t){n.updateProgressBar(t.loaded/t.total*100)},this.xhr.onload=function(){var t;try{t=JSON.parse(n.xhr.responseText)}catch(e){t=null}t?200===n.xhr.status&&(!0===t.success&&n.removeProgressBar(),"1"===t.status&&(Joomla.renderMessages({success:[t.message]},"true"),n.removeProgressBar())):n.removeProgressBar(),n.xhr=null},this.xhr.onerror=function(){n.removeProgressBar(),n.xhr=null},this.xhr.open("PUT",t,!0),this.xhr.setRequestHeader("Content-Type","application/json"),this.createProgressBar(),this.xhr.send(JSON.stringify(((r={name:Joomla.MediaManager.Edit.options.uploadPath.split("/").pop(),content:Joomla.MediaManager.Edit.current.contents.replace("data:image/"+i+";base64,","")})[Joomla.MediaManager.Edit.options.csrfToken]=1,r)))},e}());var n=function(t){var e=Joomla.MediaManager.Edit.options.currentUrl,r=new URLSearchParams(e.search);r.set("view","media"),r.delete("path"),r.delete("mediatypes");var n=Joomla.MediaManager.Edit.options.uploadPath.split("/");n.pop(),(n=n.join("/")).endsWith(":")&&(n+="/"),r.set("path",n);var i=document.querySelector('input[name="mediatypes"]');return r.set("mediatypes",i&&i.value?i.value:"0"),t&&r.set("tmpl","component"),e.search=r,e};Joomla.submitbutton=function(e){var i=new URL(Joomla.MediaManager.Edit.options.apiBaseUrl+"&task=api.files&path="+Joomla.MediaManager.Edit.options.uploadPath);switch(e){case"apply":Joomla.MediaManager.Edit.upload(i,null),Joomla.MediaManager.Edit.imagePreview.src=Joomla.MediaManager.Edit.current.contents,Joomla.MediaManager.Edit.original=Joomla.MediaManager.Edit.current,Joomla.MediaManager.Edit.history={},r(t().mark((function e(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[].slice.call(document.querySelectorAll("joomla-tab-element")).filter((function(t){return t.hasAttribute("active")})),t.prev=1,t.next=4,Joomla.MediaManager.Edit.plugins[r[0].id.replace("attrib-","")].Deactivate(Joomla.MediaManager.Edit.imagePreview);case 4:return t.next=6,Joomla.MediaManager.Edit.plugins[r[0].id.replace("attrib-","")].Activate(Joomla.MediaManager.Edit.imagePreview);case 6:t.next=11;break;case 8:t.prev=8,t.t0=t.catch(1),console.log(t.t0);case 11:case"end":return t.stop()}}),e,null,[[1,8]])})))();break;case"save":Joomla.MediaManager.Edit.upload(i,(function(){Joomla.MediaManager.Edit.xhr.readyState===XMLHttpRequest.DONE&&(window.self!==window.top?window.location=n(!0):window.location=n())}));break;case"cancel":window.self!==window.top?window.location=n(!0):window.location=n();break;case"reset":Joomla.MediaManager.Edit.Reset("initial")}}}();
The same content is in 21 releases, Joomla 4.3.0-alpha3 to 5.0.0-alpha1. See them all, or every version of this file.