0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00
ghost/core/client/app/components/gh-alert.js

40 lines
1 KiB
JavaScript
Raw Normal View History

2015-05-21 11:03:24 -06:00
import Ember from 'ember';
export default Ember.Component.extend({
2015-05-21 11:03:24 -06:00
tagName: 'article',
classNames: ['gh-alert', 'gh-alert-blue'],
classNameBindings: ['typeClass'],
notifications: Ember.inject.service(),
2015-05-21 11:03:24 -06:00
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;
}),
actions: {
closeNotification: function () {
this.get('notifications').closeNotification(this.get('message'));
2015-05-21 11:03:24 -06:00
}
}
});