diff --git a/core/client/routes/settings/general.js b/core/client/routes/settings/general.js index ce6a3a5475..1f4008d100 100644 --- a/core/client/routes/settings/general.js +++ b/core/client/routes/settings/general.js @@ -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'); + } } }); diff --git a/core/client/routes/settings/users/user.js b/core/client/routes/settings/users/user.js index 0a9df80841..aea2cf69a7 100644 --- a/core/client/routes/settings/users/user.js +++ b/core/client/routes/settings/users/user.js @@ -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'); + } } }); diff --git a/core/client/utils/ctrl-or-cmd.js b/core/client/utils/ctrl-or-cmd.js new file mode 100644 index 0000000000..5b1a518d82 --- /dev/null +++ b/core/client/utils/ctrl-or-cmd.js @@ -0,0 +1,3 @@ +var ctrlOrCmd = navigator.userAgent.indexOf('Mac') !== -1 ? 'command' : 'ctrl'; + +export default ctrlOrCmd; diff --git a/core/client/utils/editor-shortcuts.js b/core/client/utils/editor-shortcuts.js index c5482abf85..f6ee24ac6d 100644 --- a/core/client/utils/editor-shortcuts.js +++ b/core/client/utils/editor-shortcuts.js @@ -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';