mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
Make sure that notification count is defined and properly typed.
Also switch to new badge param for inline style. Change-Id: Ibf4c83e58db98c610b15d77496b7d3776438aadc
This commit is contained in:
parent
e5eb5b5f26
commit
10d827bdb4
|
@ -3,9 +3,15 @@
|
|||
|
||||
mw.echo.overlay = {
|
||||
'updateCount' : function( newCount ) {
|
||||
// Accomodate '10' or '100+'. Numbers need to be
|
||||
// passed as numbers for correct behavior of '0'.
|
||||
if ( !isNaN( newCount ) ) {
|
||||
newCount = Number( newCount );
|
||||
}
|
||||
|
||||
$( '#pt-notifications a' )
|
||||
.text( mw.msg( 'echo-link' ) )
|
||||
.badge( newCount, { 'type' : 'inline' } );
|
||||
.badge( newCount, true );
|
||||
|
||||
mw.echo.overlay.notification_count = newCount;
|
||||
},
|
||||
|
@ -14,7 +20,8 @@
|
|||
|
||||
'buildOverlay' : function( callback ) {
|
||||
var $overlay = $( '<div></div>' ).addClass( 'mw-echo-overlay' ),
|
||||
$link = $( '#pt-notifications a' );
|
||||
$link = $( '#pt-notifications a' ),
|
||||
count = 0;
|
||||
|
||||
$overlay.append(
|
||||
$( '<div/>' )
|
||||
|
@ -77,9 +84,10 @@
|
|||
'notprop' : 'count'
|
||||
}, {
|
||||
'ok' : function( result ) {
|
||||
var count = result.query.notifications.count;
|
||||
|
||||
mw.echo.overlay.updateCount( count );
|
||||
if ( result.query.notifications.count !== undefined ) {
|
||||
count = result.query.notifications.count;
|
||||
mw.echo.overlay.updateCount( count );
|
||||
}
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue