1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-21 06:09:42 +02:00
documize/gui/public/tinymce/plugins/imagetools/plugin.min.js

1 line
35 KiB
JavaScript
Raw Normal View History

2018-01-19 11:36:38 +00:00
!function(){"use strict";function t(t,e){return n(document.createElement("canvas"),t,e)}function e(t){return t.getContext("2d")}function n(t,e,n){return t.width=e,t.height=n,t}function o(t){return new U(function(e,n){function o(){u(),e(a)}function r(){u(),n("Unable to load data of type "+t.type+": "+i)}var i=URL.createObjectURL(t),a=new Image,u=function(){a.removeEventListener("load",o),a.removeEventListener("error",r)};a.addEventListener("load",o),a.addEventListener("error",r),a.src=i,a.complete&&o()})}function r(t){return new U(function(e){var n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType="blob",n.onload=function(){200==this.status&&e(this.response)},n.send()})}function i(t){var e=t.split(","),n=/data:([^;]+)/.exec(e[0]);if(!n)return H.none();for(var o=n[1],r=e[1],i=V.atob(r),a=i.length,u=Math.ceil(a/1024),c=new Array(u),l=0;l<u;++l){for(var s=1024*l,f=Math.min(s+1024,a),d=new Array(f-s),h=s,p=0;h<f;++p,++h)d[p]=i[h].charCodeAt(0);c[l]=q(d)}return H.some(P(c,{type:o}))}function a(t){return new U(function(e,n){i(t).fold(function(){n("uri is not base64: "+t)},e)})}function u(t){return new U(function(e){var n=new W;n.onloadend=function(){e(n.result)},n.readAsDataURL(t)})}function c(t,e,n){function o(e,n){return t.then(function(t){return N.canvasToDataURL(t,e,n)})}var r=e.type;return{getType:j.constant(r),toBlob:function(){return U.resolve(e)},toDataURL:function(){return n},toBase64:function(){return n.split(",")[1]},toAdjustedBlob:function(e,n){return t.then(function(t){return N.canvasToBlob(t,e,n)})},toAdjustedDataURL:o,toAdjustedBase64:function(t,e){return o(t,e).then(function(t){return t.split(",")[1]})},toCanvas:function(){return t.then(C.clone)}}}function l(t){return N.blobToDataUri(t).then(function(e){return c(N.blobToCanvas(t),t,e)})}function s(t,e,n){return(t=parseFloat(t))>n?t=n:t<e&&(t=e),t}function f(t,e){var n,o,r,i,a=[],u=new Array(10);for(n=0;n<5;n++){for(o=0;o<5;o++)a[o]=e[o+5*n];for(o=0;o<5;o++){for(i=0,r=0;r<5;r++)i+=t[o+5*r]*a[r];u[o+5*n]=i}}return u}function d(t,e){return e=s(e,0,1),t.map(function(t,n){return n%6==0?t=1-(1-t)*e:t*=e,s(t,0,1)})}function h(t,e){return t.toCanvas().then(function(n){return function(t,e,n){var o,r=C.get2dContext(t);return o=function(t,e){var n,o,r,i,a,u=t.data,c=e[0],l=e[1],s=e[2],f=e[3],d=e[4],h=e[5],p=e[6],m=e[7],g=e[8],v=e[9],y=e[10],b=e[11],w=e[12],x=e[13],R=e[14],I=e[15],T=e[16],k=e[17],C=e[18],B=e[19];for(a=0;a<u.length;a+=4)n=u[a],o=u[a+1],r=u[a+2],i=u[a+3],u[a]=n*c+o*l+r*s+i*f+d,u[a+1]=n*h+o*p+r*m+i*g+v,u[a+2]=n*y+o*b+r*w+i*x+R,u[a+3]=n*I+o*T+r*k+i*C+B;return t}(r.getImageData(0,0,t.width,t.height),n),r.putImageData(o,0,0),G.fromCanvas(t,e)}(n,t.getType(),e)})}function p(t,e){return t.toCanvas().then(function(n){return function(t,e,n){var o,r,i=C.get2dContext(t);return o=i.getImageData(0,0,t.width,t.height),r=i.getImageData(0,0,t.width,t.height),r=function(t,e,n){function o(t,e,n){return t>n?t=n:t<e&&(t=e),t}var r,i,a,u,c,l,s,f,d,h,p,m,g,v,y,b,w;for(a=Math.round(Math.sqrt(n.length)),u=Math.floor(a/2),r=t.data,i=e.data,b=t.width,w=t.height,l=0;l<w;l++)for(c=0;c<b;c++){for(s=f=d=0,p=0;p<a;p++)for(h=0;h<a;h++)m=o(c+h-u,0,b-1),g=o(l+p-u,0,w-1),v=4*(g*b+m),y=n[p*a+h],s+=r[v]*y,f+=r[v+1]*y,d+=r[v+2]*y;i[v=4*(l*b+c)]=o(s,0,255),i[v+1]=o(f,0,255),i[v+2]=o(d,0,255)}return e}(o,r,n),i.putImageData(r,0,0),G.fromCanvas(t,e)}(n,t.getType(),e)})}function m(t){return function(e,n){return e.toCanvas().then(function(o){return function(e,n,o){var r,i,a=C.get2dContext(e),u=new Array(256);for(i=0;i<u.length;i++)u[i]=t(i,o);return r=function(t,e){var n,o=t.data;for(n=0;n<o.length;n+=4)o[n]=e[o[n]],o[n+1]=e[o[n+1]],o[n+2]=e[o[n+2]];return t}(a.getImageData(0,0,e.width,e.height),u),a.putImageData(r,0,0),G.fromCanvas(e,n)}(o,e.getType(),n)})}}function g(t){return function(e,n){return h(e,t(J.identity(),n))}}function v(t){return function(e){return p(e,t)}}function y(t,e,n){var o=B.getWidth(t),r=B.getHeight(t),i=e/o,a=n/r,u=!1;(i<.5||i>2)&&(i=i<.5?.5:2,u=!0),(a<.5||a>2)&&(a=a<.5?.5:2,u=!0);var c=function(t,e,n){return new U(function(o){var r=B.getWidth(t),i=B.getHeight(t),a=Math.flo