(function ($, document, Dashboard, LibraryBrowser) { function notifications() { var self = this; self.getNotificationsSummaryPromise = null; self.total = 0; self.getNotificationsSummary = function() { self.getNotificationsSummaryPromise = self.getNotificationsSummaryPromise || ApiClient.getNotificationSummary(Dashboard.getCurrentUserId()); return self.getNotificationsSummaryPromise; }; self.updateNotificationCount = function() { self.getNotificationsSummary().done(function(summary) { var item = $('.btnNotifications').removeClass('levelNormal').removeClass('levelWarning').removeClass('levelError').html(summary.UnreadCount); if (summary.UnreadCount) { item.addClass('level' + summary.MaxUnreadNotificationLevel); } }); }; self.showNotificationsFlyout = function() { var context = this; var html = '
Loading...'; html += '
'; html += ''; html += ''; html += 'No unread notifications.
'); btn.hide(); return; } Notifications.total = totalRecordCount; if (list.filter(function (n) { return !n.IsRead; }).length) { btn.show(); } else { btn.hide(); } var html = ''; if (totalRecordCount > limit && showPaging === true) { var query = { StartIndex: startIndex, Limit: limit }; html += LibraryBrowser.getPagingHtml(query, totalRecordCount, false, limit, false); } for (var i = 0, length = list.length; i < length; i++) { var notification = list[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 += '