Vulcan/client/views/notifications.js

31 lines
844 B
JavaScript
Raw Normal View History

2012-10-04 11:17:57 +10:00
Template.notifications.helpers({
notifications: function(){
var user=Meteor.user();
2012-10-04 11:45:29 +10:00
if(user && !user.loading)
2012-10-04 17:25:10 +09:00
return user.notifications;
},
notification_count: function(){
var user=Meteor.user();
if(!user.notifications || user.notifications.length==0){
return 'No notifications';
}else if(user.notifications.length==1){
return '1 notification';
}else{
return user.notifications.length+' notifications';
}
},
notification_class: function(){
var user=Meteor.user();
if(!user.notifications || user.notifications.length==0)
return 'no-notifications';
2012-10-04 11:17:57 +10:00
}
2012-10-04 17:25:10 +09:00
});
Template.notifications.events({
'click .notifications-toggle': function(){
$('body').toggleClass('notifications-open');
},
'click .clear-notifications': function(){
Meteor.call('clearNotifications', Meteor.user());
}
})