0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Merge pull request #4523 from Gargol/issue-4516

Adds ctrl/cmd+s shortcut to whole application with a noop default
This commit is contained in:
Matt Enlow 2014-12-08 11:45:48 -07:00
commit 4c96b92748
6 changed files with 17 additions and 43 deletions

View file

@ -74,11 +74,6 @@ var ShortcutsRoute = Ember.Mixin.create({
activate: function () { activate: function () {
this._super(); this._super();
if (!this.shortcuts) {
return;
}
this.registerShortcuts(); this.registerShortcuts();
}, },

View file

@ -1,7 +1,16 @@
/* global key */ /* global key */
import ShortcutsRoute from 'ghost/mixins/shortcuts-route'; 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) { afterModel: function (model, transition) {
if (this.get('session').isAuthenticated) { 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) { title: function (tokens) {
return tokens.join(' - ') + ' - ' + this.get('config.blogTitle'); return tokens.join(' - ') + ' - ' + this.get('config.blogTitle');
}, },
@ -155,7 +159,10 @@ var ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, Shor
errorObj.el.addClass('input-error'); errorObj.el.addClass('input-error');
} }
}); });
} },
// noop default for unhandled save (used from shortcuts)
save: Ember.K
} }
}); });

View file

@ -2,15 +2,8 @@ import AuthenticatedRoute from 'ghost/routes/authenticated';
import loadingIndicator from 'ghost/mixins/loading-indicator'; import loadingIndicator from 'ghost/mixins/loading-indicator';
import CurrentUserSettings from 'ghost/mixins/current-user-settings'; import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body'; import styleBody from 'ghost/mixins/style-body';
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
import ctrlOrCmd from 'ghost/utils/ctrl-or-cmd';
var shortcuts = {}, var SettingsCodeInjectionRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, CurrentUserSettings, {
SettingsCodeInjectionRoute;
shortcuts[ctrlOrCmd + '+s'] = {action: 'save'};
SettingsCodeInjectionRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, CurrentUserSettings, ShortcutsRoute, {
classNames: ['settings-view-code'], classNames: ['settings-view-code'],
beforeModel: function () { beforeModel: function () {
@ -25,8 +18,6 @@ SettingsCodeInjectionRoute = AuthenticatedRoute.extend(styleBody, loadingIndicat
}); });
}, },
shortcuts: shortcuts,
actions: { actions: {
save: function () { save: function () {
this.get('controller').send('save'); this.get('controller').send('save');

View file

@ -2,15 +2,8 @@ import AuthenticatedRoute from 'ghost/routes/authenticated';
import loadingIndicator from 'ghost/mixins/loading-indicator'; import loadingIndicator from 'ghost/mixins/loading-indicator';
import CurrentUserSettings from 'ghost/mixins/current-user-settings'; import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body'; import styleBody from 'ghost/mixins/style-body';
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
import ctrlOrCmd from 'ghost/utils/ctrl-or-cmd';
var shortcuts = {}, var SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, CurrentUserSettings, {
SettingsGeneralRoute;
shortcuts[ctrlOrCmd + '+s'] = {action: 'save'};
SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, CurrentUserSettings, ShortcutsRoute, {
titleToken: 'General', titleToken: 'General',
classNames: ['settings-view-general'], classNames: ['settings-view-general'],
@ -27,8 +20,6 @@ SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, Cu
}); });
}, },
shortcuts: shortcuts,
actions: { actions: {
save: function () { save: function () {
this.get('controller').send('save'); this.get('controller').send('save');

View file

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

View file

@ -3,7 +3,6 @@ import ctrlOrCmd from 'ghost/utils/ctrl-or-cmd';
var shortcuts = {}; var shortcuts = {};
// General editor shortcuts // General editor shortcuts
shortcuts[ctrlOrCmd + '+s'] = 'save';
shortcuts[ctrlOrCmd + '+alt+p'] = 'publish'; shortcuts[ctrlOrCmd + '+alt+p'] = 'publish';
shortcuts['alt+shift+z'] = 'toggleZenMode'; shortcuts['alt+shift+z'] = 'toggleZenMode';