Support for PlaceholderWidget with no link

Bug: T137490
Change-Id: Ia861b5aa3f100124418956a0e09603a9ba29215a
This commit is contained in:
Stephane Bisson 2016-06-21 07:46:06 -04:00
parent c1b4e4d5aa
commit c93800e17c
3 changed files with 18 additions and 24 deletions

View file

@ -11,6 +11,7 @@ class ApiEchoNotifications extends ApiCrossWikiBase {
} }
public function execute() { public function execute() {
// To avoid API warning, register the parameter used to bust browser cache // To avoid API warning, register the parameter used to bust browser cache
$this->getMain()->getVal( '_' ); $this->getMain()->getVal( '_' );

View file

@ -2,9 +2,4 @@
.mw-echo-ui-placeholderItemWidget { .mw-echo-ui-placeholderItemWidget {
padding: 2em; padding: 2em;
background-color: @notification-background-read; background-color: @notification-background-read;
&-notLinked,
&-notLinked a {
cursor: default;
}
} }

View file

@ -19,31 +19,29 @@
// Mixin constructor // Mixin constructor
OO.ui.mixin.LabelElement.call( this, config ); OO.ui.mixin.LabelElement.call( this, config );
this.$link = $( '<a>' ) this.$element.addClass( 'mw-echo-ui-placeholderItemWidget' );
.addClass( 'mw-echo-ui-placeholderItemWidget-link' );
this.setLink( config.link || '' );
this.$element this.setLink( config.link );
.addClass( 'mw-echo-ui-placeholderItemWidget' )
.append(
this.$link.append( this.$label )
);
}; };
OO.inheritClass( mw.echo.ui.PlaceholderItemWidget, OO.ui.Widget ); OO.inheritClass( mw.echo.ui.PlaceholderItemWidget, OO.ui.Widget );
OO.mixinClass( mw.echo.ui.PlaceholderItemWidget, OO.ui.mixin.LabelElement ); OO.mixinClass( mw.echo.ui.PlaceholderItemWidget, OO.ui.mixin.LabelElement );
/** /**
* Set (or unset) the main link for this widget * Set (or unset) the main link url for this widget
* *
* @param {string} link The widget link * @param {string} url The widget url
*/ */
mw.echo.ui.PlaceholderItemWidget.prototype.setLink = function ( link ) { mw.echo.ui.PlaceholderItemWidget.prototype.setLink = function ( url ) {
this.link = link; var $link;
if ( url ) {
this.$element.toggleClass( 'mw-echo-ui-placeholderItemWidget-loadingOption-notLinked', !this.link ); $link = $( '<a>' )
.addClass( 'mw-echo-ui-placeholderItemWidget-link' )
this.$link.attr( 'href', this.link ); .attr( 'href', url );
this.$element.html( $link.append( this.$label ) );
} else {
this.$element.html( this.$label );
}
}; };
/** /**