mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-30 18:45:07 +00:00
Support for PlaceholderWidget with no link
Bug: T137490 Change-Id: Ia861b5aa3f100124418956a0e09603a9ba29215a
This commit is contained in:
parent
c1b4e4d5aa
commit
c93800e17c
|
@ -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( '_' );
|
||||||
|
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue