mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-02 12:54:18 +01:00
16fe435de4
- Fix language setting - Update TinyMCE
1 line
23 KiB
JavaScript
1 line
23 KiB
JavaScript
!function(){"use strict";var r=function(t){var n=t,e=function(){return n};return{get:e,set:function(t){n=t},clone:function(){return r(e())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),u=tinymce.util.Tools.resolve("tinymce.util.Tools");function e(t,n){return i(document.createElement("canvas"),t,n)}function o(t){return t.getContext("2d")}function i(t,n,e){return t.width=n,t.height=e,t}var n,a,c,f,l={create:e,clone:function Xt(t){var n;return o(n=e(t.width,t.height)).drawImage(t,0,0),n},resize:i,get2dContext:o,get3dContext:function Yt(t){var n=null;try{n=t.getContext("webgl")||t.getContext("experimental-webgl")}catch(e){}return n||(n=null),n}},d={getWidth:function Qt(t){return t.naturalWidth||t.width},getHeight:function Zt(t){return t.naturalHeight||t.height}},h=window.Promise?window.Promise:function(){var t=function(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],f(t,r(o,this),r(a,this))},n=t.immediateFn||"function"==typeof window.setImmediate&&window.setImmediate||function(t){setTimeout(t,1)};function r(t,n){return function(){t.apply(n,arguments)}}var e=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(r){var o=this;null!==this._state?n(function(){var t=o._state?r.onFulfilled:r.onRejected;if(null!==t){var n;try{n=t(o._value)}catch(e){return void r.reject(e)}r.resolve(n)}else(o._state?r.resolve:r.reject)(o._value)}):this._deferreds.push(r)}function o(t){try{if(t===this)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var n=t.then;if("function"==typeof n)return void f(r(n,t),r(o,this),r(a,this))}this._state=!0,this._value=t,u.call(this)}catch(e){a.call(this,e)}}function a(t){this._state=!1,this._value=t,u.call(this)}function u(){for(var t=0,n=this._deferreds.length;t<n;t++)i.call(this,this._deferreds[t]);this._deferreds=null}function c(t,n,e,r){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.resolve=e,this.reject=r}function f(t,n,e){var r=!1;try{t(function(t){r||(r=!0,n(t))},function(t){r||(r=!0,e(t))})}catch(o){if(r)return;r=!0,e(o)}}return t.prototype["catch"]=function(t){return this.then(null,t)},t.prototype.then=function(e,r){var o=this;return new t(function(t,n){i.call(o,new c(e,r,t,n))})},t.all=function(){var c=Array.prototype.slice.call(1===arguments.length&&e(arguments[0])?arguments[0]:arguments);return new t(function(o,i){if(0===c.length)return o([]);var a=c.length;function u(n,t){try{if(t&&("object"==typeof t||"function"==typeof t)){var e=t.then;if("function"==typeof e)return void e.call(t,function(t){u(n,t)},i)}c[n]=t,0==--a&&o(c)}catch(r){i(r)}}for(var t=0;t<c.length;t++)u(t,c[t])})},t.resolve=function(n){return n&&"object"==typeof n&&n.constructor===t?n:new t(function(t){t(n)})},t.reject=function(e){return new t(function(t,n){n(e)})},t.race=function(o){return new t(function(t,n){for(var e=0,r=o.length;e<r;e++)o[e].then(t,n)})},t}(),g=function(t){return function(){return t}},s=function(i){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var a=new Array(arguments.length-1),e=1;e<arguments.length;e++)a[e-1]=arguments[e];return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var e=new Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var o=a.concat(e);return i.apply(null,o)}},m=g(!1),p=g(!0),v=m,y=p,b=function(){return w},w=(f={fold:function(t,n){return t()},is:v,isSome:v,isNone:y,getOr:c=function(t){return t},getOrThunk:a=function(t){return t()},getOrDie:function(t){throw new Error(t||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:c,orThunk:a,map:b,ap:b,each:function(){},bind:b,flatten:b,exists:v,forall:y,filter:b,equals:n=function(t){return t.isNone()},equals_:n,toArray:function(){return[]},toString:g("none()")},Object.freeze&&Object.freeze(f),f),I=function(e){var t=function(){return e},n=function(){return o},r=function(t){return t(e)},o={fold:function(t,n){return n(e)},is:function(t){return e===t},isSome:y,isNone:v,getOr:t,getOrThunk:t,getOrDie:t,getOrNull:t,getOrUndefined:t,or:n,orThunk:n,map:function(t){return I(t(e))},ap:function(t){return t.fold(b,function(t){return I(t(e))})},each:function(t){t(e)},bind:r,flatten:t,exists:r,forall:r,filter:function(t){return t(e)?o:w},equals:function(t){return t.is(e)},equals_:function(t,n){return t.fold(v,function(t){return n(e,t)})},toArray:function(){return[e]},toString:function(){return"some("+e+")"}};return o},T={some:I,none:b,from:function(t){return null===t||t===undefined?w:I(t)}},C="undefined"!=typeof window?window:Function("return this;")(),A=function(t,n){return function(t,n){for(var e=n!==undefined&&null!==n?n:C,r=0;r<t.length&&e!==undefined&&null!==e;++r)e=e[t[r]];return e}(t.split("."),n)},j={getOrDie:function(t,n){var e=A(t,n);if(e===undefined||null===e)throw t+" not available on this browser";return e}};function x(){return new(j.getOrDie("FileReader"))}var _={atob:function(t){return j.getOrDie("atob")(t)},requestAnimationFrame:function(t){j.getOrDie("requestAnimationFrame")(t)}};function U(u){return new h(function(t,n){var e=URL.createObjectURL(u),r=new Image,o=function(){r.removeEventListener("load",i),r.removeEventListener("error",a)};function i(){o(),t(r)}function a(){o(),n("Unable to load data of type "+u.type+": "+e)}r.addEventListener("load",i),r.addEventListener("error",a),r.src=e,r.complete&&i()})}function O(r){return new h(function(t,e){var n=new XMLHttpRequest;n.open("GET",r,!0),n.responseType="blob",n.onload=function(){200==this.status&&t(this.response)},n.onerror=function(){var t,n=this;e(0===this.status?((t=new Error("No access to download image")).code=18,t.name="SecurityError",t):new Error("Error "+n.status+" downloading image"))},n.send()})}function R(t){var n=t.split(","),e=/data:([^;]+)/.exec(n[0]);if(!e)return T.none();for(var r,o=e[1],i=n[1],a=_.atob(i),u=a.length,c=Math.ceil(u/1024),f=new Array(c),s=0;s<c;++s){for(var l=1024*s,d=Math.min(l+1024,u),h=new Array(d-l),g=l,m=0;g<d;++m,++g)h[m]=a[g].charCodeAt(0);f[s]=(r=h,new(j.getOrDie("Uint8Array"))(r))}return T.some(function p(t,n){return new(j.getOrDie("Blob"))(t,n)}(f,{type:o}))}function B(e){return new h(function(t,n){R(e).fold(function(){n("uri is not base64: "+e)},t)})}function S(e){return new h(function(t){var n=x();n.onloadend=function(){t(n.result)},n.readAsDataURL(e)})}var D={blobToImage:U,imageToBlob:function tn(t){var n=t.src;return 0===n.indexOf("data:")?B(n):O(n)},blobToArrayBuffer:function nn(e){return new h(function(t){var n=x();n.onloadend=function(){t(n.result)},n.readAsArrayBuffer(e)})},blobToDataUri:S,blobToBase64:function en(t){return S(t).then(function(t){return t.split(",")[1]})},dataUriToBlobSync:R,canvasToBlob:function rn(t,e,r){return e=e||"image/png",HTMLCanvasElement.prototype.toBlob?new h(function(n){t.toBlob(function(t){n(t)},e,r)}):B(t.toDataURL(e,r))},canvasToDataURL:function on(t,n,e){return n=n||"image/png",t.then(function(t){return t.toDataURL(n,e)})},blobToCanvas:function an(t){return U(t).then(function(t){var n;return function e(t){URL.revokeObjectURL(t.src)}(t),n=l.create(d.getWidth(t),d.getHeight(t)),l.get2dContext(n).drawImage(t,0,0),n})},uriToBlob:function un(t){return 0===t.indexOf("blob:")?O(t):0===t.indexOf("data:")?B(t):null}},E=function(t){return D.blobToImage(t)},L=function(t){return D.imageToBlob(t)};function M(t,n,e){var r=n.type;function o(n,e){return t.then(function(t){return D.canvasToDataURL(t,n,e)})}return{getType:g(r),toBlob:function i(){return h.resolve(n)},toDataURL:function a(){return e},toBase64:function u(){return e.split(",")[1]},toAdjustedBlob:function c(n,e){return t.then(function(t){return D.canvasToBlob(t,n,e)})},toAdjustedDataURL:o,toAdjustedBase64:function f(t,n){return o(t,n).then(function(t){return t.split(",")[1]})},toCanvas:function s(){return t.then(l.clone)}}}function P(n){return D.blobToDataUri(n).then(function(t){return M(D.blobToCanvas(n),n,t)})}var k={fromBlob:P,fromCanvas:function cn(n,t){return D.canvasToBlob(n,t).then(function(t){return M(h.resolve(n),t,n.toDataURL())})},fromImage:function fn(t){return D.imageToBlob(t).then(function(t){return P(t)})},fromBlobAndUrlSync:function(t,n){return M(D.blobToCanvas(t),t,n)}};function z(t,n,e){return e<(t=parseFloat(t))?t=e:t<n&&(t=n),t}var H=[0,.01,.02,.04,.05,.06,.07,.08,.1,.11,.12,.14,.15,.16,.17,.18,.2,.21,.22,.24,.25,.27,.28,.3,.32,.34,.36,.38,.4,.42,.44,.46,.48,.5,.53,.56,.59,.62,.65,.68,.71,.74,.77,.8,.83,.86,.89,.92,.95,.98,1,1.06,1.12,1.18,1.24,1.3,1.36,1.42,1.48,1.54,1.6,1.66,1.72,1.78,1.84,1.9,1.96,2,2.12,2.25,2.37,2.5,2.62,2.75,2.87,3,3.2,3.4,3.6,3.8,4,4.3,4.7,4.9,5,5.5,6,6.5,6.8,7,7.3,7.5,7.8,8,8.4,8.7,9,9.4,9.6,9.8,10];function N(t,n){var e,r,o,i,a=[],u=new Array(10);for(e=0;e<5;e++){for(r=0;r<5;r++)a[r]=n[r+5*e];for(r=0;r<5;r++){for(o=i=0;o<5;o++)i+=t[r+5*o]*a[o];u[r+5*e]=i}}return u}function F(t,e){return e=z(e,0,1),t.map(function(t,n){return n%6==0?t=1-(1-t)*e:t*=e,z(t,0,1)})}var q={identity:function sn(){return[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1]},adjust:F,multiply:N,adjustContrast:function ln(t,n){var e;return n=z(n,-1,1),N(t,[(e=(n*=100)<0?127+n/100*127:127*(e=0==(e=n%1)?H[n]:H[Math.floor(n)]*(1-e)+H[Math.floor(n)+1]*e)+127)/127,0,0,0,.5*(127-e),0,e/127,0,0,.5*(127-e),0,0,e/127,0,.5*(127-e),0,0,0,1,0,0,0,0,0,1])},adjustBrightness:function dn(t,n){return N(t,[1,0,0,0,n=z(255*n,-255,255),0,1,0,0,n,0,0,1,0,n,0,0,0,1,0,0,0,0,0,1])},adjustSaturation:function hn(t,n){var e;return N(t,[.3086*(1-(e=1+(0<(n=z(n,-1,1))?3*n:n)))+e,.6094*(1-e),.082*(1-e),0,0,.3086*(1-e),.6094*(1-e)+e,.082*(1-e),0,0,.3086*(1-e),.6094*(1-e),.082*(1-e)+e,0,0,0,0,0,1,0,0,0,0,0,1])},adjustHue:function gn(t,n){var e,r,o,i,a;return n=z(n,-180,180)/180*Math.PI,N(t,[(o=.213)+.787*(e=Math.cos(n))+(r=Math.sin(n))*-o,(i=.715)+e*-i+r*-i,(a=.072)+e*-a+.928*r,0,0,o+e*-o+.143*r,i+e*(1-i)+.14*r,a+e*-a+-.283*r,0,0,o+e*-o+-.787*r,i+e*-i+r*i,a+.928*e+r*a,0,0,0,0,0,1,0,0,0,0,0,1])},adjustColors:function mn(t,n,e,r){return N(t,[n=z(n,0,2),0,0,0,0,0,e=z(e,0,2),0,0,0,0,0,r=z(r,0,2),0,0,0,0,0,1,0,0,0,0,0,1])},adjustSepia:function pn(t,n){return N(t,F([.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0,0,0,0,0,1],n=z(n,0,1)))},adjustGrayscale:function vn(t,n){return N(t,F([.33,.34,.33,0,0,.33,.34,.33,0,0,.33,.34,.33,0,0,0,0,0,1,0,0,0,0,0,1],n=z(n,0,1)))}};function G(n,e){return n.toCanvas().then(function(t){return function i(t,n,e){var r,o=l.get2dContext(t);return r=function U(t,n){var e,r,o,i,a,u=t.data,c=n[0],f=n[1],s=n[2],l=n[3],d=n[4],h=n[5],g=n[6],m=n[7],p=n[8],v=n[9],y=n[10],b=n[11],w=n[12],I=n[13],T=n[14],C=n[15],A=n[16],j=n[17],x=n[18],_=n[19];for(a=0;a<u.length;a+=4)e=u[a],r=u[a+1],o=u[a+2],i=u[a+3],u[a]=e*c+r*f+o*s+i*l+d,u[a+1]=e*h+r*g+o*m+i*p+v,u[a+2]=e*y+r*b+o*w+i*I+T,u[a+3]=e*C+r*A+o*j+i*x+_;return t}(o.getImageData(0,0,t.width,t.height),e),o.putImageData(r,0,0),k.fromCanvas(t,n)}(t,n.getType(),e)})}function W(n,e){return n.toCanvas().then(function(t){return function a(t,n,e){var r,o,i=l.get2dContext(t);return r=i.getImageData(0,0,t.width,t.height),o=i.getImageData(0,0,t.width,t.height),o=function I(t,n,e){var r,o,i,a,u,c,f,s,l,d,h,g,m,p,v,y,b;function w(t,n,e){return e<t?t=e:t<n&&(t=n),t}for(i=Math.round(Math.sqrt(e.length)),a=Math.floor(i/2),r=t.data,o=n.data,y=t.width,b=t.height,c=0;c<b;c++)for(u=0;u<y;u++){for(f=s=l=0,h=0;h<i;h++)for(d=0;d<i;d++)g=w(u+d-a,0,y-1),m=w(c+h-a,0,b-1),p=4*(m*y+g),v=e[h*i+d],f+=r[p]*v,s+=r[p+1]*v,l+=r[p+2]*v;o[p=4*(c*y+u)]=w(f,0,255),o[p+1]=w(s,0,255),o[p+2]=w(l,0,255)}return n}(r,o,e),i.putImageData(o,0,0),k.fromCanvas(t,n)}(t,n.getType(),e)})}function $(c){return function(n,e){return n.toCanvas().then(function(t){return function(t,n,e){var r,o,i=l.get2dContext(t),a=new Array(256);for(o=0;o<a.length;o++)a[o]=c(o,e);return r=function u(t,n){var e,r=t.data;for(e=0;e<r.length;e+=4)r[e]=n[r[e]],r[e+1]=n[r[e+1]],r[e+2]=n[r[e+2]];return t}(i.getImageData(0,0,t.width,t.height),a),i.putImageData(r,0,0),k.fromCanvas(t,n)}(t,n.getType(),e)})}}function V(e){return function(t,n){return G(t,e(q.identity(),n))}}function J(n){return function(t){return W(t,n)}}(function yn(n){return function(t){return G(t,n)}})([-1,0,0,0,255,0,-1,0,0,255,0,0,-1,0,255,0,0,0,1,0]),V(q.adjustBrightness),V(q.adjustHue),V(q.adjustSaturation),V(q.adjustContrast),V(q.adjustGrayscale),V(q.adjustSepia),J([0,-1,0,-1,5,-1,0,-1,0]),J([-2,-1,0,-1,1,1,0,1,2]),$(function(t,n){return 255*Math.pow(t/255,1-n)}),$(function(t,n){return 255*(1-Math.exp(-t/255*n))});var K,X={scale:function bn(t,n,e){var r=d.getWidth(t),o=d.getHeight(t),i=n/r,a=e/o,u=!1;(i<.5||2<i)&&(i=i<.5?.5:2,u=!0),(a<.5||2<a)&&(a=a<.5?.5:2,u=!0);var c=function s(u,c,f){return new h(function(t){var n=d.getWidth(u),e=d.getHeight(u),r=Math.floor(n*c),o=Math.floor(e*f),i=l.create(r,o),a=l.get2dContext(i);a.drawImage(u,0,0,n,e,0,0,r,o),t(i)})}(t,i,a);return u?c.then(function(t){return bn(t,n,e)}):c}},Y={rotate:function wn(n,e){return n.toCanvas().then(function(t){return function u(t,n,e){var r=l.create(t.width,t.height),o=l.get2dContext(r),i=0,a=0;return 90!=(e=e<0?360+e:e)&&270!=e||l.resize(r,r.height,r.width),90!=e&&180!=e||(i=r.width),270!=e&&180!=e||(a=r.height),o.translate(i,a),o.rotate(e*Math.PI/180),o.drawImage(t,0,0),k.fromCanvas(r,n)}(t,n.getType(),e)})},flip:function In(n,e){return n.toCanvas().then(function(t){return function i(t,n,e){var r=l.create(t.width,t.height),o=l.get2dContext(r);return"v"==e?(o.scale(1,-1),o.drawImage(t,0,-r.height)):(o.scale(-1,1),o.drawImage(t,-r.width,0)),k.fromCanvas(r,n)}(t,n.getType(),e)})},crop:function Tn(n,e,r,o,i){return n.toCanvas().then(function(t){return function u(t,n,e,r,o,i){var a=l.create(o,i);return l.get2dContext(a).drawImage(t,-e,-r),k.fromCanvas(a,n)}(t,n.getType(),e,r,o,i)})},resize:function Cn(n,e,r){return n.toCanvas().then(function(t){return X.scale(t,e,r).then(function(t){return k.fromCanvas(t,n.getType())})})}},Q=(function(){function t(t){this.littleEndian=!1,this._dv=new DataView(t)}t.prototype.readByteAt=function(t){return this._dv.getUint8(t)},t.prototype.read=function(t,n){if(t+n>this.length())return null;for(var e=this.littleEndian?0:-8*(n-1),r=0,o=0;r<n;r++)o|=this.readByteAt(t+r)<<Math.abs(e+8*r);return o},t.prototype.BYTE=function(t){return this.read(t,1)},t.prototype.SHORT=function(t){return this.read(t,2)},t.prototype.LONG=function(t){return this.read(t,4)},t.prototype.SLONG=function(t){var n=this.read(t,4);return 2147483647<n?n-4294967296:n},t.prototype.CHAR=function(t){return String.fromCharCode(this.read(t,1))},t.prototype.STRING=function(t,n){return this.asArray("CHAR",t,n).join("")},t.prototype.SEGMENT=function(t,n){var e=this._dv.buffer;switch(arguments.length){case 2:return e.slice(t,t+n);case 1:return e.slice(t);default:return e}},t.prototype.asArray=function(t,n,e){for(var r=[],o=0;o<e;o++)r[o]=this[t](n+o);return r},t.prototype.length=function(){return this._dv?this._dv.byteLength:0}}(),function(t,n){return Y.rotate(t,n)}),Z=function(t,n){return Y.flip(t,n)},tt=Q,nt=function(t){return k.fromBlob(t)},et=function(){return j.getOrDie("URL")},rt=function(t){return et().createObjectURL(t)},ot=function(t){et().revokeObjectURL(t)},it=tinymce.util.Tools.resolve("tinymce.util.Delay"),at=tinymce.util.Tools.resolve("tinymce.util.Promise"),ut=tinymce.util.Tools.resolve("tinymce.util.URI"),ct={getImageSize:function An(t){var n,e;function r(t){return/^[0-9\.]+px$/.test(t)}return n=t.style.width,e=t.style.height,n||e?r(n)&&r(e)?{w:parseInt(n,10),h:parseInt(e,10)}:null:(n=t.width,e=t.height,n&&e?{w:parseInt(n,10),h:parseInt(e,10)}:null)},setImageSize:function jn(t,n){var e,r;n&&(e=t.style.width,r=t.style.height,(e||r)&&(t.style.width=n.w+"px",t.style.height=n.h+"px",t.removeAttribute("data-mce-style")),e=t.width,r=t.height,(e||r)&&(t.setAttribute("width",n.w),t.setAttribute("height",n.h)))},getNaturalImageSize:function xn(t){return{w:t.naturalWidth,h:t.naturalHeight}}},ft=(K="function",function(t){return function(t){if(null===t)return"null";var n=typeof t;return"object"===n&&Array.prototype.isPrototypeOf(t)?"array":"object"===n&&String.prototype.isPrototypeOf(t)?"string":n}(t)===K}),st=function(t,n){for(var e=0,r=t.length;e<r;e++){var o=t[e];if(n(o,e,t))return T.some(o)}return T.none()};Array.prototype.slice;ft(Array.from)&&Array.from;var lt=function(t){return null!==t&&t!==undefined},dt=function(t,n){var e;return e=n.reduce(function(t,n){return lt(t)?t[n]:undefined},t),lt(e)?e:null},ht=function(n){return new at(function(e){var t=x();t.onload=function(t){var n=t.target;e(n.result)},t.readAsText(n)})},gt=function(r,o,i){return new at(function(t){var e;(e=function n(){return new(j.getOrDie("XMLHttpRequest"))}()).onreadystatechange=function(){4===e.readyState&&t({status:e.status,blob:this.response})},e.open("GET",r,!0),e.withCredentials=i,u.each(o,function(t,n){e.setRequestHeader(n,t)}),e.responseType="blob",e.send()})},mt=function(t){var n;try{n=JSON.parse(t)}catch(e){}return n},pt=[{code:404,message:"Could not find Image Proxy"},{code:403,message:"Rejected request"},{code:0,message:"Incorrect Image Proxy URL"}],vt=[{type:"key_missing",message:"The request did not include an api key."},{type:"key_not_found",message:"The provided api key could not be found."},{type:"domain_not_trusted",message:"The api key is not valid for the request origins."}],yt=function(n){return"ImageProxy HTTP error: "+st(pt,function(t){return n===t.code}).fold(g("Unknown ImageProxy error"),function(t){return t.message})},bt=function(t){var n=yt(t);return at.reject(n)},wt=function(n){return st(vt,function(t){return t.type===n}).fold(g("Unknown service error"),function(t){return t.message})},It=function(t,n){return ht(n).then(function(t){var n,e,r=(n=mt(t),"ImageProxy Service error: "+((e=dt(n,["error","type"]))?wt(e):"Invalid JSON in service error message"));return at.reject(r)})},Tt=function(t,n){return 400===(e=t)||403===e||500===e?It(0,n):bt(t);var e},Ct=bt,At=function(t,n){var e,r,o,i={"Content-Type":"application/json;charset=UTF-8","tiny-api-key":n};return gt((e=t,r=n,o=-1===e.indexOf("?")?"?":"&",/[?&]apiKey=/.test(e)||!r?e:e+o+"apiKey="+encodeURIComponent(r)),i,!1).then(function(t){return t.status<200||300<=t.status?Tt(t.status,t.blob):at.resolve(t.blob)})},jt=function(t,n,e){return n?At(t,n):function r(t,n){return gt(t,{},n).then(function(t){return t.status<200||300<=t.status?Ct(t.status):at.resolve(t.blob)})}(t,e)},xt=0,_t=function(t){return t.selection.getNode()},Ut=function(t,n){var e=n.src;return 0===e.indexOf("data:")||0===e.indexOf("blob:")||new ut(e).host===t.documentBaseURI.host},Ot=function(t,n){return-1!==u.inArray(t.getParam("imagetools_cors_hosts",[],"string[]"),new ut(n.src).host)},Rt=function(t,n){var e,r,o,i,a=n.src;return Ot(t,n)?jt(n.src,null,(r=t,o=n,-1!==u.inArray(r.getParam("imagetools_credentials_hosts",[],"string[]"),new ut(o.src).host))):Ut(t,n)?L(n):(a=t.getParam("imagetools_proxy"),a+=(-1===a.indexOf("?")?"?":"&")+"url="+encodeURIComponent(n.src),e=(i=t).getParam("api_key",i.getParam("imagetools_api_key","","string"),"string"),jt(a,e,!1))},Bt=function(t){var n;return(n=t.editorUpload.blobCache.getByUri(_t(t).src))?at.resolve(n.blob()):Rt(t,_t(t))},St=function(t){clearTimeout(t.get())},Dt=function(c,f,s,l,d){return f.toBlob().then(function(t){var n,e,r,o,i,a,u;return r=c.editorUpload.blobCache,n=(i=_t(c)).src,c.getParam("images_reuse_filename",!1,"boolean")&&(e=(o=r.getByUri(n))?(n=o.uri(),o.name()):(a=c,(u=n.match(/\/([^\/\?]+)?\.(?:jpeg|jpg|png|gif)(?:\?|$)/i))?a.dom.encode(u[1]):null)),o=r.create({id:"imagetools"+xt++,blob:t,base64:f.toBase64(),uri:n,name:e}),r.add(o),c.undoManager.transact(function(){c.$(i).on("load",function r(){var t,n,e;c.$(i).off("load",r),c.nodeChanged(),s?c.editorUpload.uploadImagesAuto():(St(l),t=c,n=l,e=it.setEditorTimeout(t,function(){t.editorUpload.uploadImagesAuto()},t.getParam("images_upload_timeout",3e4,"number")),n.set(e))}),d&&c.$(i).attr({width:d.w,height:d.h}),c.$(i).attr({src:o.blobUri()}).removeAttr("data-mce-src")}),o})},Et=function(e,n,t,r){return function(){return e._scanForImages().then(s(Bt,e)).then(nt).then(t).then(function(t){return Dt(e,t,!1,n,r)},function(t){var n;n=t,e.notificationManager.open({text:n,type:"error"})})}},Lt=function(e,r,o){return function(){var t=ct.getImageSize(_t(e)),n=t?{w:t.h,h:t.w}:null;return Et(e,r,function(t){return tt(t,o)},n)()}},Mt=function(t,n,e){return function(){return Et(t,n,function(t){return Z(t,e)})()}},Pt=function(t,n){return t.dom.is(n,"img:not([data-mce-object],[data-mce-placeholder])")&&(Ut(t,n)||Ot(t,n)||t.settings.imagetools_proxy)},kt=St,zt=Bt,Ht=_t,Nt=function(n,e,r,o,i){return new at(function(t){E(i).then(function(t){var n=ct.getNaturalImageSize(t);return o.w===n.w&&o.h===n.h||ct.getImageSize(r)&&ct.setImageSize(r,n),ot(t.src),i}).then(nt).then(function(t){return Dt(n,t,!0,e)},function(){})})},Ft=g("save-state"),qt=g("disable"),Gt=g("enable"),Wt=function(a,u){return function(){var r,o=Ht(a),i=ct.getNaturalImageSize(o);zt(a).then(function(t){var n,e={blob:n=t,url:rt(n)};r=a.windowManager.open({title:"Edit Image",size:"large",body:{type:"panel",items:[{type:"imagetools",name:"imagetools",label:"Edit Image",currentState:e}]},buttons:[{type:"submit",name:"save",text:"Save",primary:!0,disabled:!0},{type:"cancel",name:"cancel",text:"Cancel"}],onSubmit:function(t,n){var e=t.getData().imagetools.blob;Nt(a,u,o,i,e),t.close()},onCancel:function(){},onAction:function(t,n){switch(n.name){case Ft():n.value?t.enable("save"):t.disable("save");break;case qt():r.block("Updating image"),t.disable("save"),t.disable("cancel");break;case Gt():r.unblock(),t.enable("cancel")}}})})}},$t=function(e,t){u.each({mceImageRotateLeft:Lt(e,t,-90),mceImageRotateRight:Lt(e,t,90),mceImageFlipVertical:Mt(e,t,"v"),mceImageFlipHorizontal:Mt(e,t,"h"),mceEditImage:Wt(e,t)},function(t,n){e.addCommand(n,t)})},Vt=function(e,r,o){e.on("NodeChange",function(t){var n=o.get();n&&n.src!==t.element.src&&(kt(r),e.editorUpload.uploadImagesAuto(),o.set(null)),Pt(e,t.element)&&o.set(t.element)})},Jt=function(n){var e=function(t){return function(){return n.execCommand(t)}};n.ui.registry.addButton("rotateleft",{tooltip:"Rotate counterclockwise",icon:"rotate-left",onAction:e("mceImageRotateLeft")}),n.ui.registry.addButton("rotateright",{tooltip:"Rotate clockwise",icon:"rotate-right",onAction:e("mceImageRotateRight")}),n.ui.registry.addButton("flipv",{tooltip:"Flip vertically",icon:"flip-vertically",onAction:e("mceImageFlipVertical")}),n.ui.registry.addButton("fliph",{tooltip:"Flip horizontally",icon:"flip-horizontally",onAction:e("mceImageFlipHorizontal")}),n.ui.registry.addButton("editimage",{tooltip:"Edit image",icon:"edit-image",onAction:e("mceEditImage")}),n.ui.registry.addButton("imageoptions",{tooltip:"Image options",icon:"image-options",onAction:e("mceImage")}),n.ui.registry.addContextMenu("imagetools",{update:function(t){return t.src?[{text:"Edit image",icon:"edit-image",onAction:e("mceEditImage")}]:[]}})},Kt=function(t){var n;t.ui.registry.addContextToolbar("imagetools",{items:(n=t,n.getParam("imagetools_toolbar",["rotateleft","rotateright","flipv","fliph","crop","editimage","imageoptions"])),predicate:s(Pt,t),position:"node",scope:"node"})};t.add("imagetools",function(t){var n=r(0),e=r(null);$t(t,n),Jt(t),Kt(t),Vt(t,n,e)}),function _n(){}}(); |