mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 17:32:15 +03:00
71bee2fd46
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'`
56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
var Notifications = Ember.ArrayProxy.extend({
|
|
content: Ember.A(),
|
|
timeout: 3000,
|
|
pushObject: function (object) {
|
|
object.typeClass = 'notification-' + object.type;
|
|
// This should be somewhere else.
|
|
if (object.type === 'success') {
|
|
object.typeClass = object.typeClass + ' notification-passive';
|
|
}
|
|
this._super(object);
|
|
},
|
|
showError: function (message) {
|
|
this.pushObject({
|
|
type: 'error',
|
|
message: message
|
|
});
|
|
},
|
|
showErrors: function (errors) {
|
|
for (var i = 0; i < errors.length; i += 1) {
|
|
this.showError(errors[i].message || errors[i]);
|
|
}
|
|
},
|
|
showAPIError: function (resp, defaultErrorText) {
|
|
defaultErrorText = defaultErrorText || 'There was a problem on the server, please try again.';
|
|
|
|
if (resp && resp.jqXHR && resp.jqXHR.responseJSON && resp.jqXHR.responseJSON.error) {
|
|
this.showError(resp.jqXHR.responseJSON.error);
|
|
} else {
|
|
this.showError(defaultErrorText);
|
|
}
|
|
},
|
|
showInfo: function (message) {
|
|
this.pushObject({
|
|
type: 'info',
|
|
message: message
|
|
});
|
|
},
|
|
showSuccess: function (message) {
|
|
this.pushObject({
|
|
type: 'success',
|
|
message: message
|
|
});
|
|
},
|
|
showWarn: function (message) {
|
|
this.pushObject({
|
|
type: 'warn',
|
|
message: message
|
|
});
|
|
},
|
|
closeAll: function () {
|
|
window.alert('@TODO implement closeALl notifications');
|
|
}
|
|
});
|
|
|
|
export default Notifications;
|