(function ($, document, Dashboard) { var getNotificationsSummaryPromise; function getNotificationsSummary() { getNotificationsSummaryPromise = getNotificationsSummaryPromise || ApiClient.getNotificationSummary(Dashboard.getCurrentUserId()); return getNotificationsSummaryPromise; } function updateNotificationCount() { getNotificationsSummary().done(function (summary) { var elem = $('.btnNotifications').removeClass('levelNormal').removeClass('levelWarning').removeClass('levelError').html(summary.UnreadCount); if (summary.UnreadCount) { elem.addClass('level' + summary.MaxUnreadNotificationLevel); } }); } function showNotificationsFlyout() { var context = this; var html = '
Loading...'; html += '
'; html += ''; html += 'No unread notifications.
'); $('.btnMarkReadContainer').hide(); return; } if (notifications.filter(function (n) { return !n.IsRead; }).length) { $('.btnMarkReadContainer').show(); } else { $('.btnMarkReadContainer').hide(); } var html = ''; for (var i = 0, length = notifications.length; i < length; i++) { var notification = notifications[i]; html += getNotificationHtml(notification); } elem.html(html).trigger('create'); } function getNotificationHtml(notification) { var html = ''; var cssClass = notification.IsRead ? "flyoutNotification" : "flyoutNotification unreadFlyoutNotification"; html += '' + notification.Name + '
'; html += '' + humane_date(notification.Date) + '
'; if (notification.Description) { html += '' + notification.Description + '
'; } if (notification.Url) { html += ''; } html += '