diff --git a/modules/overlay/ext.echo.overlay.js b/modules/overlay/ext.echo.overlay.js index a2fe72b89..6d00397e8 100644 --- a/modules/overlay/ext.echo.overlay.js +++ b/modules/overlay/ext.echo.overlay.js @@ -11,6 +11,21 @@ } EchoOverlay.prototype = { + /** + * @var array a list of unread notification ids that are visible in the UI + */ + unread: [], + /** + * @var object current count status of notification types + */ + notificationCount: { + /* @var integer length of all notifications (both unread and read) that will be visible in the overlay */ + all: 0, + /* @var string a string representation the current number of unread notifications (1, 99, 99+) */ + unread: '0', + /* @var integer the total number of all unread notifications including those not in the overlay */ + unreadRaw: 0 + }, /** * @param newCount formatted count * @param rawCount unformatted count @@ -24,6 +39,8 @@ } else { $badge.removeClass( 'mw-echo-unread-notifications' ); } + this.notificationCount.unread = newCount; + this.notificationCount.unreadRaw = rawCount; }, configuration: mw.config.get( 'wgEchoOverlayConfiguration' ), @@ -100,17 +117,13 @@ return $overlayFooter; }, - /** - * Builds an Echo overlay header element - * @method - * @param integer length of all notifications (both unread and read) that will be visible in the overlay - * @param integer the total number of all unread notifications including those not in the overlay - * @param string a string representation the current number of unread notifications (1, 99, 99+) - * @param integer the number of unread notifications in the current overlay - * @return jQuery element - */ - _getTitleElement: function( notificationsCount, unreadRawTotalCount, unreadTotalCount, unreadCount ) { + _getTitleElement: function() { var titleText, includeMarkAsReadButton, overflow, + counter = this.notificationCount, + notificationsCount = counter.all, + unreadRawTotalCount = counter.unreadRaw, + unreadTotalCount = counter.unread, + unreadCount = this.unread.length, $title = $( '
' ).addClass( 'mw-echo-overlay-title' ); if ( notificationsCount > 0 ) { @@ -159,17 +172,18 @@ return $title; }, - _buildOverlay: function ( notifications ) { - var $overlay = $( '
' ).addClass( 'mw-echo-overlay' ), - self = this, - unread = [], - unreadTotalCount = notifications.count, - unreadRawTotalCount = notifications.rawcount, - $ul = $( '