mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Issue #287 : Rename addShortcut/removeShortcut to less ambiguous register/unregister
This commit is contained in:
parent
107751b7eb
commit
c11e0d5d8d
@ -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_();
|
||||
|
@ -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 () {
|
||||
|
@ -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,
|
||||
|
@ -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();
|
||||
|
@ -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));
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
@ -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');
|
||||
};
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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');
|
||||
|
@ -28,7 +28,7 @@ describe("History Service suite", function() {
|
||||
}
|
||||
};
|
||||
var mockShortcutService = {
|
||||
addShortcut : function () {}
|
||||
registerShortcut : function () {}
|
||||
};
|
||||
return new pskl.service.HistoryService(mockPiskelController, mockShortcutService);
|
||||
};
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user