Skip to content

Node.js based forum software built for the modern web

closes #1023

Baris Soner Usakli8518f26adb46
diff --git a/public/src/modules/notifications.js b/public/src/modules/notifications.js
index f1c0541723..2d150379a2 100644
--- a/public/src/modules/notifications.js
+++ b/public/src/modules/notifications.js
@@ -17,7 +17,7 @@ define(function() {
numUnread = data.unread.length,
x;
- notifList.html('');
+ var html = '';
if (!err && (data.read.length + data.unread.length) > 0) {
var image = '';
@@ -27,7 +27,7 @@ define(function() {
} else {
image = '';
}
- notifList.append($('<li class="' + (data.unread[x].readClass || '') + '"><a href="' + data.unread[x].path + '">' + image + '<span class="pull-right relTime">' + utils.relativeTime(data.unread[x].datetime, true) + '</span><span class="text">' + data.unread[x].text + '</span></a></li>'));
+ html += '<li class="' + (data.unread[x].readClass || '') + '"><a href="' + data.unread[x].path + '">' + image + '<span class="pull-right relTime">' + utils.relativeTime(data.unread[x].datetime, true) + '</span><span class="text">' + data.unread[x].text + '</span></a></li>';
}
for (x = 0; x < numRead; x++) {
@@ -36,18 +36,27 @@ define(function() {
} else {
image = '';
}
- notifList.append($('<li class="' + data.read[x].readClass + '"><a href="' + data.read[x].path + '">' + image + '<span class="pull-right relTime">' + utils.relativeTime(data.read[x].datetime, true) + '</span><span class="text">' + data.read[x].text + '</span></a></li>'));
+ html += '<li class="' + data.read[x].readClass + '"><a href="' + data.read[x].path + '">' + image + '<span class="pull-right relTime">' + utils.relativeTime(data.read[x].datetime, true) + '</span><span class="text">' + data.read[x].text + '</span></a></li>';
}
+ addSeeAllLink(replaceHtml);
} else {
translator.translate('<li class="no-notifs"><a>[[notifications:no_notifs]]</a></li>', function(translated) {
- notifList.append($(translated));
+ html += translated;
+ addSeeAllLink(replaceHtml);
});
}
- translator.translate('<li class="pagelink"><a href="' + RELATIVE_PATH + '/notifications">[[notifications:see_all]]</a></li>', function(translated) {
- notifList.append($(translated));
- });
+ function addSeeAllLink(callback) {
+ translator.translate('<li class="pagelink"><a href="' + RELATIVE_PATH + '/notifications">[[notifications:see_all]]</a></li>', function(translated) {
+ html += translated;
+ callback();
+ });
+ }
+
+ function replaceHtml() {
+ notifList.html(html);
+ }
updateNotifCount(data.unread.length);