Adds ctrl/cmd+s shortcut to whole application with a noop default
closes #4516 - shortcut for ctrl/cmd+s on application level - shortens a syntax for any route that is using 'save' method, shortcuts object doesn't have to be defined at all, only the save action.
This commit is contained in:
parent
aca7577b60
commit
7e16ef328d
@ -74,11 +74,6 @@ var ShortcutsRoute = Ember.Mixin.create({
|
||||
|
||||
activate: function () {
|
||||
this._super();
|
||||
|
||||
if (!this.shortcuts) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.registerShortcuts();
|
||||
},
|
||||
|
||||
|
@ -1,7 +1,16 @@
|
||||
/* global key */
|
||||
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
|
||||
import ctrlOrCmd from 'ghost/utils/ctrl-or-cmd';
|
||||
|
||||
var ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, ShortcutsRoute, {
|
||||
var ApplicationRoute,
|
||||
shortcuts = {};
|
||||
|
||||
shortcuts.esc = {action: 'closePopups', scope: 'all'};
|
||||
shortcuts.enter = {action: 'confirmModal', scope: 'modal'};
|
||||
shortcuts[ctrlOrCmd + '+s'] = {action: 'save', scope: 'all'};
|
||||
|
||||
ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, ShortcutsRoute, {
|
||||
shortcuts: shortcuts,
|
||||
|
||||
afterModel: function (model, transition) {
|
||||
if (this.get('session').isAuthenticated) {
|
||||
@ -9,11 +18,6 @@ var ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, Shor
|
||||
}
|
||||
},
|
||||
|
||||
shortcuts: {
|
||||
esc: {action: 'closePopups', scope: 'all'},
|
||||
enter: {action: 'confirmModal', scope: 'modal'}
|
||||
},
|
||||
|
||||
title: function (tokens) {
|
||||
return tokens.join(' - ') + ' - ' + this.get('config.blogTitle');
|
||||
},
|
||||
@ -155,7 +159,10 @@ var ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, Shor
|
||||
errorObj.el.addClass('input-error');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// noop default for unhandled save (used from shortcuts)
|
||||
save: Ember.K
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2,15 +2,8 @@ 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 shortcuts = {},
|
||||
SettingsCodeInjectionRoute;
|
||||
|
||||
shortcuts[ctrlOrCmd + '+s'] = {action: 'save'};
|
||||
|
||||
SettingsCodeInjectionRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, CurrentUserSettings, ShortcutsRoute, {
|
||||
var SettingsCodeInjectionRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, CurrentUserSettings, {
|
||||
classNames: ['settings-view-code'],
|
||||
|
||||
beforeModel: function () {
|
||||
@ -25,8 +18,6 @@ SettingsCodeInjectionRoute = AuthenticatedRoute.extend(styleBody, loadingIndicat
|
||||
});
|
||||
},
|
||||
|
||||
shortcuts: shortcuts,
|
||||
|
||||
actions: {
|
||||
save: function () {
|
||||
this.get('controller').send('save');
|
||||
|
@ -2,15 +2,8 @@ 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 shortcuts = {},
|
||||
SettingsGeneralRoute;
|
||||
|
||||
shortcuts[ctrlOrCmd + '+s'] = {action: 'save'};
|
||||
|
||||
SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, CurrentUserSettings, ShortcutsRoute, {
|
||||
var SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, CurrentUserSettings, {
|
||||
titleToken: 'General',
|
||||
|
||||
classNames: ['settings-view-general'],
|
||||
@ -27,8 +20,6 @@ SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, Cu
|
||||
});
|
||||
},
|
||||
|
||||
shortcuts: shortcuts,
|
||||
|
||||
actions: {
|
||||
save: function () {
|
||||
this.get('controller').send('save');
|
||||
|
@ -1,14 +1,7 @@
|
||||
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 shortcuts = {},
|
||||
SettingsUserRoute;
|
||||
|
||||
shortcuts[ctrlOrCmd + '+s'] = {action: 'save'};
|
||||
|
||||
SettingsUserRoute = AuthenticatedRoute.extend(styleBody, ShortcutsRoute, {
|
||||
var SettingsUserRoute = AuthenticatedRoute.extend(styleBody, {
|
||||
titleToken: 'User',
|
||||
|
||||
classNames: ['settings-view-user'],
|
||||
@ -55,8 +48,6 @@ SettingsUserRoute = AuthenticatedRoute.extend(styleBody, ShortcutsRoute, {
|
||||
this._super();
|
||||
},
|
||||
|
||||
shortcuts: shortcuts,
|
||||
|
||||
actions: {
|
||||
save: function () {
|
||||
this.get('controller').send('save');
|
||||
|
@ -3,7 +3,6 @@ import ctrlOrCmd from 'ghost/utils/ctrl-or-cmd';
|
||||
var shortcuts = {};
|
||||
|
||||
// General editor shortcuts
|
||||
shortcuts[ctrlOrCmd + '+s'] = 'save';
|
||||
shortcuts[ctrlOrCmd + '+alt+p'] = 'publish';
|
||||
shortcuts['alt+shift+z'] = 'toggleZenMode';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user