diff --git a/modules/ext.echo.init.js b/modules/ext.echo.init.js index e04481841..9a0fc6362 100644 --- a/modules/ext.echo.init.js +++ b/modules/ext.echo.init.js @@ -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(); diff --git a/modules/ooui/mw.echo.ui.BadgeLinkWidget.js b/modules/ooui/mw.echo.ui.BadgeLinkWidget.js index 2a7ae68fb..61b7039f7 100644 --- a/modules/ooui/mw.echo.ui.BadgeLinkWidget.js +++ b/modules/ooui/mw.echo.ui.BadgeLinkWidget.js @@ -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 ); diff --git a/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js b/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js index ef4633c49..18530ec2e 100644 --- a/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js +++ b/modules/ooui/mw.echo.ui.NotificationBadgeWidget.js @@ -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