derickbailey/backbone.memento — pull request #11 by roasm (2012-01-09 22:47:22+00:00)
Title: Redo and returning true if undo/redo did anything.

I added two features that we needed for our app.

The larger one is redo. It doesn't pop states off the stack, but instead keeps an index to the next state that should be returned by undo. If a store() is called while the index is in the middle of the stack, it truncates the array to remove the remain states that should no longer be accessible.

Because store() is usually called before an action is performed on the model, there are generally some unsaved changes to the model when you call undo. These unsaved changes are stored in a temporary attributes variable so they can be redone (redo'ed?).

I also return true if an undo() or redo() call actually applies attributes to the model. If nothing is applied, it returns false.