PHP Classes

File: jSignature.min.js

Recommend this page to a friend!
  Classes of Gianluca Zanferrari   Sign on display   jSignature.min.js   Download  
File: jSignature.min.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Sign on display
Insert a captured person signature in a PDF file
Author: By
Last change: Update of jSignature.min.js
Date: 9 months ago
Size: 21,950 bytes
 

Contents

Class file image Download
/* jSignature v2 Copyright (c) 2012 Willow Systems Corp http://willow-systems.com Copyright (c) 2010 Brinley Ang http://www.unbolt.net MIT License <http://www.opensource.org/licenses/mit-license.php> jSignature v2 jSignature's Undo Button and undo functionality plugin Copyright (c) 2011 Willow Systems Corp http://willow-systems.com MIT License <http://www.opensource.org/licenses/mit-license.php> jSignature v2 jSignature's custom "base30" format export and import plugins. Copyright (c) 2011 Willow Systems Corp http://willow-systems.com MIT License <http://www.opensource.org/licenses/mit-license.php> Simplify.js BSD (c) 2012, Vladimir Agafonkin mourner.github.com/simplify-js base64 encoder MIT, GPL http://phpjs.org/functions/base64_encode + original by: Tyler Akins (http://rumkin.com) + improved by: Bayron Guevara + improved by: Thunder.m + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + bugfixed by: Pellentesque Malesuada + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + improved by: Rafal Kukawski (http://kukawski.pl) jSignature v2 SVG export plugin. Copyright (c) 2012 Willow Systems Corp http://willow-systems.com MIT License <http://www.opensource.org/licenses/mit-license.php> */ (function(){function r(a){for(var f,o=a.css("color"),x,a=a[0],c=!1;a&&!x&&!c;){try{f=$(a).css("background-color")}catch(g){f="transparent"}"transparent"!==f&&"rgba(0, 0, 0, 0)"!==f&&(x=f);c=a.body;a=a.parentNode}var a=/rgb[a]*\((\d+),\s*(\d+),\s*(\d+)/,c=/#([AaBbCcDdEeFf\d]{2})([AaBbCcDdEeFf\d]{2})([AaBbCcDdEeFf\d]{2})/,b;f=void 0;(f=o.match(a))?b={r:parseInt(f[1],10),g:parseInt(f[2],10),b:parseInt(f[3],10)}:(f=o.match(c))&&(b={r:parseInt(f[1],16),g:parseInt(f[2],16),b:parseInt(f[3],16)});var d;x? (f=void 0,(f=x.match(a))?d={r:parseInt(f[1],10),g:parseInt(f[2],10),b:parseInt(f[3],10)}:(f=x.match(c))&&(d={r:parseInt(f[1],16),g:parseInt(f[2],16),b:parseInt(f[3],16)})):d=b?127<Math.max.apply(null,[b.r,b.g,b.b])?{r:0,g:0,b:0}:{r:255,g:255,b:255}:{r:255,g:255,b:255};f=function(a){return"rgb("+[a.r,a.g,a.b].join(", ")+")"};b&&d?(a=Math.max.apply(null,[b.r,b.g,b.b]),b=Math.max.apply(null,[d.r,d.g,d.b]),b=Math.round(b+-0.75*(b-a)),b={r:b,g:b,b:b}):b?(b=Math.max.apply(null,[b.r,b.g,b.b]),a=1,127<b&& (a=-1),b=Math.round(b+96*a),b={r:b,g:b,b:b}):b={r:191,g:191,b:191};return{color:o,"background-color":d?f(d):x,"decor-color":f(b)}}function m(a,f){this.x=a;this.y=f;this.reverse=function(){return new this.constructor(-1*this.x,-1*this.y)};this._length=null;this.getLength=function(){this._length||(this._length=Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2)));return this._length};var o=function(a){return Math.round(a/Math.abs(a))};this.resizeTo=function(a){if(0===this.x&&0===this.y)this._length=0;else if(0=== this.x)this._length=a,this.y=a*o(this.y);else if(0===this.y)this._length=a,this.x=a*o(this.x);else{var f=Math.abs(this.y/this.x),b=Math.sqrt(Math.pow(a,2)/(1+Math.pow(f,2))),f=f*b;this._length=a;this.x=b*o(this.x);this.y=f*o(this.y)}return this};this.angleTo=function(a){var f=this.getLength()*a.getLength();return 0===f?0:Math.acos(Math.min(Math.max((this.x*a.x+this.y*a.y)/f,-1),1))/Math.PI}}function h(a,f){this.x=a;this.y=f;this.getVectorToCoordinates=function(a,f){return new m(a-this.x,f-this.y)}; this.getVectorFromCoordinates=function(a,f){return this.getVectorToCoordinates(a,f).reverse()};this.getVectorToPoint=function(a){return new m(a.x-this.x,a.y-this.y)};this.getVectorFromPoint=function(a){return this.getVectorToPoint(a).reverse()}}function s(a,f,b,c,g){this.data=a;this.context=f;if(a.length)for(var d=a.length,j,i,e=0;e<d;e++){j=a[e];i=j.x.length;b.call(f,j);for(var h=1;h<i;h++)c.call(f,j,h);g.call(f,j)}this.changed=function(){};this.startStrokeFn=b;this.addToStrokeFn=c;this.endStrokeFn= g;this.inStroke=!1;this._stroke=this._lastPoint=null;this.startStroke=function(a){if(a&&"number"==typeof a.x&&"number"==typeof a.y){this._stroke={x:[a.x],y:[a.y]};this.data.push(this._stroke);this._lastPoint=a;this.inStroke=!0;var f=this._stroke,b=this.startStrokeFn,o=this.context;setTimeout(function(){b.call(o,f)},3);return a}return null};this.addToStroke=function(a){if(this.inStroke&&"number"===typeof a.x&&"number"===typeof a.y&&4<Math.abs(a.x-this._lastPoint.x)+Math.abs(a.y-this._lastPoint.y)){var f= this._stroke.x.length;this._stroke.x.push(a.x);this._stroke.y.push(a.y);this._lastPoint=a;var b=this._stroke,o=this.addToStrokeFn,c=this.context;setTimeout(function(){o.call(c,b,f)},3);return a}return null};this.endStroke=function(){var a=this.inStroke;this.inStroke=!1;this._lastPoint=null;if(a){var f=this._stroke,b=this.endStrokeFn,o=this.context,c=this.changed;setTimeout(function(){b.call(o,f);c.call(o)},3);return!0}return null}}function p(a,f,b){var c=this.$parent=$(a),a=this.eventTokens={};this.events= new t(this);var g=$.fn[e]("globalEvents"),d={width:"ratio",height:"ratio",sizeRatio:4,color:"#000","background-color":"#fff","decor-color":"#eee",lineWidth:0,minFatFingerCompensation:-10,showUndoButton:!1,data:[]};$.extend(d,r(c));f&&$.extend(d,f);this.settings=d;for(var j in b)b.hasOwnProperty(j)&&b[j].call(this,j);this.events.publish(e+".initializing");this.$controlbarUpper=$('<div style="padding:0 !important;margin:0 !important;width: 100% !important; height: 0 !important;margin-top:-1em !important;margin-bottom:1em !important;"></div>').appendTo(c); this.isCanvasEmulator=!1;b=this.canvas=this.initializeCanvas(d);f=$(b);this.$controlbarLower=$('<div style="padding:0 !important;margin:0 !important;width: 100% !important; height: 0 !important;margin-top:-1.5em !important;margin-bottom:1.5em !important;"></div>').appendTo(c);this.canvasContext=b.getContext("2d");f.data(e+".this",this);c=(c=d.lineWidth)?c:Math.max(Math.round(b.width/400),2);d.lineWidth=c;this.lineCurveThreshold=3*d.lineWidth;d.cssclass&&""!=$.trim(d.cssclass)&&f.addClass(d.cssclass); this.fatFingerCompensation=0;var c=function(a){var f,b,c=function(c){c=c.changedTouches&&0<c.changedTouches.length?c.changedTouches[0]:c;return new h(Math.round(c.pageX+f),Math.round(c.pageY+b)+a.fatFingerCompensation)},o=new y(750,function(){a.dataEngine.endStroke()});this.drawEndHandler=function(f){try{f.preventDefault()}catch(b){}o.clear();a.dataEngine.endStroke()};this.drawStartHandler=function(d){d.preventDefault();var g=$(a.canvas).offset();f=-1*g.left;b=-1*g.top;a.dataEngine.startStroke(c(d)); o.kick()};this.drawMoveHandler=function(f){f.preventDefault();a.dataEngine.inStroke&&(a.dataEngine.addToStroke(c(f)),o.kick())};return this}.call({},this),i=c.drawEndHandler,k=c.drawStartHandler,l=c.drawMoveHandler,n=this.canvas,f=$(n);this.isCanvasEmulator?(f.bind("mousemove."+e,l),f.bind("mouseup."+e,i),f.bind("mousedown."+e,k)):(n.ontouchstart=function(a){n.onmousedown=void 0;n.onmouseup=void 0;n.onmousemove=void 0;this.fatFingerCompensation=d.minFatFingerCompensation&&-3*d.lineWidth>d.minFatFingerCompensation? -3*d.lineWidth:d.minFatFingerCompensation;k(a);n.ontouchend=i;n.ontouchstart=k;n.ontouchmove=l},n.onmousedown=function(a){n.ontouchstart=void 0;n.ontouchend=void 0;n.ontouchmove=void 0;k(a);n.onmousedown=k;n.onmouseup=i;n.onmousemove=l});a[e+".windowmouseup"]=g.subscribe(e+".windowmouseup",c.drawEndHandler);this.events.publish(e+".attachingEventHandlers");var q=this,a=d.width.toString(10),w=e;if("ratio"===a||"%"===a.split("")[a.length-1])this.eventTokens[w+".parentresized"]=g.subscribe(w+".parentresized", function(a,f,b){return function(){var c=f.width();if(c!==b){for(var o in a)if(a.hasOwnProperty(o)){g.unsubscribe(a[o]);delete a[o]}var d=q.settings;q.$parent.children().remove();for(o in q)q.hasOwnProperty(o)&&delete q[o];o=d.data;var c=c*1/b,x=[],j,i,e,k,h,n;i=0;for(e=o.length;i<e;i++){n=o[i];j={x:[],y:[]};k=0;for(h=n.x.length;k<h;k++){j.x.push(n.x[k]*c);j.y.push(n.y[k]*c)}x.push(j)}d.data=x;f[w](d)}}}(this.eventTokens,this.$parent,this.$parent.width(),1*this.canvas.width/this.canvas.height));this.resetCanvas(d.data); this.events.publish(e+".initialized");return this}var e="jSignature",y=function(a,f){var b;this.kick=function(){clearTimeout(b);b=setTimeout(f,a)};this.clear=function(){clearTimeout(b)};return this},t=function(a){this.topics={};this.context=a?a:this;this.publish=function(a,b,c,d){if(this.topics[a]){var g=this.topics[a],j=Array.prototype.slice.call(arguments,1),i=[],k,e,h,n;e=0;for(h=g.length;e<h;e++)n=g[e],k=n[0],n[1]&&(n[0]=function(){},i.push(e)),k.apply(this.context,j);e=0;for(h=i.length;e<h;e++)g.splice(i[e], 1)}};this.subscribe=function(a,b,c){this.topics[a]?this.topics[a].push([b,c]):this.topics[a]=[[b,c]];return{topic:a,callback:b}};this.unsubscribe=function(a){if(this.topics[a.topic])for(var b=this.topics[a.topic],c=0,d=b.length;c<d;c++)b[c][0]===a.callback&&b.splice(c,1)}},z=function(a){var f=this.canvasContext,b=a.x[0],a=a.y[0],c=this.settings.lineWidth,d=f.fillStyle;f.fillStyle=f.strokeStyle;f.fillRect(b+c/-2,a+c/-2,c,c);f.fillStyle=d},u=function(a,f){var b=new h(a.x[f-1],a.y[f-1]),c=new h(a.x[f], a.y[f]),d=b.getVectorToPoint(c);if(1<f){var g=new h(a.x[f-2],a.y[f-2]),j=g.getVectorToPoint(b),i;if(j.getLength()>this.lineCurveThreshold){i=2<f?(new h(a.x[f-3],a.y[f-3])).getVectorToPoint(g):new m(0,0);var e=0.35*j.getLength(),k=j.angleTo(i.reverse()),n=d.angleTo(j.reverse());i=(new m(i.x+j.x,i.y+j.y)).resizeTo(Math.max(0.05,k)*e);var l=(new m(j.x+d.x,j.y+d.y)).reverse().resizeTo(Math.max(0.05,n)*e),j=this.canvasContext,e=g.x,n=g.y,k=b.x,q=b.y,w=g.x+i.x,g=g.y+i.y;i=b.x+l.x;l=b.y+l.y;j.beginPath(); j.moveTo(e,n);j.bezierCurveTo(w,g,i,l,k,q);j.stroke()}}d.getLength()<=this.lineCurveThreshold&&(d=this.canvasContext,g=b.x,b=b.y,i=c.x,c=c.y,d.beginPath(),d.moveTo(g,b),d.lineTo(i,c),d.stroke())},v=function(a){var b=a.x.length-1;if(0<b){var c=new h(a.x[b],a.y[b]),d=new h(a.x[b-1],a.y[b-1]),g=d.getVectorToPoint(c);if(g.getLength()>this.lineCurveThreshold){if(1<b){var a=(new h(a.x[b-2],a.y[b-2])).getVectorToPoint(d),j=(new m(a.x+g.x,a.y+g.y)).resizeTo(g.getLength()/2),g=this.canvasContext,a=d.x,b=d.y, i=c.x,e=c.y,k=d.x+j.x,d=d.y+j.y,j=c.x,c=c.y;g.beginPath();g.moveTo(a,b);g.bezierCurveTo(k,d,j,c,i,e)}else g=this.canvasContext,a=d.x,d=d.y,b=c.x,c=c.y,g.beginPath(),g.moveTo(a,d),g.lineTo(b,c);g.stroke()}}};p.prototype.resetCanvas=function(a){var b=this.canvas,c=this.settings,d=this.canvasContext,g=this.isCanvasEmulator,j=b.width,i=b.height;d.clearRect(0,0,j+30,i+30);d.shadowColor=d.fillStyle=c["background-color"];g&&d.fillRect(0,0,j+30,i+30);d.lineWidth=Math.ceil(parseInt(c.lineWidth,10));d.lineCap= d.lineJoin="round";d.strokeStyle=c["decor-color"];d.shadowOffsetX=0;d.shadowOffsetY=0;var k=Math.round(i/5),n=1.5*k,h=i-k,j=j-1.5*k,i=i-k;d.beginPath();d.moveTo(n,h);d.lineTo(j,i);d.stroke();d.strokeStyle=c.color;g||(d.shadowColor=d.strokeStyle,d.shadowOffsetX=0.5*d.lineWidth,d.shadowOffsetY=-0.6*d.lineWidth,d.shadowBlur=0);a||(a=[]);d=this.dataEngine=new s(a,this,z,u,v);c.data=a;$(b).data(e+".data",a).data(e+".settings",c);var l=this.$parent,q=this.events,w=e;d.changed=function(){q.publish(w+".change"); l.trigger("change")};d.changed();return!0};p.prototype.initializeCanvas=function(a){var b=document.createElement("canvas"),c=$(b);a.width===a.height&&"ratio"===a.height&&(a.width="100%");c.css("margin",0).css("padding",0).css("border","none").css("height","ratio"===a.height||!a.height?1:a.height.toString(10)).css("width","ratio"===a.width||!a.width?1:a.width.toString(10));c.appendTo(this.$parent);"ratio"===a.height?c.css("height",Math.round(c.width()/a.sizeRatio)):"ratio"===a.width&&c.css("width", Math.round(c.height()*a.sizeRatio));c.addClass(e);b.width=c.width();b.height=c.height();a=b;if(a.getContext)a=!1;else if("undefined"!==typeof FlashCanvas)a=FlashCanvas.initElement(a),c=1,window&&(window.screen&&window.screen.deviceXDPI&&window.screen.logicalXDPI)&&(c=1*window.screen.deviceXDPI/window.screen.logicalXDPI),1!==c&&($(a).children("object").get(0).resize(Math.ceil(a.width*c),Math.ceil(a.height*c)),a.getContext("2d").scale(c,c)),a=!0;else throw Error("Canvas element does not support 2d context. jSignature cannot proceed."); this.isCanvasEmulator=a;b.onselectstart=function(a){a&&a.preventDefault&&a.preventDefault();a&&a.stopPropagation&&a.stopPropagation();return false};return b};var k=function(a,c){var b=new Image,d=this;b.onload=function(){d.getContext("2d").drawImage(b,0,0,b.width<d.width?b.width:d.width,b.height<d.height?b.height:d.height)};b.src="data:"+c+","+a},q=function(a){this.find("canvas."+e).add(this.filter("canvas."+e)).data(e+".this").resetCanvas(a);return this},b=function(a,b){if(void 0===b&&("string"=== typeof a&&"data:"===a.substr(0,5))&&(b=a.slice(5).split(",")[0],a=a.slice(6+b.length),b===a))return;var c=this.find("canvas."+e).add(this.filter("canvas."+e));if(w.hasOwnProperty(b))0!==c.length&&w[b].call(c[0],a,b,function(a){return function(){return a.resetCanvas.apply(a,arguments)}}(c.data(e+".this")));else throw Error(e+" is unable to find import plugin with for format '"+String(b)+"'");return this},d=new t,g=e,c,j=function(){d.publish(g+".parentresized")};$(window).bind("resize."+g,function(){c&& clearTimeout(c);c=setTimeout(j,500)}).bind("mouseup."+g,function(a){d.publish(g+".windowmouseup",a)});var i={},n={"default":function(){return this.toDataURL()},"native":function(a){return a},image:function(){var a=this.toDataURL();if("string"===typeof a&&4<a.length&&"data:"===a.slice(0,5)&&-1!==a.indexOf(",")){var b=a.indexOf(",");return[a.slice(5,b),a.substr(b+1)]}return[]}},w={"native":function(a,b,c){c(a)},image:k,"image/png;base64":k,"image/jpeg;base64":k,"image/jpg;base64":k},l={"export":n,"import":w, instance:i},A={init:function(a){return this.each(function(){var b,c=!1;for(b=this.parentNode;b&&!c;)c=b.body,b=b.parentNode;!c||new p(this,a,i)})},getSettings:function(){return this.find("canvas."+e).add(this.filter("canvas."+e)).data(e+".this").settings},clear:q,reset:q,addPlugin:function(a,b,c){l.hasOwnProperty(a)&&(l[a][b]=c);return this},listPlugins:function(a){var b=[];if(l.hasOwnProperty(a)){var a=l[a],c;for(c in a)a.hasOwnProperty(c)&&b.push(c)}return b},getData:function(a){var b=this.find("canvas."+ e).add(this.filter("canvas."+e));void 0===a&&(a="default");if(0!==b.length&&n.hasOwnProperty(a))return n[a].call(b.get(0),b.data(e+".data"))},importData:b,setData:b,globalEvents:function(){return d},events:function(){return this.find("canvas."+e).add(this.filter("canvas."+e)).data(e+".this").events}};$.fn[e]=function(a){if(!a||"object"===typeof a)return A.init.apply(this,arguments);if("string"===typeof a&&A[a])return A[a].apply(this,Array.prototype.slice.call(arguments,1));$.error("Method "+String(a)+ " does not exist on jQuery."+e)}})(); (function(){$.fn.jSignature("addPlugin","instance","UndoButton",function(r){this.events.subscribe("jSignature.attachingEventHandlers",function(){if(this.settings[r]){var m=this.settings[r];"function"!==typeof m&&(m=function(){var e=$('<input type="button" value="Undo last stroke" style="position:absolute;display:none;margin:0 !important;top:auto" />').appendTo(this.$controlbarLower),h=e.width();e.css("left",Math.round((this.canvas.width-h)/2));h!==e.width()&&e.width(h);return e});var h=m.call(this), s=this;s.events.subscribe("jSignature.change",function(){s.dataEngine.data.length?h.show():h.hide()});var p=this,e=(this.events.topics.hasOwnProperty("jSignature.undo")?r:"jSignature")+".undo";h.bind("click",function(){p.events.publish(e)});p.events.subscribe(e,function(){var e=p.dataEngine.data;e.length&&(e.pop(),p.resetCanvas(e))})}})})})(); (function(){for(var r={},m={},h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX".split(""),s=h.length/2,p=s-1;-1<p;p--)r[h[p]]=h[p+s],m[h[p+s]]=h[p];var e=function(e){for(var e=e.split(""),h=e.length,b=1;b<h;b++)e[b]=r[e[b]];return e.join("")},y=function(h){for(var q=[],b=0,d=1,g=h.length,c,j,i=0;i<g;i++)c=Math.round(h[i]),j=c-b,b=c,0>j&&0<d?(d=-1,q.push("Z")):0<j&&0>d&&(d=1,q.push("Y")),c=Math.abs(j),c>=s?q.push(e(c.toString(s))):q.push(c.toString(s));return q.join("")},t=function(e){for(var h= [],e=e.split(""),b=e.length,d,g=1,c=[],j=0,i=0;i<b;i++)(d=e[i],d in r||"Z"===d||"Y"===d)?(0!==c.length&&(c=parseInt(c.join(""),s)*g+j,h.push(c),j=c),"Z"===d)?(g=-1,c=[]):"Y"===d?(g=1,c=[]):c=[d]:c.push(m[d]);h.push(parseInt(c.join(""),s)*g+j);return h},z=function(e){for(var h=[],b=e.length,d,g=0;g<b;g++)d=e[g],h.push(y(d.x)),h.push(y(d.y));return h.join("_")},u=function(e){for(var h=[],e=e.split("_"),b=e.length/2,d=0;d<b;d++)h.push({x:t(e[2*d]),y:t(e[2*d+1])});return h},h=function(e){return["image/jsignature;base30", z(e)]},p=function(e,h,b){"string"===typeof e&&("image/jsignature;base30"===e.substring(0,23).toLowerCase()&&(e=e.substring(24)),b(u(e)))};if(null==this.jQuery)throw Error("We need jQuery for some of the functionality. jQuery is not detected. Failing to initialize...");var v=this.jQuery.fn.jSignature;v("addPlugin","export","base30",h);v("addPlugin","export","image/jsignature;base30",h);v("addPlugin","import","base30",p);v("addPlugin","import","image/jsignature;base30",p);this.jSignatureDebug&&(this.jSignatureDebug.base30= {remapTailChars:e,compressstrokeleg:y,uncompressstrokeleg:t,compressstrokes:z,uncompressstrokes:u,charmap:r})}).call("undefined"!==typeof window?window:this); (function(){function r(b,d){this.x=b;this.y=d;this.reverse=function(){return new this.constructor(-1*this.x,-1*this.y)};this._length=null;this.getLength=function(){this._length||(this._length=Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2)));return this._length};var g=function(b){return Math.round(b/Math.abs(b))};this.resizeTo=function(b){if(0===this.x&&0===this.y)this._length=0;else if(0===this.x)this._length=b,this.y=b*g(this.y);else if(0===this.y)this._length=b,this.x=b*g(this.x);else{var d=Math.abs(this.y/ this.x),e=Math.sqrt(Math.pow(b,2)/(1+Math.pow(d,2))),d=d*e;this._length=b;this.x=e*g(this.x);this.y=d*g(this.y)}return this};this.angleTo=function(b){var d=this.getLength()*b.getLength();return 0===d?0:Math.acos(Math.min(Math.max((this.x*b.x+this.y*b.y)/d,-1),1))/Math.PI}}function m(b,d){this.x=b;this.y=d;this.getVectorToCoordinates=function(b,c){return new r(b-this.x,c-this.y)};this.getVectorFromCoordinates=function(b,c){return this.getVectorToCoordinates(b,c).reverse()};this.getVectorToPoint=function(b){return new r(b.x- this.x,b.y-this.y)};this.getVectorFromPoint=function(b){return this.getVectorToPoint(b).reverse()}}function h(b,d){var g=Math.pow(10,d);return Math.round(b*g)/g}function s(b,d,g){var d=d+1,c=new m(b.x[d-1],b.y[d-1]),e=new m(b.x[d],b.y[d]),e=c.getVectorToPoint(e),i=new m(b.x[d-2],b.y[d-2]),c=i.getVectorToPoint(c);return c.getLength()>g?(g=2<d?(new m(b.x[d-3],b.y[d-3])).getVectorToPoint(i):new r(0,0),b=0.35*c.getLength(),i=c.angleTo(g.reverse()),d=e.angleTo(c.reverse()),g=(new r(g.x+c.x,g.y+c.y)).resizeTo(Math.max(0.05, i)*b),e=(new r(c.x+e.x,c.y+e.y)).reverse().resizeTo(Math.max(0.05,d)*b),e=new r(c.x+e.x,c.y+e.y),["c",h(g.x,2),h(g.y,2),h(e.x,2),h(e.y,2),h(c.x,2),h(c.y,2)]):["l",h(c.x,2),h(c.y,2)]}function p(b,d){var g=b.x.length-1,c=new m(b.x[g],b.y[g]),e=new m(b.x[g-1],b.y[g-1]),c=e.getVectorToPoint(c);if(1<g&&c.getLength()>d){var g=(new m(b.x[g-2],b.y[g-2])).getVectorToPoint(e),e=c.angleTo(g.reverse()),i=0.35*c.getLength(),g=(new r(g.x+c.x,g.y+c.y)).resizeTo(Math.max(0.05,e)*i);return["c",h(g.x,2),h(g.y,2),h(c.x, 2),h(c.y,2),h(c.x,2),h(c.y,2)]}return["l",h(c.x,2),h(c.y,2)]}function e(b,d,e){for(var d=["M",h(b.x[0]-d,2),h(b.y[0]-e,2)],e=1,c=b.x.length-1;e<c;e++)d.push.apply(d,s(b,e,1));0<c?d.push.apply(d,p(b,e,1)):0===c&&d.push.apply(d,["l",1,1]);return d.join(" ")}function y(b){var d=['<?xml version="1.0" encoding="UTF-8" standalone="no"?>','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'],g,c=b.length,j,i=[],h=[],k=j=g=0,l=0,m=[];if(0!==c){for(g=0;g<c;g++){k= b[g];l=[];j={x:[],y:[]};for(var a=void 0,f=void 0,a=0,f=k.x.length;a<f;a++)l.push({x:k.x[a],y:k.y[a]});l=simplify(l,0.7,!0);a=0;for(f=l.length;a<f;a++)j.x.push(l[a].x),j.y.push(l[a].y);m.push(j);i=i.concat(j.x);h=h.concat(j.y)}b=Math.min.apply(null,i)-1;c=Math.max.apply(null,i)+1;i=Math.min.apply(null,h)-1;h=Math.max.apply(null,h)+1;k=0>b?0:b;l=0>i?0:i;g=c-b;j=h-i}d.push('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="'+g.toString()+'" height="'+j.toString()+'">');g=0;for(c=m.length;g< c;g++)j=m[g],d.push('<path fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="'+e(j,k,l)+'"/>');d.push("</svg>");return d.join("")}function t(b){return[k,y(b)]}function z(b){return[q,v(y(b))]}var u=window;"use strict";("undefined"!=typeof exports?exports:u).simplify=function(b,d,e){d=void 0!==d?d*d:1;if(!e){for(var c=b.length,j,i=b[0],h=[i],e=1;e<c;e++){j=b[e];var k=j.x-i.x,l=j.y-i.y;k*k+l*l>d&&(h.push(j),i=j)}b=(i!==j&&h.push(j),h)}j=b;var e=j.length, c=new ("undefined"!=typeof Uint8Array?Uint8Array:Array)(e),i=0,h=e-1,m,a,f=[],o=[],q=[];for(c[i]=c[h]=1;h;){l=0;for(k=i+1;k<h;k++){m=j[k];var p=j[i],r=j[h],s=p.x,u=p.y,p=r.x-s,t=r.y-u,v=void 0;if(0!==p||0!==t)v=((m.x-s)*p+(m.y-u)*t)/(p*p+t*t),1<v?(s=r.x,u=r.y):0<v&&(s+=p*v,u+=t*v);m=(p=m.x-s,t=m.y-u,p*p+t*t);m>l&&(a=k,l=m)}l>d&&(c[a]=1,f.push(i),o.push(a),f.push(a),o.push(h));i=f.pop();h=o.pop()}for(k=0;k<e;k++)c[k]&&q.push(j[k]);return b=q,b};if("function"!==typeof v)var v=function(b){var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""), e,c,h,i,k=0,m=0,l="",l=[];do e=b.charCodeAt(k++),c=b.charCodeAt(k++),h=b.charCodeAt(k++),i=e<<16|c<<8|h,e=i>>18&63,c=i>>12&63,h=i>>6&63,i&=63,l[m++]=d[e]+d[c]+d[h]+d[i];while(k<b.length);l=l.join("");b=b.length%3;return(b?l.slice(0,b-3):l)+"===".slice(b||3)};var k="image/svg+xml",q="image/svg+xml;base64";if("undefined"===typeof $)throw Error("We need jQuery for some of the functionality. jQuery is not detected. Failing to initialize...");u=$.fn.jSignature;u("addPlugin","export","svg",t);u("addPlugin", "export",k,t);u("addPlugin","export","svgbase64",z);u("addPlugin","export",q,z)})();