1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00
invoiceninja/public/js/jSignature.min.js

3 lines
22 KiB
JavaScript
Raw Normal View History

2016-11-04 14:34:15 +01:00
!function(){function t(t){var n,e,i=t.css("color");t=t[0];for(var s=!1;t&&!e&&!s;){try{n=$(t).css("background-color")}catch(r){n="transparent"}"transparent"!==n&&"rgba(0, 0, 0, 0)"!==n&&(e=n),s=t.body,t=t.parentNode}t=/rgb[a]*\((\d+),\s*(\d+),\s*(\d+)/;var o,s=/#([AaBbCcDdEeFf\d]{2})([AaBbCcDdEeFf\d]{2})([AaBbCcDdEeFf\d]{2})/;n=void 0,(n=i.match(t))?o={r:parseInt(n[1],10),g:parseInt(n[2],10),b:parseInt(n[3],10)}:(n=i.match(s))&&(o={r:parseInt(n[1],16),g:parseInt(n[2],16),b:parseInt(n[3],16)});var a;return e?(n=void 0,(n=e.match(t))?a={r:parseInt(n[1],10),g:parseInt(n[2],10),b:parseInt(n[3],10)}:(n=e.match(s))&&(a={r:parseInt(n[1],16),g:parseInt(n[2],16),b:parseInt(n[3],16)})):a=o&&127<Math.max.apply(null,[o.r,o.g,o.b])?{r:0,g:0,b:0}:{r:255,g:255,b:255},n=function(t){return"rgb("+[t.r,t.g,t.b].join(", ")+")"},o&&a?(t=Math.max.apply(null,[o.r,o.g,o.b]),o=Math.max.apply(null,[a.r,a.g,a.b]),o=Math.round(o+-.75*(o-t)),o={r:o,g:o,b:o}):o?(o=Math.max.apply(null,[o.r,o.g,o.b]),t=1,127<o&&(t=-1),o=Math.round(o+96*t),o={r:o,g:o,b:o}):o={r:191,g:191,b:191},{color:i,"background-color":a?n(a):e,"decor-color":n(o)}}function n(t,n){this.x=t,this.y=n,this.reverse=function(){return new this.constructor(-1*this.x,-1*this.y)},this._length=null,this.getLength=function(){return this._length||(this._length=Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))),this._length};var e=function(t){return Math.round(t/Math.abs(t))};this.resizeTo=function(t){if(0===this.x&&0===this.y)this._length=0;else if(0===this.x)this._length=t,this.y=t*e(this.y);else if(0===this.y)this._length=t,this.x=t*e(this.x);else{var n=Math.abs(this.y/this.x),i=Math.sqrt(Math.pow(t,2)/(1+Math.pow(n,2))),n=n*i;this._length=t,this.x=i*e(this.x),this.y=n*e(this.y)}return this},this.angleTo=function(t){var n=this.getLength()*t.getLength();return 0===n?0:Math.acos(Math.min(Math.max((this.x*t.x+this.y*t.y)/n,-1),1))/Math.PI}}function e(t,e){this.x=t,this.y=e,this.getVectorToCoordinates=function(t,e){return new n(t-this.x,e-this.y)},this.getVectorFromCoordinates=function(t,n){return this.getVectorToCoordinates(t,n).reverse()},this.getVectorToPoint=function(t){return new n(t.x-this.x,t.y-this.y)},this.getVectorFromPoint=function(t){return this.getVectorToPoint(t).reverse()}}function i(t,n,e,i,s){if(this.data=t,this.context=n,t.length)for(var r,o,a=t.length,h=0;h<a;h++){r=t[h],o=r.x.length,e.call(n,r);for(var u=1;u<o;u++)i.call(n,r,u);s.call(n,r)}this.changed=function(){},this.startStrokeFn=e,this.addToStrokeFn=i,this.endStrokeFn=s,this.inStroke=!1,this._stroke=this._lastPoint=null,this.startStroke=function(t){if(t&&"number"==typeof t.x&&"number"==typeof t.y){this._stroke={x:[t.x],y:[t.y]},this.data.push(this._stroke),this._lastPoint=t,this.inStroke=!0;var n=this._stroke,e=this.startStrokeFn,i=this.context;return setTimeout(function(){e.call(i,n)},3),t}return null},this.addToStroke=function(t){if(this.inStroke&&"number"==typeof t.x&&"number"==typeof t.y&&4<Math.abs(t.x-this._lastPoint.x)+Math.abs(t.y-this._lastPoint.y)){var n=this._stroke.x.length;this._stroke.x.push(t.x),this._stroke.y.push(t.y),this._lastPoint=t;var e=this._stroke,i=this.addToStrokeFn,s=this.context;return setTimeout(function(){i.call(s,e,n)},3),t}return null},this.endStroke=function(){var t=this.inStroke;if(this.inStroke=!1,this._lastPoint=null,t){var n=this._stroke,e=this.endStrokeFn,i=this.context,s=this.changed;return setTimeout(function(){e.call(i,n),s.call(i)},3),!0}return null}}function s(t,n,e,i){"ratio"!==n&&"%"!==n.split("")[n.length-1]||(this.eventTokens[e+".parentresized"]=i.subscribe(e+".parentresized",function(n,s,r,o){return function(){var o=s.width();if(o!==r){for(var a in n)n.hasOwnProperty(a)&&(i.unsubscribe(n[a]),delete n[a]);var h=t.settings;t.$parent.children().remove();for(a in t)t.hasOwnProperty(a)&&delete t[a];a=h.data;var u,c,l,d,g,f,o=1*o/r,p=[];for(c=0,l=a.length;c<l;c++){for(f=a[c],u={x:[],y:[]},d=0,g=f.x.length;d<g;d++)u.x.push(f.x[d]*o),u.y.push(f.y[d]*o);p.push(u)}h.data=p,s[e](h)}}}(this.eventTokens,this.$parent,this.$parent.width(),1*this.canvas.width/this.canvas.height)))}function r(
//# sourceMappingURL=jSignature.min.js.map