mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
fcc2e1ddfc
Some of the counts are capped (wiki counts) and some are not (page counts) - so we are adding a config option ('isCapped') to the widget to make sure that capped numbers appear with the proper i18n message ('99+' in English) and non-capped numbers appear as-is. Bug: T144707 Change-Id: I7332e7f5108621d0bd403edefe4feacca44b1f88
77 lines
2.2 KiB
JavaScript
77 lines
2.2 KiB
JavaScript
( function ( $, mw ) {
|
|
/**
|
|
* An option widget for the page filter in PageFilterWidget
|
|
*
|
|
* @class
|
|
* @extends OO.ui.OptionWidget
|
|
* @mixins OO.ui.mixin.IconElement
|
|
* @mixins OO.ui.mixin.TitledElement
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration object
|
|
* @cfg {number} [count] Number of unread notifications
|
|
* @cfg {boolean} [isCapped] The count for this widget is capped
|
|
*/
|
|
mw.echo.ui.PageNotificationsOptionWidget = function MwEchoUiPageNotificationsOptionWidget( config ) {
|
|
var countLabel;
|
|
|
|
config = config || {};
|
|
|
|
// Parent
|
|
mw.echo.ui.PageNotificationsOptionWidget.parent.call( this, config );
|
|
// Mixin constructors
|
|
OO.ui.mixin.IconElement.call( this, config );
|
|
OO.ui.mixin.TitledElement.call( this, config );
|
|
|
|
this.$label
|
|
.addClass( 'mw-echo-ui-pageNotificationsOptionWidget-title-label' );
|
|
|
|
this.count = config.count !== undefined ? config.count : 0;
|
|
|
|
countLabel = mw.language.convertNumber( this.count );
|
|
countLabel = config.isCapped ?
|
|
mw.msg( 'echo-badge-count', countLabel ) : countLabel;
|
|
|
|
this.unreadCountLabel = new OO.ui.LabelWidget( {
|
|
classes: [ 'mw-echo-ui-pageNotificationsOptionWidget-label-count' ],
|
|
label: countLabel
|
|
} );
|
|
|
|
// Initialization
|
|
this.$element
|
|
.addClass( 'mw-echo-ui-pageNotificationsOptionWidget' )
|
|
.append(
|
|
$( '<div>' )
|
|
.addClass( 'mw-echo-ui-pageNotificationsOptionWidget-count' )
|
|
.append( this.unreadCountLabel.$element ),
|
|
$( '<div>' )
|
|
.addClass( 'mw-echo-ui-pageNotificationsOptionWidget-title' )
|
|
.append( this.$label )
|
|
);
|
|
|
|
if ( this.getIcon() ) {
|
|
this.$element.prepend(
|
|
$( '<div>' )
|
|
.addClass( 'mw-echo-ui-pageNotificationsOptionWidget-icon' )
|
|
.append( this.$icon )
|
|
);
|
|
}
|
|
};
|
|
|
|
/* Initialization */
|
|
|
|
OO.inheritClass( mw.echo.ui.PageNotificationsOptionWidget, OO.ui.OptionWidget );
|
|
OO.mixinClass( mw.echo.ui.PageNotificationsOptionWidget, OO.ui.mixin.IconElement );
|
|
OO.mixinClass( mw.echo.ui.PageNotificationsOptionWidget, OO.ui.mixin.TitledElement );
|
|
|
|
/**
|
|
* Get the page count
|
|
*
|
|
* @return {number} Page count
|
|
*/
|
|
mw.echo.ui.PageNotificationsOptionWidget.prototype.getCount = function () {
|
|
return this.count;
|
|
};
|
|
|
|
} )( jQuery, mediaWiki );
|