mediawiki-extensions-Echo/modules/ui/mw.echo.ui.ReadStateButtonSelectWidget.js
Ed Sanders df8fbfed38 Replace jsduck with jsdoc
Change-Id: I2a1bfedeba66c9ec1b3ee2640a77d5ef8782530c
2024-04-30 15:29:06 +01:00

63 lines
1.5 KiB
JavaScript

( function () {
/**
* A select widget for notification read state: 'all', 'read' or 'unread'
*
* @class
* @extends OO.ui.ButtonSelectWidget
*
* @constructor
* @param {Object} [config] Configuration object
*/
mw.echo.ui.ReadStateButtonSelectWidget = function MwEchoUiReadStateButtonSelectWidget( config ) {
// Parent constructor
mw.echo.ui.ReadStateButtonSelectWidget.super.call( this, $.extend( config, {
items: [
new OO.ui.ButtonOptionWidget( {
data: 'all',
label: mw.msg( 'notification-inbox-filter-all' )
} ),
new OO.ui.ButtonOptionWidget( {
data: 'read',
label: mw.msg( 'notification-inbox-filter-read' )
} ),
new OO.ui.ButtonOptionWidget( {
data: 'unread',
label: mw.msg( 'notification-inbox-filter-unread' )
} )
]
} ) );
this.connect( this, { choose: 'onChoose' } );
this.$element
.addClass( 'mw-echo-ui-readStateButtonSelectWidget' );
};
/* Initialization */
OO.inheritClass( mw.echo.ui.ReadStateButtonSelectWidget, OO.ui.ButtonSelectWidget );
/* Events */
/**
* @event mw.echo.ui.ReadStateButtonSelectWidget#filter
* @param {string} readState The chosen read state
*/
/* Methods */
/**
* Respond to choose event
*
* @param {OO.ui.ButtonOptionWidget} item Chosen item
* @fires mw.echo.ui.ReadStateButtonSelectWidget#filter
*/
mw.echo.ui.ReadStateButtonSelectWidget.prototype.onChoose = function ( item ) {
var data = item && item.getData();
if ( data ) {
this.emit( 'filter', data );
}
};
}() );