Ghost/ghost/admin/mixins/editor-route-base.js
Matt Enlow 71bee2fd46 Implement Shortcuts in Ember
Closes #2988, #2752
Ref #1463, #2984,
 # Shortcuts via Keymaster
- Added KeyMaster to bower dependencies. KeyMaster is a minimal keyboard
  shortcuts library.
- Added `ShortcutsRouteMixin` for routes that will use shortcuts.
  Currently, only routes can have shortcuts. See the extensive comment
  at the top of `core/client/mixins/shortcuts-route.js` for a
  description of how to implement shortcuts.

 ## Other Changes
- Injected popover service into ApplicationRoute
- Created `EditorRouteBase` mixin for the `editor.new` and
  `editor.edit` routes to mixin.
- `StyleBodyMixin` now calls `this._super()` on `activate` and
  `deactivate` to play nicely with other mixins.

 ## Shortcuts and Stubs implemented
 #### Application-Wide
- `'esc':'closePopups'` shortcut **stub** to close popovers,
 modals, and notifcations

 #### Editor Shortcuts
- `'ctrl+s, command+s': 'save'` note that `command` is the
  `meta` key.
- `'ctrl+alt+p': 'publish'`
- `'ctrl+alt+z': 'toggleZenMode'`
2014-06-19 15:07:42 -06:00

26 lines
739 B
JavaScript

import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
import styleBody from 'ghost/mixins/style-body';
var EditorRouteBase = Ember.Mixin.create(styleBody, ShortcutsRoute, {
shortcuts: {
'ctrl+s, command+s': 'save',
'ctrl+alt+p': 'publish',
'ctrl+alt+z': 'toggleZenMode'
},
actions: {
save: function () {
this.get('controller').send('save');
},
publish: function () {
var controller = this.get('controller');
controller.send('setSaveType', 'publish');
controller.send('save');
},
toggleZenMode: function () {
Ember.$('body').toggleClass('zen');
}
}
});
export default EditorRouteBase;