Move HistoryManager to a service

This commit is contained in:
Vince 2012-09-16 13:10:05 +02:00
parent b8eb3c9bd9
commit 7d529aeaaa
3 changed files with 11 additions and 14 deletions

View File

@ -109,13 +109,10 @@
<script src="js/controller/ToolController.js"></script>
<script src="js/Palette.js"></script>
<script src="js/Notification.js"></script>
<!-- Services -->
<script src="js/service/LocalStorageService.js"></script>
<script src="js/HistoryManager.js"></script>
<script src="js/KeyManager.js"></script>
<script src="js/service/HistoryService.js"></script>
<script src="js/KeyManager.js"></script>
<!-- Tools-->
<script src="js/drawingtools/BaseTool.js"></script>
<script src="js/drawingtools/SimplePen.js"></script>

View File

@ -66,8 +66,8 @@ $.namespace("pskl");
this.animationController.init();
this.previewsController.init();
this.historyManager = new pskl.HistoryManager(frameSheet);
this.historyManager.init();
this.historyService = new pskl.service.HistoryService(frameSheet);
this.historyService.init();
this.keyManager = new pskl.KeyManager();

View File

@ -1,26 +1,26 @@
(function () {
var ns = $.namespace("pskl");
ns.HistoryManager = function (framesheet) {
var ns = $.namespace("pskl.service");
ns.HistoryService = function (framesheet) {
this.framesheet = framesheet;
};
ns.HistoryManager.prototype.init = function () {
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));
};
ns.HistoryManager.prototype.saveState = function () {
ns.HistoryService.prototype.saveState = function () {
this.framesheet.getCurrentFrame().saveState();
};
ns.HistoryManager.prototype.undo = function () {
ns.HistoryService.prototype.undo = function () {
this.framesheet.getCurrentFrame().loadPreviousState();
$.publish(Events.FRAMESHEET_RESET);
};
ns.HistoryManager.prototype.redo = function () {
ns.HistoryService.prototype.redo = function () {
this.framesheet.getCurrentFrame().loadNextState();
$.publish(Events.FRAMESHEET_RESET);
};