(function ($, document, Dashboard, LibraryBrowser) { function notifications() { var self = this; self.getNotificationsSummaryPromise = null; self.total = 0; self.getNotificationsSummary = function () { var apiClient = ConnectionManager.currentApiClient(); if (!apiClient) { return; } self.getNotificationsSummaryPromise = self.getNotificationsSummaryPromise || apiClient.getNotificationSummary(Dashboard.getCurrentUserId()); return self.getNotificationsSummaryPromise; }; self.updateNotificationCount = function () { if (!Dashboard.getCurrentUserId()) { return; } var promise = self.getNotificationsSummary(); if (!promise) { return; } promise.done(function (summary) { var item = $('.btnNotificationsInner').removeClass('levelNormal').removeClass('levelWarning').removeClass('levelError').html(summary.UnreadCount); if (summary.UnreadCount) { item.addClass('level' + summary.MaxUnreadNotificationLevel); } }); }; self.showNotificationsFlyout = function () { var html = '
' + Globalize.translate('LabelNoUnreadNotifications') + '
'); if (btn) { btn.hide(); } return; } Notifications.total = totalRecordCount; if (btn) { 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 += '