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

3 lines
37 KiB
JavaScript
Raw Normal View History

!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("p",[],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("q",[],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("r",[],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("s",[],function(){function a(a){return a.naturalWidth||a.width}function b(a){return a.naturalHeight||a.height}return{getWidth:a,getHeight:b}}),g("c",["p","q","r","s"],function(a,b,c,d){function e(b){return n
onclick:"submit"}]).hide().on("submit",function(a){var c=parseInt(O.find("#w").value(),10),d=parseInt(O.find("#h").value(),10);a.preventDefault(),A(b.resize,c,d)(),B()}).on("show",t),U=J([{text:"Back",onclick:B},{type:"spacer",flex:1},{icon:"fliph",tooltip:"Flip horizontally",onclick:z(b.flip,"h")},{icon:"flipv",tooltip:"Flip vertically",onclick:z(b.flip,"v")},{icon:"rotateleft",tooltip:"Rotate counterclockwise",onclick:z(b.rotate,-90)},{icon:"rotateright",tooltip:"Rotate clockwise",onclick:z(b.rotate,90)},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:D}]).hide().on("show",t),Y=K("Invert",b.invert),ea=K("Sharpen",b.sharpen),fa=K("Emboss",b.emboss),Z=L("Brightness",b.brightness,0,-1,1),$=L("Hue",b.hue,180,0,360),_=L("Saturate",b.saturate,0,-1,1),aa=L("Contrast",b.contrast,0,-1,1),ba=L("Grayscale",b.grayscale,0,0,1),ca=L("Sepia",b.sepia,0,0,1),da=M("Colorize",b.colorize),ga=L("Gamma",b.gamma,0,-1,1),ha=L("Exposure",b.exposure,1,0,2),Q=J([{text:"Back",onclick:B},{type:"spacer",flex:1},{text:"hue",icon:"hue",onclick:v($)},{text:"saturate",icon:"saturate",onclick:v(_)},{text:"sepia",icon:"sepia",onclick:v(ca)},{text:"emboss",icon:"emboss",onclick:v(fa)},{text:"exposure",icon:"exposure",onclick:v(ha)},{type:"spacer",flex:1}]).hide(),P=J([{tooltip:"Crop",icon:"crop",onclick:v(S)},{tooltip:"Resize",icon:"resize2",onclick:v(T)},{tooltip:"Orientation",icon:"orientation",onclick:v(U)},{tooltip:"Brightness",icon:"sun",onclick:v(Z)},{tooltip:"Sharpen",icon:"sharpen",onclick:v(ea)},{tooltip:"Contrast",icon:"contrast",onclick:v(aa)},{tooltip:"Color levels",icon:"drop",onclick:v(da)},{tooltip:"Gamma",icon:"gamma",onclick:v(ga)},{tooltip:"Invert",icon:"invert",onclick:v(Y)}]),V=new h({flex:1,imageSrc:n.url}),W=new d({layout:"flex",direction:"column",border:"0 1 0 0",padding:5,spacing:5,items:[{type:"button",icon:"undo",tooltip:"Undo",name:"undo",onclick:G},{type:"button",icon:"redo",tooltip:"Redo",name:"redo",onclick:H},{type:"button",icon:"zoomin",tooltip:"Zoom in",onclick:E},{type:"button",icon:"zoomout",tooltip:"Zoom out",onclick:F}]}),X=new d({type:"container",layout:"flex",direction:"row",align:"stretch",flex:1,items:[W,V]}),ia=[P,S,T,U,Q,Y,Z,$,_,aa,ba,ca,da,ea,fa,ga,ha],O=f.windowManager.open({layout:"flex",direction:"column",align:"stretch",minWidth:j.min(c.DOM.getViewPort().w,800),minHeight:j.min(c.DOM.getViewPort().h,650),title:"Edit image",items:ia.concat([X]),buttons:[{text:"Save",name:"save",subtype:"primary",onclick:I},{text:"Cancel",onclick:"close"}]}),O.on("close",function(){p(),m(na.data),na=null,R=null}),na.add(n),s(),V.on("load",function(){ja=V.imageSize().w,ka=V.imageSize().h,la=ka/ja,ma=ja/ka,O.find("#w").value(ja),O.find("#h").value(ka)}),V.on("crop",y)}function o(a,b){return new f(function(c,d){return b.toBlob().then(function(b){n(a,k(b),c,d)})})}return{edit:o}}),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(),