Ghost/core/client/components/gh-notifications.js
Jason Williams b7be74907f Add a notify action to the notifications component
Refs #3160
- gh-notifications component now takes an optional notify
  parameter.  If present it will be invoked as an action
  when a notification is added or removed.
- Add a data-notification-count attribute to the main container
  that tracks the number of "top" notification messages that
  are currently being shown.
2014-07-17 17:34:38 +00:00

25 lines
812 B
JavaScript

var NotificationsComponent = Ember.Component.extend({
tagName: 'aside',
classNames: 'notifications',
classNameBindings: ['location'],
messages: Ember.computed.filter('notifications', function (notification) {
// If this instance of the notifications component has no location affinity
// then it gets all notifications
if (!this.get('location')) {
return true;
}
var displayLocation = (typeof notification.toJSON === 'function') ?
notification.get('location') : notification.location;
return this.get('location') === displayLocation;
}),
messageCountObserver: function () {
this.sendAction('notify', this.get('messages').length);
}.observes('messages.[]')
});
export default NotificationsComponent;