Skip to content

Commit

Permalink
Issue #287 : Rename addShortcut/removeShortcut to less ambiguous regi…
Browse files Browse the repository at this point in the history
…ster/unregister
  • Loading branch information
juliandescottes committed Nov 12, 2015
1 parent 107751b commit c11e0d5
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 42 deletions.
6 changes: 3 additions & 3 deletions src/js/controller/DrawingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_();
Expand Down
2 changes: 1 addition & 1 deletion src/js/controller/LayersListController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
4 changes: 2 additions & 2 deletions src/js/controller/PaletteController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/js/controller/PalettesListController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/js/controller/ToolController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
};
})();
6 changes: 3 additions & 3 deletions src/js/controller/dialogs/DialogsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};
Expand Down Expand Up @@ -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');
};

Expand All @@ -84,7 +84,7 @@
};

ns.DialogsController.prototype.hideDialogWrapper_ = function () {
pskl.app.shortcutService.removeShortcut('ESC');
pskl.app.shortcutService.unregisterShortcut('ESC');
this.dialogWrapper_.classList.remove('show');
};

Expand Down
8 changes: 4 additions & 4 deletions src/js/controller/piskel/PublicPiskelController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/js/controller/preview/PreviewController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
10 changes: 5 additions & 5 deletions src/js/selection/SelectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
Expand Down
6 changes: 3 additions & 3 deletions src/js/service/HistoryService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/js/service/keyboard/CheatsheetService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
};
Expand Down
8 changes: 4 additions & 4 deletions src/js/service/keyboard/ShortcutService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/js/service/storage/StorageService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions test/js/selection/SelectionManagerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("SelectionManager suite", function() {
* @Mock
*/
pskl.app.shortcutService = {
addShortcut : function () {}
registerShortcut : function () {}
};

/**
Expand All @@ -40,7 +40,7 @@ describe("SelectionManager suite", function() {
selectionManager.init();

selection = new pskl.selection.BaseSelection();

selection.pixels = [];
});

Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/js/service/HistoryServiceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("History Service suite", function() {
}
};
var mockShortcutService = {
addShortcut : function () {}
registerShortcut : function () {}
};
return new pskl.service.HistoryService(mockPiskelController, mockShortcutService);
};
Expand Down
2 changes: 1 addition & 1 deletion test/js/service/storage/StorageServiceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c11e0d5

Please sign in to comment.