2015-02-13 07:22:32 +03:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
2014-03-22 16:08:15 +04:00
|
|
|
var NotificationComponent = Ember.Component.extend({
|
|
|
|
classNames: ['js-bb-notification'],
|
|
|
|
|
2014-07-30 05:57:19 +04:00
|
|
|
typeClass: Ember.computed(function () {
|
2014-07-09 08:17:30 +04:00
|
|
|
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');
|
2014-10-25 01:09:50 +04:00
|
|
|
} else {
|
2014-07-09 08:17:30 +04:00
|
|
|
type = message.type;
|
|
|
|
dismissible = message.dismissible;
|
|
|
|
}
|
|
|
|
|
|
|
|
classes += 'notification-' + type;
|
|
|
|
|
|
|
|
if (type === 'success' && dismissible !== false) {
|
|
|
|
classes += ' notification-passive';
|
|
|
|
}
|
|
|
|
|
|
|
|
return classes;
|
2014-07-30 05:57:19 +04:00
|
|
|
}),
|
2014-07-09 08:17:30 +04:00
|
|
|
|
2014-03-22 16:08:15 +04:00
|
|
|
didInsertElement: function () {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
self.$().on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', function (event) {
|
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;
|