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