agenda-libre-ruby/public/assets/tinymce/plugins/imagetools/plugin-cde4e862daaa1072a4a548d462ecd155e4c5798ea673bdab3ba4bf6193123257.js

3 lines
37 KiB
JavaScript
Raw Normal View History

2017-10-08 11:38:34 +02:00
!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i<g;++i)h[i]=d(e[i]);var j=f.apply(null,h);if(void 0===j)throw"module ["+b+"] returned undefined";c.instance=j},c=function(b,c,d){if("string"!=typeof b)throw"module id must be a string";if(void 0===c)throw"no dependencies for "+b;if(void 0===d)throw"no definition function for "+b;a[b]={deps:c,defn:d,instance:void 0}},d=function(c){var d=a[c];if(void 0===d)throw"module ["+c+"] was undefined";return void 0===d.instance&&b(c),d.instance},e=function(a,b){for(var c=a.length,e=new Array(c),f=0;f<c;++f)e.push(d(a[f]));b.apply(null,b)},f={};f.bolt={module:{api:{define:c,require:e,demand:d}}};var g=c,h=function(a,b){g(a,[],function(){return b})};g("o",[],function(){function a(a,b){return function(){a.apply(b,arguments)}}function b(b){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof b)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],h(b,a(d,this),a(e,this))}function c(a){var b=this;return null===this._state?void this._deferreds.push(a):void i(function(){var c=b._state?a.onFulfilled:a.onRejected;if(null===c)return void(b._state?a.resolve:a.reject)(b._value);var d;try{d=c(b._value)}catch(b){return void a.reject(b)}a.resolve(d)})}function d(b){try{if(b===this)throw new TypeError("A promise cannot be resolved with itself.");if(b&&("object"==typeof b||"function"==typeof b)){var c=b.then;if("function"==typeof c)return void h(a(c,b),a(d,this),a(e,this))}this._state=!0,this._value=b,f.call(this)}catch(a){e.call(this,a)}}function e(a){this._state=!1,this._value=a,f.call(this)}function f(){for(var a=0,b=this._deferreds.length;a<b;a++)c.call(this,this._deferreds[a]);this._deferreds=null}function g(a,b,c,d){this.onFulfilled="function"==typeof a?a:null,this.onRejected="function"==typeof b?b:null,this.resolve=c,this.reject=d}function h(a,b,c){var d=!1;try{a(function(a){d||(d=!0,b(a))},function(a){d||(d=!0,c(a))})}catch(a){if(d)return;d=!0,c(a)}}if(window.Promise)return window.Promise;var i=b.immediateFn||"function"==typeof setImmediate&&setImmediate||function(a){setTimeout(a,1)},j=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)};return b.prototype["catch"]=function(a){return this.then(null,a)},b.prototype.then=function(a,d){var e=this;return new b(function(b,f){c.call(e,new g(a,d,b,f))})},b.all=function(){var a=Array.prototype.slice.call(1===arguments.length&&j(arguments[0])?arguments[0]:arguments);return new b(function(b,c){function d(f,g){try{if(g&&("object"==typeof g||"function"==typeof g)){var h=g.then;if("function"==typeof h)return void h.call(g,function(a){d(f,a)},c)}a[f]=g,0===--e&&b(a)}catch(a){c(a)}}if(0===a.length)return b([]);for(var e=a.length,f=0;f<a.length;f++)d(f,a[f])})},b.resolve=function(a){return a&&"object"==typeof a&&a.constructor===b?a:new b(function(b){b(a)})},b.reject=function(a){return new b(function(b,c){c(a)})},b.race=function(a){return new b(function(b,c){for(var d=0,e=a.length;d<e;d++)a[d].then(b,c)})},b}),g("p",[],function(){function a(a,b){return e(document.createElement("canvas"),a,b)}function b(b){var d,e;return d=a(b.width,b.height),e=c(d),e.drawImage(b,0,0),d}function c(a){return a.getContext("2d")}function d(a){var b=null;try{b=a.getContext("webgl")||a.getContext("experimental-webgl")}catch(a){}return b||(b=null),b}function e(a,b,c){return a.width=b,a.height=c,a}return{create:a,clone:b,resize:e,get2dContext:c,get3dContext:d}}),g("q",[],function(){function a(a){var b=document.createElement("a");return b.href=a,b.pathname}function b(b){var c,d,e,f;return 0===b.indexOf("data:")?(b=b.split(","),f=/data:([^;]+)/.exec(b[0]),f?f[1]:""):(e={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png"},c=a(b).split("."),d=c[c.length-1],d&&(d=d.toLowerCase()),e[d])}return{guessMimeType:b}}),g("r",[],function(){function a(a){return a.naturalWidth||a.width}function b(a){return a.naturalHeight||a.height}return{getWidth:a,getHeight:b}}),g("c",["o","p","q","r"],function(a,b,c,d){function e(b){return n
a.preventDefault(),z(b.resize,c,d)(),A()}).on("show",s),T=I([{text:"Back",onclick:A},{type:"spacer",flex:1},{icon:"fliph",tooltip:"Flip horizontally",onclick:y(b.flip,"h")},{icon:"flipv",tooltip:"Flip vertically",onclick:y(b.flip,"v")},{icon:"rotateleft",tooltip:"Rotate counterclockwise",onclick:y(b.rotate,-90)},{icon:"rotateright",tooltip:"Rotate clockwise",onclick:y(b.rotate,90)},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:C}]).hide().on("show",s),X=J("Invert",b.invert),da=J("Sharpen",b.sharpen),ea=J("Emboss",b.emboss),Y=K("Brightness",b.brightness,0,-1,1),Z=K("Hue",b.hue,180,0,360),$=K("Saturate",b.saturate,0,-1,1),_=K("Contrast",b.contrast,0,-1,1),aa=K("Grayscale",b.grayscale,0,0,1),ba=K("Sepia",b.sepia,0,0,1),ca=L("Colorize",b.colorize),fa=K("Gamma",b.gamma,0,-1,1),ga=K("Exposure",b.exposure,1,0,2),P=I([{text:"Back",onclick:A},{type:"spacer",flex:1},{text:"hue",icon:"hue",onclick:u(Z)},{text:"saturate",icon:"saturate",onclick:u($)},{text:"sepia",icon:"sepia",onclick:u(ba)},{text:"emboss",icon:"emboss",onclick:u(ea)},{text:"exposure",icon:"exposure",onclick:u(ga)},{type:"spacer",flex:1}]).hide(),O=I([{tooltip:"Crop",icon:"crop",onclick:u(R)},{tooltip:"Resize",icon:"resize2",onclick:u(S)},{tooltip:"Orientation",icon:"orientation",onclick:u(T)},{tooltip:"Brightness",icon:"sun",onclick:u(Y)},{tooltip:"Sharpen",icon:"sharpen",onclick:u(da)},{tooltip:"Contrast",icon:"contrast",onclick:u(_)},{tooltip:"Color levels",icon:"drop",onclick:u(ca)},{tooltip:"Gamma",icon:"gamma",onclick:u(fa)},{tooltip:"Invert",icon:"invert",onclick:u(X)}]),U=i.create({flex:1,imageSrc:m.url}),V=e.create("Container",{layout:"flex",direction:"column",border:"0 1 0 0",padding:5,spacing:5,items:[{type:"button",icon:"undo",tooltip:"Undo",name:"undo",onclick:F},{type:"button",icon:"redo",tooltip:"Redo",name:"redo",onclick:G},{type:"button",icon:"zoomin",tooltip:"Zoom in",onclick:D},{type:"button",icon:"zoomout",tooltip:"Zoom out",onclick:E}]}),W=e.create("Container",{type:"container",layout:"flex",direction:"row",align:"stretch",flex:1,items:[V,U]}),ha=[O,R,S,T,P,X,Y,Z,$,_,aa,ba,ca,da,ea,fa,ga],N=f.windowManager.open({layout:"flex",direction:"column",align:"stretch",minWidth:c.min(d.DOM.getViewPort().w,800),minHeight:c.min(d.DOM.getViewPort().h,650),title:"Edit image",items:ha.concat([W]),buttons:[{text:"Save",name:"save",subtype:"primary",onclick:H},{text:"Cancel",onclick:"close"}]}),N.on("close",function(){o(),l(ma.data),ma=null,Q=null}),ma.add(m),r(),U.on("load",function(){ia=U.imageSize().w,ja=U.imageSize().h,ka=ja/ia,la=ia/ja,N.find("#w").value(ia),N.find("#h").value(ja)}),U.on("crop",x)}function n(a,b){return new f(function(c,d){return b.toBlob().then(function(b){m(a,j(b),c,d)})})}return{edit:n}}),g("0",["1","2","3","4","5","6","7","8","9","a","b"],function(a,b,c,d,e,f,g,h,i,j,k){var l=function(d){function l(a){d.notificationManager.open({text:a,type:"error"})}function m(){return d.selection.getNode()}function n(a){var b=a.match(/\/([^\/\?]+)?\.(?:jpeg|jpg|png|gif)(?:\?|$)/i);return b?d.dom.encode(b[1]):null}function o(){return"imagetools"+H++}function p(a){var b=a.src;return 0===b.indexOf("data:")||0===b.indexOf("blob:")||new h(b).host===d.documentBaseURI.host}function q(a){return g.inArray(d.settings.imagetools_cors_hosts,new h(a.src).host)!==-1}function r(){return d.settings.api_key||d.settings.imagetools_api_key}function s(b){var c,e=b.src;return q(b)?j.getUrl(b.src,null):p(b)?a.imageToBlob(b):(e=d.settings.imagetools_proxy,e+=(e.indexOf("?")===-1?"?":"&")+"url="+encodeURIComponent(b.src),c=r(),j.getUrl(e,c))}function t(){var a;return a=d.editorUpload.blobCache.getByUri(m().src),a?f.resolve(a.blob()):s(m())}function u(){F=e.setEditorTimeout(d,function(){d.editorUpload.uploadImagesAuto()},d.settings.images_upload_timeout||3e4)}function v(){clearTimeout(F)}function w(a,b){return a.toBlob().then(function(c){var e,f,g,h,i;return g=d.editorUpload.blobCache,i=m(),e=i.src,d.settings.images_reuse_filename&&(h=g.getByUri(e),h?(e=h.uri(),f=h.name()):f=n(e)),h=g.create({id:o(),blob:c,base64:a.toBase64(),uri:e,name:f}),g.add(h),d.undoM