jenkins-bot has submitted this change and it was merged.

Change subject: Make middle-clicking badge work
......................................................................


Make middle-clicking badge work

* Ignore non-left-button click events on initial badge
* Pass href into OOUI badge widget

Bug: T113555
Change-Id: I963aa5193435c46075df6d7204de335b51ecffd4
---
M modules/ext.echo.init.js
M modules/ooui/mw.echo.ui.BadgeLinkWidget.js
M modules/ooui/mw.echo.ui.NotificationBadgeWidget.js
3 files changed, 18 insertions(+), 4 deletions(-)

Approvals:
  Mooeypoo: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ext.echo.init.js b/modules/ext.echo.init.js
index db77e27..d1ddba9 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' );
 
@@ -52,7 +57,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();
@@ -77,7 +83,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 2a7ae68..61b7039 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 6418db9..5f6f0ae 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

-- 
To view, visit https://gerrit.wikimedia.org/r/240629
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I963aa5193435c46075df6d7204de335b51ecffd4
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Mooeypoo <mor...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to