Merge "Make middle-clicking badge work"

This commit is contained in:
jenkins-bot 2015-09-24 23:16:07 +00:00 committed by Gerrit Code Review
commit a206bdd9ef
3 changed files with 18 additions and 4 deletions

View file

@ -33,9 +33,14 @@
};
// Respond to click on the notification button and load the UI on demand
$( '.mw-echo-notification-badge-nojs' ).click( function () {
$( '.mw-echo-notification-badge-nojs' ).click( function ( e ) {
var myType = $( this ).parent().prop( 'id' ) === 'pt-notifications-alert' ? 'alert' : 'message',
time = mw.now();
if ( e.which !== 1 ) {
return;
}
// Dim the button while we load
$( this ).addClass( 'mw-echo-notifications-badge-dimmed' );
@ -56,7 +61,8 @@
numItems: numMessages,
hasUnseen: hasUnseenMessages,
badgeIcon: 'speechBubble',
links: links
links: links,
href: $existingMessageLink.attr( 'href' )
} );
// HACK: avoid late debouncedUpdateThemeClasses
mw.echo.ui.messageWidget.badgeButton.debouncedUpdateThemeClasses();
@ -81,7 +87,8 @@
seen: 'bell',
unseen: 'bellOn'
},
links: links
links: links,
href: $existingAlertLink.attr( 'href' )
} );
// HACK: avoid late debouncedUpdateThemeClasses
mw.echo.ui.alertWidget.badgeButton.debouncedUpdateThemeClasses();

View file

@ -15,6 +15,7 @@
* unseen: 'bellOn',
* seen: 'bell'
* } }
* @cfg {string} [href] URL the badge links to
*/
mw.echo.ui.BadgeLinkWidget = function MwEchoUiBadgeLinkWidget( config ) {
config = config || {};
@ -30,6 +31,10 @@
OO.ui.mixin.FlaggedElement.call( this, $.extend( {}, config, { $flagged: this.$element } ) );
this.$element.addClass( 'mw-echo-notifications-badge' );
if ( config.href !== undefined && OO.ui.isSafeUrl( config.href ) ) {
this.$element.attr( 'href', config.href );
}
};
OO.inheritClass( mw.echo.ui.BadgeLinkWidget, OO.ui.Widget );

View file

@ -20,6 +20,7 @@
* unseen: 'bellOn',
* seen: 'bell'
* } }
* @cfg {string} [href] URL the badge links to
*/
mw.echo.ui.NotificationBadgeWidget = function MwEchoUiNotificationBadgeButtonPopupWidget( config ) {
var buttonFlags, allNotificationsButton, preferencesButton, footerButtonGroupWidget, $footer;
@ -52,7 +53,8 @@
// The following messages can be used here:
// tooltip-pt-notifications-alert
// tooltip-pt-notifications-message
title: mw.msg( 'tooltip-pt-notifications-' + this.type )
title: mw.msg( 'tooltip-pt-notifications-' + this.type ),
href: config.href
} );
// View model