2014-03-22 16:08:15 +04:00
|
|
|
var NotificationComponent = Ember.Component.extend({
|
|
|
|
classNames: ['js-bb-notification'],
|
|
|
|
|
2014-07-09 08:17:30 +04:00
|
|
|
typeClass: 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;
|
|
|
|
}.property(),
|
|
|
|
|
2014-03-22 16:08:15 +04:00
|
|
|
didInsertElement: function () {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
self.$().on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', function (event) {
|
|
|
|
/* jshint unused: false */
|
2014-07-13 18:00:25 +04:00
|
|
|
if (event.originalEvent.animationName === 'fade-out') {
|
|
|
|
self.notifications.removeObject(self.get('message'));
|
|
|
|
}
|
2014-03-22 16:08:15 +04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
closeNotification: function () {
|
|
|
|
var self = this;
|
2014-06-30 01:45:03 +04:00
|
|
|
self.notifications.closeNotification(self.get('message'));
|
2014-03-22 16:08:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-30 01:45:03 +04:00
|
|
|
export default NotificationComponent;
|