You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nodebb/public/src/client/notifications.js

35 lines
873 B
JavaScript

10 years ago
'use strict';
/* globals define, socket, app */
10 years ago
define('forum/notifications', ['components', 'notifications'], function(components, notifs) {
var Notifications = {};
Notifications.init = function() {
var listEl = $('.notifications-list');
10 years ago
listEl.on('click', '[component="notifications/item/link"]', function(e) {
10 years ago
var nid = $(this).parents('[data-nid]').attr('data-nid');
socket.emit('notifications.markRead', nid, function(err) {
if (err) {
return app.alertError(err);
}
});
10 years ago
});
$('.timeago').timeago();
components.get('notifications/mark_all').on('click', function() {
10 years ago
socket.emit('notifications.markAllRead', function(err) {
10 years ago
if (err) {
return app.alertError(err.message);
}
components.get('notifications/item').removeClass('unread');
10 years ago
notifs.updateNotifCount(0);
10 years ago
});
});
10 years ago
};
return Notifications;
});