(function (a) { a.fn.extend({ sigpad: function (e) { var A = { lineWidth: 3.0, lineCap: 'round', lineJoin: 'round', miterLimit: 10, strokeStyle: 'black', fillStyle: 'none', showClear: false, clearLabel: 'Clear', clearStyle: 'button' }; e = a.extend(A, e); return this.each(function () { if (this.nodeName === 'CANVAS') { a(this).css('cursor', 'pointer'); a(this).attr('onclick', 'function onclick(event) { void 1; }'); if (this.getContext) { var r = this; var c = this.getContext('2d'); var h = a(this).attr('id'); a(this).after('
'); c.underInteractionEnabled = true; c.lineWidth = e.lineWidth; c.lineCap = e.lineCap; c.lineJoin = e.lineJoin; c.miterLimit = e.miterLimit; c.strokeStyle = e.strokeStyle; c.fillStyle = e.fillStyle; var k = h + '-data'; a(this).after(''); var m = false; var s = a('#' + h).height(); var t = a('#' + h).width(); var d = ''; var n = 0; var o = 0; var B = a(this).attr('offsetLeft'); var C = a(this).attr('offsetTop'); var j = false; var p = false; var u = false; var f = false; var g = false; a(document).mousedown(function (b) { v(b) }); a(document).mousemove(function (b) { w(b) }); a(document).mouseup(function () { q() }); a(document).bind('touchstart', function (b) { v(b) }); a(document).bind('touchmove', function (b) { w(b) }); a(document).bind('touchend', function () { q() }); a(document).bind('touchcancel', function () { q() }); if (e.showClear === true) { var x = (e.clearStyle == 'link' ? 'div' : 'button'); a('#' + h + '-controls').append('<' + x + ' id="' + h + '-clear" style="float:left">' + e.clearLabel + '' + x + '> '); clear = true } a('#' + h + '-clear').click(function (b) { c.save(); c.beginPath(); c.closePath(); c.restore(); c.clearRect(0, 0, a(r).width(), a(r).height()); a('#' + k).val('') }); function y(b) { if (typeof (event) != "undefined" && typeof (event.touches) != "undefined") { b = event.touches.item(0); n = document.body.scrollLeft; o = document.body.scrollTop } else { n = a(document).scrollLeft(); o = a(document).scrollTop() } if (f != false) { p = f; u = g } f = b.clientX - (B - n); g = b.clientY - (C - o); return b } function l(b) { if (b != 'stop') { if (b == 'start') { j = false; p = false; u = false; c.beginPath(); c.moveTo(f, g); if (d == '') { var i = new Date(); var D = i.getFullYear() + ':' + (i.getMonth()+1) + ':' + i.getDate() + ':' + i.getHours() + ':' + i.getMinutes() + ':' + i.getSeconds(); d = '{version=1 width=' + t + ' height=' + s + ' captured=' + D + '}' } if (d != '') { d += 'X' } } else { if (p == false) { f = f + 1; g = g + 1 } c.lineTo(f, g) } c.stroke(); if (d.length > 0 && d.substring(d.length - 1) != '"') { d = d + ' ' } d = d + f + ',' + g; if ((f > 0 && f <= t) && (g > 0 && g <= s)) { j = true } } else { l('move'); if (j == true) { var z = a('#' + k); var E = z.val(); z.val(d) } } } function v(b) { if (j == true) { b.preventDefault() } m = true; b = y(b); c.strokeStyle = a('#' + h + '-colors div.selected').css('backgroundColor'); l('start') } function w(b) { if (j == true) { b.preventDefault() } if (m == true) { b = y(b); l('move') } return false } function q() { m = false; l('stop') } } } else { alert('Not a CANVAS element') } }) } }) })(jQuery);