2012-09-07 02:18:59 +04:00
|
|
|
(function () {
|
|
|
|
var ns = $.namespace("pskl");
|
2012-09-11 01:26:12 +04:00
|
|
|
ns.HistoryManager = function (framesheet) {
|
|
|
|
this.framesheet = framesheet;
|
|
|
|
};
|
2012-09-07 02:18:59 +04:00
|
|
|
|
|
|
|
ns.HistoryManager.prototype.init = function () {
|
2012-09-11 01:26:12 +04:00
|
|
|
$.subscribe(Events.TOOL_RELEASED, this.saveState.bind(this));
|
2012-09-12 14:01:47 +04:00
|
|
|
|
|
|
|
$.subscribe(Events.UNDO, this.undo.bind(this));
|
|
|
|
$.subscribe(Events.REDO, this.redo.bind(this));
|
2012-09-07 02:18:59 +04:00
|
|
|
};
|
|
|
|
|
2012-09-11 01:26:12 +04:00
|
|
|
ns.HistoryManager.prototype.saveState = function () {
|
|
|
|
this.framesheet.getCurrentFrame().saveState();
|
|
|
|
};
|
2012-09-07 02:18:59 +04:00
|
|
|
|
2012-09-11 01:26:12 +04:00
|
|
|
ns.HistoryManager.prototype.undo = function () {
|
|
|
|
this.framesheet.getCurrentFrame().loadPreviousState();
|
2012-09-14 02:03:27 +04:00
|
|
|
$.publish(Events.FRAMESHEET_RESET);
|
2012-09-11 01:26:12 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
ns.HistoryManager.prototype.redo = function () {
|
|
|
|
this.framesheet.getCurrentFrame().loadNextState();
|
2012-09-14 02:03:27 +04:00
|
|
|
$.publish(Events.FRAMESHEET_RESET);
|
2012-09-11 01:26:12 +04:00
|
|
|
};
|
|
|
|
|
2012-09-07 02:18:59 +04:00
|
|
|
})();
|