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