mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-18 02:40:50 +00:00
Fix notification dynamic actions outside of the dropdown
* Event handler was not registered for the non-dropdown version * Clicks would be handled by both the action and by the default link Also remove returning false to prevent default and stop propagation, this is not supported by OOUI events and did nothing. Handling a 'click' event always returns false to jQuery (so this was not needed), handling 'choose' event never does (hence my other fix was needed). Change-Id: Ia8a21749a8edc20f34b2a3e445278ea6922b9109
This commit is contained in:
parent
84843d3619
commit
54c27e5763
|
@ -76,6 +76,21 @@
|
||||||
return this.isLink ? 'a' : 'div';
|
return this.isLink ? 'a' : 'div';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mw.echo.ui.MenuItemWidget.prototype.onClick = function ( e ) {
|
||||||
|
// Stop propagation, so that the default dynamic action of the notification isn't triggered
|
||||||
|
// (e.g. expanding a bundled notification).
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
// If this is a dynamic action, also prevent default to disable the native browser behavior,
|
||||||
|
// the default link of the notification won't be followed.
|
||||||
|
// (If this is a link, default link of the notification is ignored as native browser behavior.)
|
||||||
|
if ( !this.isLink ) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mw.echo.ui.MenuItemWidget.super.prototype.onClick.apply( this, arguments );
|
||||||
|
};
|
||||||
|
|
||||||
mw.echo.ui.MenuItemWidget.prototype.isSelectable = function () {
|
mw.echo.ui.MenuItemWidget.prototype.isSelectable = function () {
|
||||||
// If we have a link force selectability to false, otherwise defer to parent method
|
// If we have a link force selectability to false, otherwise defer to parent method
|
||||||
// Without a link (for dynamic actions or specific internal actions) we need this widget
|
// Without a link (for dynamic actions or specific internal actions) we need this widget
|
||||||
|
|
|
@ -189,6 +189,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
|
this.actionsButtonSelectWidget.connect( this, { choose: 'onPopupButtonWidgetChoose' } );
|
||||||
this.menuPopupButtonWidget.getMenu().connect( this, { choose: 'onPopupButtonWidgetChoose' } );
|
this.menuPopupButtonWidget.getMenu().connect( this, { choose: 'onPopupButtonWidgetChoose' } );
|
||||||
this.markAsReadButton.connect( this, { click: 'onMarkAsReadButtonClick' } );
|
this.markAsReadButton.connect( this, { click: 'onMarkAsReadButtonClick' } );
|
||||||
|
|
||||||
|
@ -228,10 +229,14 @@
|
||||||
* NOTE: The messages are parsed as HTML. If user-input is expected
|
* NOTE: The messages are parsed as HTML. If user-input is expected
|
||||||
* please make sure to properly escape it.
|
* please make sure to properly escape it.
|
||||||
*
|
*
|
||||||
* @param {mw.echo.ui.MenuItemWidget} item The selected item
|
* @param {OO.ui.ButtonOptionWidget} item The selected item
|
||||||
* @return {boolean} False to prevent the native event
|
|
||||||
*/
|
*/
|
||||||
mw.echo.ui.NotificationItemWidget.prototype.onPopupButtonWidgetChoose = function ( item ) {
|
mw.echo.ui.NotificationItemWidget.prototype.onPopupButtonWidgetChoose = function ( item ) {
|
||||||
|
if ( !( item instanceof mw.echo.ui.MenuItemWidget ) ) {
|
||||||
|
// Other kinds of items may be added by subclasses
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var actionData = item && item.getActionData(),
|
var actionData = item && item.getActionData(),
|
||||||
messages = item && item.getConfirmationMessages(),
|
messages = item && item.getConfirmationMessages(),
|
||||||
widget = this;
|
widget = this;
|
||||||
|
@ -268,24 +273,16 @@
|
||||||
// Send to mw.notify
|
// Send to mw.notify
|
||||||
mw.notify( $confirmation );
|
mw.notify( $confirmation );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Prevent the click propagation
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Respond to mark as read button click
|
* Respond to mark as read button click
|
||||||
*
|
|
||||||
* @return {boolean} False to prevent the native event
|
|
||||||
*/
|
*/
|
||||||
mw.echo.ui.NotificationItemWidget.prototype.onMarkAsReadButtonClick = function () {
|
mw.echo.ui.NotificationItemWidget.prototype.onMarkAsReadButtonClick = function () {
|
||||||
// If we're marking read or unread, the notification was already seen.
|
// If we're marking read or unread, the notification was already seen.
|
||||||
// Remove the animation class
|
// Remove the animation class
|
||||||
this.$element.removeClass( 'mw-echo-ui-notificationItemWidget-initiallyUnseen' );
|
this.$element.removeClass( 'mw-echo-ui-notificationItemWidget-initiallyUnseen' );
|
||||||
this.markRead( !this.model.isRead() );
|
this.markRead( !this.model.isRead() );
|
||||||
// Prevent propogation in case there's a link wrapping the content
|
|
||||||
// and the mark as read/unread button
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue