mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
c3ad1ae9e2
No Issue - Switches to the newer style of dependency injection. - Instead of injection Controllers via "needs," use Ember.inject.controller(). - Get rid of initializers that were only injecting objects into various factories. Converts these objects into Ember.Service objects and declaratively inject them where needed via Ember.inject.service(). The added benefit to this is that it's no longer a mystery where these properties/methods come from and it's straightforward to inject them where needed.
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
import Ember from 'ember';
|
|
|
|
export default Ember.Component.extend({
|
|
tagName: 'article',
|
|
classNames: ['gh-notification', 'gh-notification-green'],
|
|
classNameBindings: ['typeClass'],
|
|
|
|
message: null,
|
|
|
|
notifications: Ember.inject.service(),
|
|
|
|
typeClass: Ember.computed(function () {
|
|
var classes = '',
|
|
message = this.get('message'),
|
|
type,
|
|
dismissible;
|
|
|
|
// Check to see if we're working with a DS.Model or a plain JS object
|
|
if (typeof message.toJSON === 'function') {
|
|
type = message.get('type');
|
|
dismissible = message.get('dismissible');
|
|
} else {
|
|
type = message.type;
|
|
dismissible = message.dismissible;
|
|
}
|
|
|
|
classes += 'notification-' + type;
|
|
|
|
if (type === 'success' && dismissible !== false) {
|
|
classes += ' notification-passive';
|
|
}
|
|
|
|
return classes;
|
|
}),
|
|
|
|
didInsertElement: function () {
|
|
var self = this;
|
|
|
|
self.$().on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', function (event) {
|
|
if (event.originalEvent.animationName === 'fade-out') {
|
|
self.get('notifications').removeObject(self.get('message'));
|
|
}
|
|
});
|
|
},
|
|
|
|
actions: {
|
|
closeNotification: function () {
|
|
this.get('notifications').closeNotification(this.get('message'));
|
|
}
|
|
}
|
|
});
|