/*global window:false */ ( function ( $, mw ) { 'use strict'; mw.echo.overlay = { 'updateCount' : function ( newCount ) { var $badge = $( '.mw-echo-notifications-badge' ); $badge.text( newCount ); // newCount could be '99+' or another string. // Checking for number as well just to be paranoid. if ( newCount !== '0' && newCount !== 0 ) { $badge.addClass( 'mw-echo-unread-notifications' ); } else { $badge.removeClass( 'mw-echo-unread-notifications' ); } }, 'configuration' : mw.config.get( 'wgEchoOverlayConfiguration' ), 'buildOverlay' : function ( callback ) { var notificationLimit, $overlay = $( '
' ).addClass( 'mw-echo-overlay' ), $prefLink = $( '#pt-preferences a' ), count = 0, api = new mw.Api(); // Set notification limit based on height of the window notificationLimit = Math.floor( ( $( window ).height() - 134 ) / 90 ); if ( notificationLimit < 1 ) { notificationLimit = 1; } else if ( notificationLimit > 8 ) { notificationLimit = 8; } api.get( { 'action' : 'query', 'meta' : 'notifications', 'notformat' : 'flyout', 'notlimit' : notificationLimit, 'notprop' : 'index|list|count' } ).done( function ( result ) { var notifications = result.query.notifications, unread = [], unreadTotalCount = result.query.notifications.count, $title = $( '' ), $ul = $( '