From 8518f26adb463dce322156184824fd9aa77f227c Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 18 Feb 2014 15:46:03 -0500 Subject: [PATCH] closes #1023 --- public/src/modules/notifications.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) 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($('
  • ' + image + '' + utils.relativeTime(data.unread[x].datetime, true) + '' + data.unread[x].text + '
  • ')); + html += '
  • ' + image + '' + utils.relativeTime(data.unread[x].datetime, true) + '' + data.unread[x].text + '
  • '; } for (x = 0; x < numRead; x++) { @@ -36,18 +36,27 @@ define(function() { } else { image = ''; } - notifList.append($('
  • ' + image + '' + utils.relativeTime(data.read[x].datetime, true) + '' + data.read[x].text + '
  • ')); + html += '
  • ' + image + '' + utils.relativeTime(data.read[x].datetime, true) + '' + data.read[x].text + '
  • '; } + addSeeAllLink(replaceHtml); } else { translator.translate('
  • [[notifications:no_notifs]]
  • ', function(translated) { - notifList.append($(translated)); + html += translated; + addSeeAllLink(replaceHtml); }); } - translator.translate('', function(translated) { - notifList.append($(translated)); - }); + function addSeeAllLink(callback) { + translator.translate('', function(translated) { + html += translated; + callback(); + }); + } + + function replaceHtml() { + notifList.html(html); + } updateNotifCount(data.unread.length);