diff --git a/src/js/controller/DrawingController.js b/src/js/controller/DrawingController.js index 41f5ca4e9..c0f2ea5ab 100644 --- a/src/js/controller/DrawingController.js +++ b/src/js/controller/DrawingController.js @@ -62,9 +62,9 @@ $.subscribe(Events.USER_SETTINGS_CHANGED, this.onUserSettingsChange_.bind(this)); $.subscribe(Events.FRAME_SIZE_CHANGED, this.onFrameSizeChange_.bind(this)); - pskl.app.shortcutService.addShortcut('0', this.resetZoom_.bind(this)); - pskl.app.shortcutService.addShortcut('+', this.increaseZoom_.bind(this, 1)); - pskl.app.shortcutService.addShortcut('-', this.decreaseZoom_.bind(this, 1)); + pskl.app.shortcutService.registerShortcut('0', this.resetZoom_.bind(this)); + pskl.app.shortcutService.registerShortcut('+', this.increaseZoom_.bind(this, 1)); + pskl.app.shortcutService.registerShortcut('-', this.decreaseZoom_.bind(this, 1)); window.setTimeout(function () { this.afterWindowResize_(); diff --git a/src/js/controller/LayersListController.js b/src/js/controller/LayersListController.js index e6fb81baa..deebdd9f3 100644 --- a/src/js/controller/LayersListController.js +++ b/src/js/controller/LayersListController.js @@ -39,7 +39,7 @@ var toggleLayerPreviewTooltip = pskl.utils.TooltipFormatter.format(helpText, TOGGLE_LAYER_SHORTCUT, descriptors); this.toggleLayerPreviewEl.setAttribute('title', toggleLayerPreviewTooltip); - pskl.app.shortcutService.addShortcut(TOGGLE_LAYER_SHORTCUT, this.toggleLayerPreview_.bind(this)); + pskl.app.shortcutService.registerShortcut(TOGGLE_LAYER_SHORTCUT, this.toggleLayerPreview_.bind(this)); }; ns.LayersListController.prototype.updateButtonStatus_ = function () { diff --git a/src/js/controller/PaletteController.js b/src/js/controller/PaletteController.js index 36986b9ad..b09498527 100644 --- a/src/js/controller/PaletteController.js +++ b/src/js/controller/PaletteController.js @@ -10,8 +10,8 @@ $.subscribe(Events.SELECT_PRIMARY_COLOR, this.onColorSelected_.bind(this, {isPrimary:true})); $.subscribe(Events.SELECT_SECONDARY_COLOR, this.onColorSelected_.bind(this, {isPrimary:false})); - pskl.app.shortcutService.addShortcut('X', this.swapColors.bind(this)); - pskl.app.shortcutService.addShortcut('D', this.resetColors.bind(this)); + pskl.app.shortcutService.registerShortcut('X', this.swapColors.bind(this)); + pskl.app.shortcutService.registerShortcut('D', this.resetColors.bind(this)); var spectrumCfg = { showPalette: true, diff --git a/src/js/controller/PalettesListController.js b/src/js/controller/PalettesListController.js index c31e521c1..a9525c549 100644 --- a/src/js/controller/PalettesListController.js +++ b/src/js/controller/PalettesListController.js @@ -37,9 +37,9 @@ $.subscribe(Events.SECONDARY_COLOR_SELECTED, this.highlightSelectedColors.bind(this)); $.subscribe(Events.USER_SETTINGS_CHANGED, $.proxy(this.onUserSettingsChange_, this)); - pskl.app.shortcutService.addShortcuts(['>', 'shift+>'], this.selectNextColor_.bind(this)); - pskl.app.shortcutService.addShortcut('<', this.selectPreviousColor_.bind(this)); - pskl.app.shortcutService.addShortcuts('123465789'.split(''), this.selectColorForKey_.bind(this)); + pskl.app.shortcutService.registerShortcuts(['>', 'shift+>'], this.selectNextColor_.bind(this)); + pskl.app.shortcutService.registerShortcuts('123465789'.split(''), this.selectColorForKey_.bind(this)); + pskl.app.shortcutService.registerShortcut('<', this.selectPreviousColor_.bind(this)); this.fillPaletteList(); this.updateFromUserSettings(); diff --git a/src/js/controller/ToolController.js b/src/js/controller/ToolController.js index a0668a80b..6de16235a 100644 --- a/src/js/controller/ToolController.js +++ b/src/js/controller/ToolController.js @@ -125,7 +125,7 @@ ns.ToolController.prototype.addKeyboardShortcuts_ = function () { for (var i = 0 ; i < this.tools.length ; i++) { - pskl.app.shortcutService.addShortcut(this.tools[i].shortcut, this.onKeyboardShortcut_.bind(this)); + pskl.app.shortcutService.registerShortcut(this.tools[i].shortcut, this.onKeyboardShortcut_.bind(this)); } }; })(); diff --git a/src/js/controller/dialogs/DialogsController.js b/src/js/controller/dialogs/DialogsController.js index 1da679bd0..6ab23f671 100644 --- a/src/js/controller/dialogs/DialogsController.js +++ b/src/js/controller/dialogs/DialogsController.js @@ -27,7 +27,7 @@ $.subscribe(Events.DIALOG_DISPLAY, this.onDialogDisplayEvent_.bind(this)); $.subscribe(Events.DIALOG_HIDE, this.onDialogHideEvent_.bind(this)); - pskl.app.shortcutService.addShortcut('alt+P', this.onDialogDisplayEvent_.bind(this, null, 'create-palette')); + pskl.app.shortcutService.registerShortcut('alt+P', this.onDialogDisplayEvent_.bind(this, null, 'create-palette')); this.dialogWrapper_.classList.add('animated'); }; @@ -65,7 +65,7 @@ }; ns.DialogsController.prototype.showDialogWrapper_ = function () { - pskl.app.shortcutService.addShortcut('ESC', this.hideDialog.bind(this)); + pskl.app.shortcutService.registerShortcut('ESC', this.hideDialog.bind(this)); this.dialogWrapper_.classList.add('show'); }; @@ -84,7 +84,7 @@ }; ns.DialogsController.prototype.hideDialogWrapper_ = function () { - pskl.app.shortcutService.removeShortcut('ESC'); + pskl.app.shortcutService.unregisterShortcut('ESC'); this.dialogWrapper_.classList.remove('show'); }; diff --git a/src/js/controller/piskel/PublicPiskelController.js b/src/js/controller/piskel/PublicPiskelController.js index 1c602e583..d3794e6ba 100644 --- a/src/js/controller/piskel/PublicPiskelController.js +++ b/src/js/controller/piskel/PublicPiskelController.js @@ -30,10 +30,10 @@ this.saveWrap_('moveLayerDown', true); this.saveWrap_('removeCurrentLayer', true); - pskl.app.shortcutService.addShortcut('up', this.selectPreviousFrame.bind(this)); - pskl.app.shortcutService.addShortcut('down', this.selectNextFrame.bind(this)); - pskl.app.shortcutService.addShortcut('n', this.addFrameAtCurrentIndex.bind(this)); - pskl.app.shortcutService.addShortcut('shift+n', this.duplicateCurrentFrame.bind(this)); + pskl.app.shortcutService.registerShortcut('up', this.selectPreviousFrame.bind(this)); + pskl.app.shortcutService.registerShortcut('down', this.selectNextFrame.bind(this)); + pskl.app.shortcutService.registerShortcut('n', this.addFrameAtCurrentIndex.bind(this)); + pskl.app.shortcutService.registerShortcut('shift+n', this.duplicateCurrentFrame.bind(this)); }; ns.PublicPiskelController.prototype.setPiskel = function (piskel, preserveState) { diff --git a/src/js/controller/preview/PreviewController.js b/src/js/controller/preview/PreviewController.js index aad5a81cf..5207c90b3 100644 --- a/src/js/controller/preview/PreviewController.js +++ b/src/js/controller/preview/PreviewController.js @@ -47,8 +47,8 @@ pskl.utils.Event.addEventListener(this.openPopupPreview, 'click', this.onOpenPopupPreviewClick_, this); pskl.utils.Event.addEventListener(this.originalSizeButton, 'click', this.onOriginalSizeButtonClick_, this); - pskl.app.shortcutService.addShortcut(ONION_SKIN_SHORTCUT, this.toggleOnionSkin_.bind(this)); - pskl.app.shortcutService.addShortcut(ORIGINAL_SIZE_SHORTCUT, this.onOriginalSizeButtonClick_.bind(this)); + pskl.app.shortcutService.registerShortcut(ONION_SKIN_SHORTCUT, this.toggleOnionSkin_.bind(this)); + pskl.app.shortcutService.registerShortcut(ORIGINAL_SIZE_SHORTCUT, this.onOriginalSizeButtonClick_.bind(this)); $.subscribe(Events.FRAME_SIZE_CHANGED, this.onFrameSizeChange_.bind(this)); $.subscribe(Events.USER_SETTINGS_CHANGED, $.proxy(this.onUserSettingsChange_, this)); diff --git a/src/js/selection/SelectionManager.js b/src/js/selection/SelectionManager.js index 96d4b04cf..9b95e6f73 100644 --- a/src/js/selection/SelectionManager.js +++ b/src/js/selection/SelectionManager.js @@ -18,11 +18,11 @@ $.subscribe(Events.SELECTION_DISMISSED, $.proxy(this.onSelectionDismissed_, this)); $.subscribe(Events.SELECTION_MOVE_REQUEST, $.proxy(this.onSelectionMoved_, this)); - pskl.app.shortcutService.addShortcut('ctrl+V', this.paste.bind(this)); - pskl.app.shortcutService.addShortcut('ctrl+X', this.cut.bind(this)); - pskl.app.shortcutService.addShortcut('ctrl+C', this.copy.bind(this)); - pskl.app.shortcutService.addShortcut('del', this.erase.bind(this)); - pskl.app.shortcutService.addShortcut('back', this.onBackPressed_.bind(this)); + pskl.app.shortcutService.registerShortcut('ctrl+V', this.paste.bind(this)); + pskl.app.shortcutService.registerShortcut('ctrl+X', this.cut.bind(this)); + pskl.app.shortcutService.registerShortcut('ctrl+C', this.copy.bind(this)); + pskl.app.shortcutService.registerShortcut('del', this.erase.bind(this)); + pskl.app.shortcutService.registerShortcut('back', this.onBackPressed_.bind(this)); $.subscribe(Events.TOOL_SELECTED, $.proxy(this.onToolSelected_, this)); }; diff --git a/src/js/service/HistoryService.js b/src/js/service/HistoryService.js index 82070bad5..4fd09a096 100644 --- a/src/js/service/HistoryService.js +++ b/src/js/service/HistoryService.js @@ -26,9 +26,9 @@ ns.HistoryService.prototype.init = function () { $.subscribe(Events.PISKEL_SAVE_STATE, this.onSaveStateEvent.bind(this)); - this.shortcutService.addShortcut('ctrl+Z', this.undo.bind(this)); - this.shortcutService.addShortcut('ctrl+Y', this.redo.bind(this)); - this.shortcutService.addShortcut('ctrl+shift+Z', this.redo.bind(this)); + this.shortcutService.registerShortcut('ctrl+Z', this.undo.bind(this)); + this.shortcutService.registerShortcut('ctrl+Y', this.redo.bind(this)); + this.shortcutService.registerShortcut('ctrl+shift+Z', this.redo.bind(this)); this.saveState({ type : ns.HistoryService.SNAPSHOT diff --git a/src/js/service/keyboard/CheatsheetService.js b/src/js/service/keyboard/CheatsheetService.js index d9b81373d..53df638b9 100644 --- a/src/js/service/keyboard/CheatsheetService.js +++ b/src/js/service/keyboard/CheatsheetService.js @@ -13,7 +13,7 @@ } this.initMarkup_(); - pskl.app.shortcutService.addShortcuts(['?', 'shift+?'], this.toggleCheatsheet_.bind(this)); + pskl.app.shortcutService.registerShortcuts(['?', 'shift+?'], this.toggleCheatsheet_.bind(this)); pskl.utils.Event.addEventListener(document.body, 'click', this.onBodyClick_, this); @@ -46,13 +46,13 @@ }; ns.CheatsheetService.prototype.showCheatsheet_ = function () { - pskl.app.shortcutService.addShortcut('ESC', this.hideCheatsheet_.bind(this)); + pskl.app.shortcutService.registerShortcut('ESC', this.hideCheatsheet_.bind(this)); this.cheatsheetEl.style.display = 'block'; this.isDisplayed = true; }; ns.CheatsheetService.prototype.hideCheatsheet_ = function () { - pskl.app.shortcutService.removeShortcut('ESC'); + pskl.app.shortcutService.unregisterShortcut('ESC'); this.cheatsheetEl.style.display = 'none'; this.isDisplayed = false; }; diff --git a/src/js/service/keyboard/ShortcutService.js b/src/js/service/keyboard/ShortcutService.js index fec8da8a4..c68b11dd4 100644 --- a/src/js/service/keyboard/ShortcutService.js +++ b/src/js/service/keyboard/ShortcutService.js @@ -21,7 +21,7 @@ * 'ctrl+shift+S' * @param {Function} callback should return true to let the original event perform its default action */ - ns.ShortcutService.prototype.addShortcut = function (rawKey, callback) { + ns.ShortcutService.prototype.registerShortcut = function (rawKey, callback) { var parsedKey = this.parseKey_(rawKey.toLowerCase()); var key = parsedKey.key; @@ -37,13 +37,13 @@ } }; - ns.ShortcutService.prototype.addShortcuts = function (keys, callback) { + ns.ShortcutService.prototype.registerShortcuts = function (keys, callback) { keys.forEach(function (key) { - this.addShortcut(key, callback); + this.registerShortcut(key, callback); }.bind(this)); }; - ns.ShortcutService.prototype.removeShortcut = function (rawKey) { + ns.ShortcutService.prototype.unregisterShortcut = function (rawKey) { var parsedKey = this.parseKey_(rawKey.toLowerCase()); var key = parsedKey.key; var meta = parsedKey.meta; diff --git a/src/js/service/storage/StorageService.js b/src/js/service/storage/StorageService.js index 69bcb6aca..583b9aeed 100644 --- a/src/js/service/storage/StorageService.js +++ b/src/js/service/storage/StorageService.js @@ -10,9 +10,9 @@ }; ns.StorageService.prototype.init = function () { - pskl.app.shortcutService.addShortcut('ctrl+o', this.onOpenKey_.bind(this)); - pskl.app.shortcutService.addShortcut('ctrl+s', this.onSaveKey_.bind(this)); - pskl.app.shortcutService.addShortcut('ctrl+shift+s', this.onSaveAsKey_.bind(this)); + pskl.app.shortcutService.registerShortcut('ctrl+o', this.onOpenKey_.bind(this)); + pskl.app.shortcutService.registerShortcut('ctrl+s', this.onSaveKey_.bind(this)); + pskl.app.shortcutService.registerShortcut('ctrl+shift+s', this.onSaveAsKey_.bind(this)); $.subscribe(Events.BEFORE_SAVING_PISKEL, this.setSavingFlag_.bind(this, true)); $.subscribe(Events.AFTER_SAVING_PISKEL, this.setSavingFlag_.bind(this, false)); diff --git a/test/js/selection/SelectionManagerTest.js b/test/js/selection/SelectionManagerTest.js index 736fe984f..44b20c390 100644 --- a/test/js/selection/SelectionManagerTest.js +++ b/test/js/selection/SelectionManagerTest.js @@ -17,7 +17,7 @@ describe("SelectionManager suite", function() { * @Mock */ pskl.app.shortcutService = { - addShortcut : function () {} + registerShortcut : function () {} }; /** @@ -40,7 +40,7 @@ describe("SelectionManager suite", function() { selectionManager.init(); selection = new pskl.selection.BaseSelection(); - + selection.pixels = []; }); @@ -161,7 +161,7 @@ describe("SelectionManager suite", function() { [R, B, T], [T, R, B] ]); - + selection.move(-1, 0); console.log('[SelectionManager] ... paste out of bounds'); diff --git a/test/js/service/HistoryServiceTest.js b/test/js/service/HistoryServiceTest.js index 66d293dbf..663403a24 100644 --- a/test/js/service/HistoryServiceTest.js +++ b/test/js/service/HistoryServiceTest.js @@ -28,7 +28,7 @@ describe("History Service suite", function() { } }; var mockShortcutService = { - addShortcut : function () {} + registerShortcut : function () {} }; return new pskl.service.HistoryService(mockPiskelController, mockShortcutService); }; diff --git a/test/js/service/storage/StorageServiceTest.js b/test/js/service/storage/StorageServiceTest.js index 5d5a0adea..025890b72 100644 --- a/test/js/service/storage/StorageServiceTest.js +++ b/test/js/service/storage/StorageServiceTest.js @@ -16,7 +16,7 @@ describe("Storage Service test suite", function() { save : function () {} }; pskl.app.shortcutService = { - addShortcut : function () {} + registerShortcut : function () {} }; storageService = new pskl.service.storage.StorageService();