/* jSignature v2 "2017-07-30T10:26" "commit ID 3ef5538b5b49228993a9d3613d4b6d465150a310" 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 q(a){var b=a.css("color"),d;a=a[0];for(var g=!1;a&&!d&&!g;){try{var c=$(a).css("background-color")}catch(l){c="transparent"}"transparent"!==c&&"rgba(0, 0, 0, 0)"!==c&&(d=c);g=a.body;a=a.parentNode}a=/rgb[a]*\((\d+),\s*(\d+),\s*(\d+)/;var g=/#([AaBbCcDdEeFf\d]{2})([AaBbCcDdEeFf\d]{2})([AaBbCcDdEeFf\d]{2})/;c=void 0;if(c=b.match(a))var n={r:parseInt(c[1],10),g:parseInt(c[2],10),b:parseInt(c[3],10)};else(c=b.match(g))&&(n={r:parseInt(c[1],16),g:parseInt(c[2],16),b:parseInt(c[3], 16)});if(d)if(c=void 0,c=d.match(a))var e={r:parseInt(c[1],10),g:parseInt(c[2],10),b:parseInt(c[3],10)};else(c=d.match(g))&&(e={r:parseInt(c[1],16),g:parseInt(c[2],16),b:parseInt(c[3],16)});else e=n?127').appendTo(g);this.isCanvasEmulator=!1;b=this.canvas=this.initializeCanvas(e);d=$(b);this.$controlbarLower=$('
').appendTo(g); this.canvasContext=b.getContext("2d");d.data("jSignature.this",this);e.lineWidth=function(a,b){return a?a:Math.max(Math.round(b/400),2)}(e.lineWidth,b.width);this.lineCurveThreshold=3*e.lineWidth;e.cssclass&&""!=$.trim(e.cssclass)&&d.addClass(e.cssclass);this.fatFingerCompensation=0;g=function(a){var b,d,c=function(c){c=c.changedTouches&&0e.minFatFingerCompensation?-3*e.lineWidth:e.minFatFingerCompensation;b(g);c.ontouchend=a;c.ontouchstart=b;c.ontouchmove=d},c.onmousedown=function(g){c.ontouchstart=c.ontouchend=c.ontouchmove=void 0;b(g);c.onmousedown=b;c.onmouseup= a;c.onmousemove=d},window.navigator.msPointerEnabled&&(c.onmspointerdown=b,c.onmspointerup=a,c.onmspointermove=d))}).call(this,g.drawEndHandler,g.drawStartHandler,g.drawMoveHandler);a["jSignature.windowmouseup"]=c.subscribe("jSignature.windowmouseup",g.drawEndHandler);this.events.publish("jSignature.attachingEventHandlers");m.call(this,this,e.width.toString(10),"jSignature",c);this.resetCanvas(e.data);this.events.publish("jSignature.initialized");return this}function y(a){if(a.getContext)return!1; var b=a.ownerDocument.parentWindow,d=b.FlashCanvas?a.ownerDocument.parentWindow.FlashCanvas:"undefined"===typeof FlashCanvas?void 0:FlashCanvas;if(d){a=d.initElement(a);d=1;b&&b.screen&&b.screen.deviceXDPI&&b.screen.logicalXDPI&&(d=1*b.screen.deviceXDPI/b.screen.logicalXDPI);if(1!==d)try{$(a).children("object").get(0).resize(Math.ceil(a.width*d),Math.ceil(a.height*d)),a.getContext("2d").scale(d,d)}catch(g){}return!0}throw Error("Canvas element does not support 2d context. jSignature cannot proceed."); }var w=function(a,b){var d;this.kick=function(){clearTimeout(d);d=setTimeout(b,a)};this.clear=function(){clearTimeout(d)};return this},v=function(a){this.topics={};this.context=a?a:this;this.publish=function(a,d,g,c){if(this.topics[a]){var b=this.topics[a],e=Array.prototype.slice.call(arguments,1),f=[],h=[],u;var k=0;for(u=b.length;kthis.lineCurveThreshold){var l=2this.lineCurveThreshold)if(1').appendTo(this.$controlbarLower),k=h.width();h.css("left",Math.round((this.canvas.width-k)/2));k!==h.width()&&h.width(k);return h});q.call(this,h,"jSignature",k)}})})})(); (function(){for(var q={},k={},h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX".split(""),p=h.length/2,m=p-1;-1f&&0d&&(d=1,a.push("Y")),c=Math.abs(f),c>=p?a.push(x(c.toString(p))):a.push(c.toString(p));return a.join("")},w=function(e){var a= [];e=e.split("");for(var b=e.length,d,g=1,c=[],f=0,h=0;ha?(a=2e){var a=(new k(f.x[a-2],f.y[a-2])).getVectorToPoint(d),d=b.angleTo(a.reverse()),g=.35*b.getLength(),a=(new q(a.x+b.x,a.y+b.y)).resizeTo(Math.max(.05,d)*g);return["c",h(a.x,2),h(a.y,2),h(b.x, 2),h(b.y,2),h(b.x,2),h(b.y,2)]}return["l",h(b.x,2),h(b.y,2)]}function x(f,e,a){e=["M",h(f.x[0]-e,2),h(f.y[0]-a,2)];a=1;for(var b=f.x.length-1;a',''],b,d=f.length,g,c=[],h=[],k=g=b=0,l=0,p=[];if(0!==d){for(b=0;bd?0:d;l=0>c?0:c;b-=d;g=h-c}a.push('');b=0;for(d=p.length;b');a.push("");return a.join("")}function v(f,e){return["image/svg+xml",w(f,e)]}function z(f,e){return["image/svg+xml;base64",r(w(f,e))]}var r;(function(f, e){"use strict";f.simplify=function(a,b,d){b=b!==e?b*b:1;if(!d){var g=a.length,c=a[0],f=[c];for(d=1;db&&(f.push(h),c=h)}a=(c!==h&&f.push(h),f)}h=a;d=h.length;var g=new (typeof Uint8Array!=e+""?Uint8Array:Array)(d),c=0,f=d-1,p,q=[],t=[],z=[];for(g[c]=g[f]=1;f;){m=0;for(k=c+1;km&&(p=k,m=B)}m>b&&(g[p]=1,q.push(c),t.push(p),q.push(p),t.push(f));c=q.pop();f=t.pop()}for(k=0;k>18&63;c=k>>12&63;h=k>>6&63;k&=63;d[b++]=e[g]+e[c]+e[h]+e[k]}while(a