Adds 'save' shortcut to settings screens

closes #4414
- adds `ctrl/cmd+s` shortcuts to `settings/general` screen
- adds `ctrl/cmd+s` shortcuts to `settings/user/xx` screen
- extracts `ctrlOrCmd` variable to separate module for reuse
This commit is contained in:
Nazar Gargol 2014-11-12 21:35:41 +01:00
parent 9aa011037b
commit 777d945f03
4 changed files with 38 additions and 4 deletions

View File

@ -2,8 +2,15 @@ import AuthenticatedRoute from 'ghost/routes/authenticated';
import loadingIndicator from 'ghost/mixins/loading-indicator';
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body';
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
import ctrlOrCmd from 'ghost/utils/ctrl-or-cmd';
var SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, CurrentUserSettings, {
var shortcuts = {},
SettingsGeneralRoute;
shortcuts[ctrlOrCmd + '+s'] = {action: 'save'};
SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, CurrentUserSettings, ShortcutsRoute, {
classNames: ['settings-view-general'],
beforeModel: function () {
@ -16,6 +23,14 @@ var SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator
return this.store.find('setting', {type: 'blog,theme'}).then(function (records) {
return records.get('firstObject');
});
},
shortcuts: shortcuts,
actions: {
save: function () {
this.get('controller').send('save');
}
}
});

View File

@ -1,7 +1,14 @@
import AuthenticatedRoute from 'ghost/routes/authenticated';
import styleBody from 'ghost/mixins/style-body';
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
import ctrlOrCmd from 'ghost/utils/ctrl-or-cmd';
var SettingsUserRoute = AuthenticatedRoute.extend(styleBody, {
var shortcuts = {},
SettingsUserRoute;
shortcuts[ctrlOrCmd + '+s'] = {action: 'save'};
SettingsUserRoute = AuthenticatedRoute.extend(styleBody, ShortcutsRoute, {
classNames: ['settings-view-user'],
model: function (params) {
@ -44,6 +51,14 @@ var SettingsUserRoute = AuthenticatedRoute.extend(styleBody, {
}
this._super();
},
shortcuts: shortcuts,
actions: {
save: function () {
this.get('controller').send('save');
}
}
});

View File

@ -0,0 +1,3 @@
var ctrlOrCmd = navigator.userAgent.indexOf('Mac') !== -1 ? 'command' : 'ctrl';
export default ctrlOrCmd;

View File

@ -1,5 +1,6 @@
var shortcuts = {},
ctrlOrCmd = navigator.userAgent.indexOf('Mac') !== -1 ? 'command' : 'ctrl';
import ctrlOrCmd from 'ghost/utils/ctrl-or-cmd';
var shortcuts = {};
// General editor shortcuts
shortcuts[ctrlOrCmd + '+s'] = 'save';