Ghost/core/client/app/components/gh-alert.js

36 lines
837 B
JavaScript
Raw Normal View History

2015-05-21 20:03:24 +03:00
import Ember from 'ember';
export default Ember.Component.extend({
2015-05-21 20:03:24 +03:00
tagName: 'article',
classNames: ['gh-alert'],
2015-05-21 20:03:24 +03:00
classNameBindings: ['typeClass'],
notifications: Ember.inject.service(),
2015-05-21 20:03:24 +03:00
typeClass: Ember.computed(function () {
var classes = '',
message = this.get('message'),
type = Ember.get(message, 'type'),
typeMapping;
typeMapping = {
success: 'green',
error: 'red',
warn: 'yellow',
info: 'blue'
};
if (typeMapping[type] !== undefined) {
classes += 'gh-alert-' + typeMapping[type];
2015-05-21 20:03:24 +03:00
}
return classes;
}),
actions: {
closeNotification: function () {
this.get('notifications').closeNotification(this.get('message'));
2015-05-21 20:03:24 +03:00
}
}
});