From a7e198fd71b1d0b9ec544c3f2b1e38eaca4d719f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 29 Aug 2014 22:13:20 -0400 Subject: undo/redo for colors --- public/assets/javascripts/rectangles/util/undostack.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'public/assets/javascripts/rectangles/util/undostack.js') diff --git a/public/assets/javascripts/rectangles/util/undostack.js b/public/assets/javascripts/rectangles/util/undostack.js index b93c79e..959e3d1 100644 --- a/public/assets/javascripts/rectangles/util/undostack.js +++ b/public/assets/javascripts/rectangles/util/undostack.js @@ -31,16 +31,17 @@ this.types[ action.type ].redo(action.redo) return this.pointer < this.stack.length-1 } - UndoStack.prototype.register = function(actionType){ - if (actionType.length) { - actionType.forEach(this.registerOne.bind(this)) + UndoStack.prototype.register = function(actions){ + if (actions.length) { + actions.forEach(this.registerOne.bind(this)) } else { - this.registerOne(actionType) + this.registerOne(actions) } } - UndoStack.prototype.registerOne = function(actionType){ - this.types[ actionType.type ] = actionType + UndoStack.prototype.registerOne = function(action){ + if (! action.redo) { action.redo = action.undo } + this.types[ action.type ] = action } if ('window' in this) { window.UndoStack = new UndoStack -- cgit v1.2.3-70-g09d2