Fixes to the toolbar link for notifications per Vibha

New badge behavior - Show badge even if zero notifications
Enable long and short links - i.e. 'Notification (X)' or just '(X)'

Depends on core change https://gerrit.wikimedia.org/r/#/c/38258/

Change-Id: Idc2288a4ddd0bf788ccdadb96d4744d223edaf0a
This commit is contained in:
Kaldari 2012-12-11 18:18:51 -08:00
parent d2d59c1d47
commit 704147d1d2
3 changed files with 28 additions and 11 deletions

View file

@ -163,6 +163,10 @@ $wgEchoDisableStandardEmail = true;
// Whether to turn on email batch function
$wgEchoEnableEmailBatch = true;
// Show a 'Notifications' link with badge in the user toolbar at the top of the page.
// Otherwise, only show a badge next to the username.
$wgEchoShowFullNotificationsLink = false;
// The organization address, the value should be defined in LocalSettings.php
$wgEchoEmailFooterAddress = '';

View file

@ -220,26 +220,30 @@ class EchoHooks {
* @return bool true in all cases
*/
static function onPersonalUrls( &$personal_urls, &$title ) {
global $wgUser;
// Add a "My notifications" item to personal URLs
global $wgUser, $wgEchoShowFullNotificationsLink;
if ( $wgUser->isAnon() || !$wgUser->getOption( 'echo-notify-link' ) ) {
return true;
}
$notificationCount = EchoNotificationController::getNotificationCount( $wgUser );
$msg = wfMessage( $notificationCount == 0 ? 'echo-link' : 'echo-link-new' );
if ( $wgEchoShowFullNotificationsLink ) {
// Add a "Notifications" item to personal URLs
$msg = wfMessage( $notificationCount == 0 ? 'echo-link' : 'echo-link-new' );
$text = $msg->params( EchoNotificationController::formatNotificationCount( $notificationCount ) )->text();
} else {
// Just add a number
$text = wfMessage( 'parentheses', $notificationCount )->plain();
}
$url = SpecialPage::getTitleFor( 'Notifications' )->getLocalURL();
$notificationsLink = array(
'href' => $url,
'text' => $msg->params( EchoNotificationController::formatNotificationCount( $notificationCount ) )->text(),
'active' => $notificationCount > 0,
'text' => $text,
'active' => ( $url == $title->getLocalUrl() ),
);
$insertUrls = array( 'notifications' => $notificationsLink );
$personal_urls = wfArrayInsertAfter( $personal_urls, $insertUrls, 'watchlist' );
$personal_urls = wfArrayInsertAfter( $personal_urls, $insertUrls, 'userpage' );
return true;
}
@ -261,6 +265,7 @@ class EchoHooks {
* @return bool true in all cases
*/
public static function makeGlobalVariablesScript( &$vars, OutputPage $outputPage ) {
global $wgEchoShowFullNotificationsLink;
$user = $outputPage->getUser();
// Provide info for the Overlay
@ -268,6 +273,7 @@ class EchoHooks {
$timestamp = new MWTimestamp( wfTimestampNow() );
if ( ! $user->isAnon() ) {
$vars['wgEchoOverlayConfiguration'] = array(
'notifications-link-full' => $wgEchoShowFullNotificationsLink,
'timestamp' => $timestamp->getTimestamp( TS_UNIX ),
'notification-count' => EchoNotificationController::getFormattedNotificationCount( $user ),
);

View file

@ -12,9 +12,16 @@
newCount = Number( newCount );
}
$( '#pt-notifications a' )
.text( mw.msg( 'echo-link' ) )
.badge( newCount, true );
if ( mw.echo.overlay.configuration['notifications-link-full'] ) {
$( '#pt-notifications a' )
.text( mw.msg( 'echo-link' ) )
.badge( newCount, true, true );
} else {
$( '#pt-notifications a' )
.text( '' )
.badge( newCount, true, true );
$( '#pt-notifications .mw-badge' ).css( 'margin-left', '-5px' );
}
mw.echo.overlay.notification_count = newCount;
},