2012-09-06 22:18:59 +00:00
|
|
|
(function () {
|
2012-09-16 11:10:05 +00:00
|
|
|
var ns = $.namespace("pskl.service");
|
|
|
|
ns.HistoryService = function (framesheet) {
|
2012-09-10 21:26:12 +00:00
|
|
|
this.framesheet = framesheet;
|
|
|
|
};
|
2012-09-06 22:18:59 +00:00
|
|
|
|
2012-09-16 11:10:05 +00:00
|
|
|
ns.HistoryService.prototype.init = function () {
|
|
|
|
|
2012-09-10 21:26:12 +00:00
|
|
|
$.subscribe(Events.TOOL_RELEASED, this.saveState.bind(this));
|
2012-09-12 10:01:47 +00:00
|
|
|
$.subscribe(Events.UNDO, this.undo.bind(this));
|
|
|
|
$.subscribe(Events.REDO, this.redo.bind(this));
|
2012-09-06 22:18:59 +00:00
|
|
|
};
|
|
|
|
|
2012-09-16 11:10:05 +00:00
|
|
|
ns.HistoryService.prototype.saveState = function () {
|
2012-09-10 21:26:12 +00:00
|
|
|
this.framesheet.getCurrentFrame().saveState();
|
|
|
|
};
|
2012-09-06 22:18:59 +00:00
|
|
|
|
2012-09-16 11:10:05 +00:00
|
|
|
ns.HistoryService.prototype.undo = function () {
|
2012-09-10 21:26:12 +00:00
|
|
|
this.framesheet.getCurrentFrame().loadPreviousState();
|
2012-09-13 22:03:27 +00:00
|
|
|
$.publish(Events.FRAMESHEET_RESET);
|
2012-09-10 21:26:12 +00:00
|
|
|
};
|
|
|
|
|
2012-09-16 11:10:05 +00:00
|
|
|
ns.HistoryService.prototype.redo = function () {
|
2012-09-10 21:26:12 +00:00
|
|
|
this.framesheet.getCurrentFrame().loadNextState();
|
2012-09-13 22:03:27 +00:00
|
|
|
$.publish(Events.FRAMESHEET_RESET);
|
2012-09-10 21:26:12 +00:00
|
|
|
};
|
|
|
|
|
2012-09-06 22:18:59 +00:00
|
|
|
})();
|