mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 17:50:39 +00:00
4b7520af90
If an error has occurred while fetching from the API, the placeholder item should display the API error information. If the error is specifically a login issue, a specific error message is displayed. Also, adjusted the mw.echo.ui.PlaceholderItemWidget to accept a clickable link; when valid (currently only with login error) the link is applied so the user can click the notification and be taken to the login page. For general notices (like API error or a general 'no notifications found' message) the link does nothing. Bug: T121923 Change-Id: I89a43c7c0eb2cf8e63d03704536e0938ab57dd4d
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
( function ( mw, $ ) {
|
|
/**
|
|
* Placeholder notification option widget for echo popup.
|
|
*
|
|
* @class
|
|
* @extends OO.ui.OptionWidget
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration object
|
|
* @cfg {string} [link] A link that this widget leads to.
|
|
*/
|
|
mw.echo.ui.PlaceholderItemWidget = function MwEchoUiPlaceholderItemWidget( config ) {
|
|
config = config || {};
|
|
|
|
// Parent constructor
|
|
mw.echo.ui.PlaceholderItemWidget.parent.call( this, $.extend( { data: null }, config ) );
|
|
|
|
this.$link = $( '<a>' )
|
|
.addClass( 'mw-echo-ui-notificationsWidget-loadingOption-link' );
|
|
this.setLink( config.link || '' );
|
|
|
|
this.$element
|
|
.addClass( 'mw-echo-ui-notificationsWidget-loadingOption' )
|
|
.append(
|
|
this.$link.append( this.$label )
|
|
);
|
|
};
|
|
|
|
OO.inheritClass( mw.echo.ui.PlaceholderItemWidget, OO.ui.OptionWidget );
|
|
|
|
mw.echo.ui.PlaceholderItemWidget.static.selectable = false;
|
|
mw.echo.ui.PlaceholderItemWidget.static.highlightable = false;
|
|
mw.echo.ui.PlaceholderItemWidget.static.pressable = false;
|
|
|
|
/**
|
|
* Set (or unset) the main link for this widget
|
|
*
|
|
* @param {string} link The widget link
|
|
*/
|
|
mw.echo.ui.PlaceholderItemWidget.prototype.setLink = function ( link ) {
|
|
this.link = link;
|
|
|
|
this.$element.toggleClass( 'mw-echo-ui-notificationsWidget-loadingOption-notLinked', !this.link );
|
|
|
|
this.$link.attr( 'href', this.link );
|
|
};
|
|
|
|
} )( mediaWiki, jQuery );
|