mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-25 00:05:29 +00:00
e5e19dd0f1
Change-Id: I7b47e76ae48eaf4732d99616baa3b4b1ee4ddff5
65 lines
1.5 KiB
JavaScript
65 lines
1.5 KiB
JavaScript
( function ( $, mw ) {
|
|
/**
|
|
* 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 ) {
|
|
config = config || {};
|
|
|
|
// Parent
|
|
mw.echo.ui.ReadStateButtonSelectWidget.parent.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 filter
|
|
* @param {string} readState The chosen read state
|
|
*/
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Respond to choose event
|
|
*
|
|
* @param {OO.ui.ButtonOptionWidget} item Chosen item
|
|
* @fires filter
|
|
*/
|
|
mw.echo.ui.ReadStateButtonSelectWidget.prototype.onChoose = function ( item ) {
|
|
var data = item && item.getData();
|
|
|
|
if ( data ) {
|
|
this.emit( 'filter', data );
|
|
}
|
|
};
|
|
} )( jQuery, mediaWiki );
|