|
|
|
@ -96,26 +96,7 @@
|
|
|
|
|
notifTrigger.addEventListener('click', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (notifContainer.className.indexOf('open') === -1) {
|
|
|
|
|
socket.emit('api:notifications.get');
|
|
|
|
|
socket.emit('api:notifications.mark_all_read', null, function() {
|
|
|
|
|
notifIcon.className = 'icon-circle-blank';
|
|
|
|
|
utils.refreshTitle();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
notifList.addEventListener('click', function(e) {
|
|
|
|
|
var target;
|
|
|
|
|
switch(e.target.nodeName) {
|
|
|
|
|
case 'SPAN': target = e.target.parentNode.parentNode; break;
|
|
|
|
|
case 'A': target = e.target.parentNode; break;
|
|
|
|
|
case 'li': target = e.target; break;
|
|
|
|
|
}
|
|
|
|
|
if (target) {
|
|
|
|
|
var nid = parseInt(target.getAttribute('data-nid'));
|
|
|
|
|
if (nid > 0) socket.emit('api:notifications.mark_read', nid);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
socket.on('api:notifications.get', function(data) {
|
|
|
|
|
socket.emit('api:notifications.get', null, function(data) {
|
|
|
|
|
var notifFrag = document.createDocumentFragment(),
|
|
|
|
|
notifEl = document.createElement('li'),
|
|
|
|
|
numRead = data.read.length,
|
|
|
|
@ -143,6 +124,25 @@
|
|
|
|
|
|
|
|
|
|
if (data.unread.length > 0) notifIcon.className = 'icon-circle active';
|
|
|
|
|
else notifIcon.className = 'icon-circle-blank';
|
|
|
|
|
|
|
|
|
|
socket.emit('api:notifications.mark_all_read', null, function() {
|
|
|
|
|
notifIcon.className = 'icon-circle-blank';
|
|
|
|
|
utils.refreshTitle();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
notifList.addEventListener('click', function(e) {
|
|
|
|
|
var target;
|
|
|
|
|
switch(e.target.nodeName) {
|
|
|
|
|
case 'SPAN': target = e.target.parentNode.parentNode; break;
|
|
|
|
|
case 'A': target = e.target.parentNode; break;
|
|
|
|
|
case 'li': target = e.target; break;
|
|
|
|
|
}
|
|
|
|
|
if (target) {
|
|
|
|
|
var nid = parseInt(target.getAttribute('data-nid'));
|
|
|
|
|
if (nid > 0) socket.emit('api:notifications.mark_read', nid);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
socket.on('event:new_notification', function() {
|
|
|
|
|
document.querySelector('.notifications a i').className = 'icon-circle active';
|
|
|
|
|