From ee9f9a24206da4916e5f9138722c7d789949d9da Mon Sep 17 00:00:00 2001 From: Luis Leiva Date: Sat, 12 Apr 2014 00:42:11 +0200 Subject: [PATCH 1/2] Minor renaming --- jquery.sketchable.memento.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/jquery.sketchable.memento.js b/jquery.sketchable.memento.js index eeb49c5..42fca93 100644 --- a/jquery.sketchable.memento.js +++ b/jquery.sketchable.memento.js @@ -27,13 +27,13 @@ // Private stuff ////////////////////////////////////////////////////////// var stack = []; var stpos = -1; - var self = this; + var self = this; function prev() { if (stpos > 0) { stpos--; var snapshot = new Image(); - snapshot.src = stack[stpos].state; + snapshot.src = stack[stpos].image; snapshot.onload = function() { restore(this); }; @@ -44,7 +44,7 @@ if (stpos < stack.length - 1) { stpos++; var snapshot = new Image(); - snapshot.src = stack[stpos].state; + snapshot.src = stack[stpos].image; snapshot.onload = function() { restore(this); }; @@ -122,7 +122,7 @@ stpos++; if (stpos < stack.length) stack.length = stpos; $canvas.sketchable('handler', function(elem, data) { - stack.push({ state: elem[0].toDataURL(), strokes: data.strokes.slice() }); + stack.push({ image: elem[0].toDataURL(), strokes: data.strokes.slice() }); }); }; /** @@ -172,10 +172,10 @@ // A helper function to override user-defined event listeners. function override(ev) { if (options.events && typeof options.events[ev] === 'function') { - var _init = options.events[ev]; + var fn = options.events[ev]; options.events[ev] = function() { var args = Array.prototype.slice.call(arguments, 0); - _init.call(this, args); + fn.call(this, args); callbacks[ev].apply(this, args); } } else { @@ -183,6 +183,7 @@ } }; + // Event order matters. var events = 'init mouseup destroy'.split(" "); for (var i = 0; i < events.length; i++) { override(events[i]); @@ -195,7 +196,7 @@ }, redo: function() { mc.redo(); - }, + } }); return plugin.defaults; From 5fb01a7c8a0e389bcc1d259ecd613f4859f8b7ae Mon Sep 17 00:00:00 2001 From: Luis Leiva Date: Sat, 12 Apr 2014 01:02:57 +0200 Subject: [PATCH 2/2] Minor renaming --- jquery.sketchable.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/jquery.sketchable.js b/jquery.sketchable.js index 3a32303..0fcc428 100644 --- a/jquery.sketchable.js +++ b/jquery.sketchable.js @@ -44,7 +44,7 @@ var sketch = new jSketch(this, { fillStyle: options.graphics.fillStyle, strokeStyle: options.graphics.strokeStyle, - lineWidth: options.graphics.lineWidth, + lineWidth: options.graphics.lineWidth }); // Flag drawing state on a per-canvas basis. sketch.isDrawing = false; @@ -218,7 +218,7 @@ * destroy: function(elem, data){}, * mousedown: function(elem, data, evt){}, * mousemove: function(elem, data, evt){}, - * mouseup: function(elem, data, evt){}, + * mouseup: function(elem, data, evt){} * }, * graphics: { * firstPointSize: 0, @@ -244,7 +244,7 @@ // destroy: function(elem, data){}, // mousedown: function(elem, data, evt){}, // mousemove: function(elem, data, evt){}, - // mouseup: function(elem, data, evt){}, + // mouseup: function(elem, data, evt){} }, // TODO: add more jSketch config options graphics: { @@ -252,9 +252,9 @@ lineWidth: 3, strokeStyle: '#F0F', fillStyle: '#F0F' - //lineCap: - //lineJoin: - //miterLimit: + //lineCap: "round", + //lineJoin: "round", + //miterLimit: 10 } }; @@ -315,11 +315,11 @@ function touchHandler(e) { e.preventDefault(); - var elem = $(e.target); + var elem = $(e.target); var touch = e.originalEvent.changedTouches[0]; // Copy original event properties to touch event. for (var o in e) { - touch[o] = e[o]; + if (e.hasOwnProperty(o)) touch[o] = e[o]; } // Remove (emulated) mouse events on mobile devices. switch (e.type) {