2012-09-07 02:18:59 +04:00
|
|
|
(function () {
|
2013-08-10 14:11:16 +04:00
|
|
|
var ns = $.namespace("pskl.service");
|
2013-09-22 23:02:43 +04:00
|
|
|
ns.HistoryService = function (piskelController) {
|
2013-09-29 01:52:51 +04:00
|
|
|
this.piskelController = piskelController;
|
2012-09-11 01:26:12 +04:00
|
|
|
};
|
2012-09-07 02:18:59 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
ns.HistoryService.prototype.init = function () {
|
2013-09-29 01:52:51 +04:00
|
|
|
|
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));
|
2013-08-10 14:11:16 +04:00
|
|
|
};
|
2012-09-07 02:18:59 +04:00
|
|
|
|
2012-09-16 15:10:05 +04:00
|
|
|
ns.HistoryService.prototype.saveState = function () {
|
2013-09-22 23:02:43 +04:00
|
|
|
this.piskelController.getCurrentFrame().saveState();
|
2012-09-11 01:26:12 +04:00
|
|
|
};
|
2012-09-07 02:18:59 +04:00
|
|
|
|
2012-09-16 15:10:05 +04:00
|
|
|
ns.HistoryService.prototype.undo = function () {
|
2013-09-22 23:02:43 +04:00
|
|
|
this.piskelController.getCurrentFrame().loadPreviousState();
|
2013-09-29 02:01:18 +04:00
|
|
|
$.publish(Events.PISKEL_RESET);
|
2012-09-11 01:26:12 +04:00
|
|
|
};
|
|
|
|
|
2012-09-16 15:10:05 +04:00
|
|
|
ns.HistoryService.prototype.redo = function () {
|
2013-09-22 23:02:43 +04:00
|
|
|
this.piskelController.getCurrentFrame().loadNextState();
|
2013-09-29 02:01:18 +04:00
|
|
|
$.publish(Events.PISKEL_RESET);
|
2012-09-11 01:26:12 +04:00
|
|
|
};
|
|
|
|
|
2012-09-07 02:18:59 +04:00
|
|
|
})();
|