piskel/js/service/HistoryService.js

28 lines
796 B
JavaScript
Raw Normal View History

(function () {
2012-09-16 15:10:05 +04:00
var ns = $.namespace("pskl.service");
ns.HistoryService = function (framesheet) {
this.framesheet = framesheet;
};
2012-09-16 15:10:05 +04:00
ns.HistoryService.prototype.init = function () {
$.subscribe(Events.TOOL_RELEASED, this.saveState.bind(this));
$.subscribe(Events.UNDO, this.undo.bind(this));
$.subscribe(Events.REDO, this.redo.bind(this));
};
2012-09-16 15:10:05 +04:00
ns.HistoryService.prototype.saveState = function () {
this.framesheet.getCurrentFrame().saveState();
};
2012-09-16 15:10:05 +04:00
ns.HistoryService.prototype.undo = function () {
this.framesheet.getCurrentFrame().loadPreviousState();
$.publish(Events.FRAMESHEET_RESET);
};
2012-09-16 15:10:05 +04:00
ns.HistoryService.prototype.redo = function () {
this.framesheet.getCurrentFrame().loadNextState();
$.publish(Events.FRAMESHEET_RESET);
};
})();