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