/* jSignature v2 "2016-11-05T00:40" "commit ID d9ac2f271cfdf479d005a449193e09985043cafa" Copyright (c) 2012 Willow Systems Corp http://willow-systems.com Copyright (c) 2010 Brinley Ang http://www.unbolt.net MIT License 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 jSignature's Undo Button and undo functionality plugin jSignature v2 jSignature's custom "base30" format export and import plugins. jSignature v2 SVG export plugin. */ (function(){function t(b){var a,c=b.css("color"),e;b=b[0];for(var h=!1;b&&!e&&!h;){try{a=$(b).css("background-color")}catch(l){a="transparent"}"transparent"!==a&&"rgba(0, 0, 0, 0)"!==a&&(e=a);h=b.body;b=b.parentNode}b=/rgb[a]*\((\d+),\s*(\d+),\s*(\d+)/;var h=/#([AaBbCcDdEeFf\d]{2})([AaBbCcDdEeFf\d]{2})([AaBbCcDdEeFf\d]{2})/,m;a=void 0;(a=c.match(b))?m={r:parseInt(a[1],10),g:parseInt(a[2],10),b:parseInt(a[3],10)}:(a=c.match(h))&&(m={r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)});var d; e?(a=void 0,(a=e.match(b))?d={r:parseInt(a[1],10),g:parseInt(a[2],10),b:parseInt(a[3],10)}:(a=e.match(h))&&(d={r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)})):d=m?127').appendTo(e);this.isCanvasEmulator=!1;a=this.canvas=this.initializeCanvas(d);c=$(a);this.$controlbarLower=$('
').appendTo(e); this.canvasContext=a.getContext("2d");c.data("jSignature.this",this);d.lineWidth=function(a,b){return a?a:Math.max(Math.round(b/400),2)}(d.lineWidth,a.width);this.lineCurveThreshold=3*d.lineWidth;d.cssclass&&""!=$.trim(d.cssclass)&&c.addClass(d.cssclass);this.fatFingerCompensation=0;e=function(a){var b,c,e=function(e){e=e.changedTouches&&0d.minFatFingerCompensation?-3*d.lineWidth:d.minFatFingerCompensation;b(h);e.ontouchend=a;e.ontouchstart=b;e.ontouchmove=c},e.onmousedown=function(d){e.ontouchstart=e.ontouchend=e.ontouchmove=void 0;b(d);e.onmousedown=b;e.onmouseup= a;e.onmousemove=c},window.navigator.msPointerEnabled&&(e.onmspointerdown=b,e.onmspointerup=a,e.onmspointermove=c))}).call(this,e.drawEndHandler,e.drawStartHandler,e.drawMoveHandler);b["jSignature.windowmouseup"]=h.subscribe("jSignature.windowmouseup",e.drawEndHandler);this.events.publish("jSignature.attachingEventHandlers");r.call(this,this,d.width.toString(10),"jSignature",h);this.resetCanvas(d.data);this.events.publish("jSignature.initialized");return this}function y(b){if(b.getContext)return!1; var a=b.ownerDocument.parentWindow,c=a.FlashCanvas?b.ownerDocument.parentWindow.FlashCanvas:"undefined"===typeof FlashCanvas?void 0:FlashCanvas;if(c){b=c.initElement(b);c=1;a&&a.screen&&a.screen.deviceXDPI&&a.screen.logicalXDPI&&(c=1*a.screen.deviceXDPI/a.screen.logicalXDPI);if(1!==c)try{$(b).children("object").get(0).resize(Math.ceil(b.width*c),Math.ceil(b.height*c)),b.getContext("2d").scale(c,c)}catch(e){}return!0}throw Error("Canvas element does not support 2d context. jSignature cannot proceed."); }var w=function(b,a){var c;this.kick=function(){clearTimeout(c);c=setTimeout(a,b)};this.clear=function(){clearTimeout(c)};return this},v=function(b){this.topics={};this.context=b?b:this;this.publish=function(a,b,e,d){if(this.topics[a]){var c=this.topics[a],h=Array.prototype.slice.call(arguments,1),f=[],g=[],p,q,u,A;q=0;for(u=c.length;qthis.lineCurveThreshold){l=2this.lineCurveThreshold)if(1').appendTo(this.$controlbarLower),k=g.width();g.css("left",Math.round((this.canvas.width-k)/2));k!==g.width()&&g.width(k);return g});t.call(this,g,"jSignature",k)}})})})(); (function(){for(var t={},k={},g="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX".split(""),n=g.length/2,r=n-1;-1f&&0c&&(c=1,b.push("Y")),h=Math.abs(f),h>=n?b.push(x(h.toString(n))):b.push(h.toString(n));return b.join("")},w=function(d){var b= [];d=d.split("");for(var a=d.length,c,e=1,f=[],m=0,g=0;gb?(b=2d){var b=(new k(f.x[b-2],f.y[b-2])).getVectorToPoint(c),c=a.angleTo(b.reverse()),e=.35*a.getLength(),b=(new t(b.x+a.x,b.y+a.y)).resizeTo(Math.max(.05,c)*e);return["c",g(b.x,2),g(b.y,2),g(a.x, 2),g(a.y,2),g(a.x,2),g(a.y,2)]}return["l",g(a.x,2),g(a.y,2)]}function x(f,d,b){d=["M",g(f.x[0]-d,2),g(f.y[0]-b,2)];b=1;for(var a=f.x.length-1;b',''],a,c=f.length,e,h=[],g=[],k=e=a=0,l=0,n=[];if(0!==c){for(a=0;ac?0:c;l=0>h?0:h;a-=c;e=g-h}b.push('');a=0;for(c=n.length;a');b.push("");return b.join("")}function v(f,d){return["image/svg+xml",w(f,d)]}function z(f,d){return["image/svg+xml;base64",D(w(f,d))]}(function(f,d){"use strict"; (typeof exports!=d+""?exports:f).simplify=function(b,a,c){a=a!==d?a*a:1;if(!c){var e=b.length,f,g=b[0],k=[g];for(c=1;ca&&(k.push(f),g=f)}b=(g!==f&&k.push(f),k)}f=b;c=f.length;var e=new (typeof Uint8Array!=d+""?Uint8Array:Array)(c),g=0,k=c-1,p,q,r=[],t=[],z=[];for(e[g]=e[k]=1;k;){n=0;for(l=g+1;ln&&(q=l,n=p)}n>a&&(e[q]=1,r.push(g),t.push(q),r.push(q),t.push(k));g=r.pop();k=t.pop()}for(l=0;l>18&63,a=e>>12&63,c=e>>6&63,e&=63,n[k++]=d[b]+d[a]+d[c]+d[e];while(g