Debian Codegraph @

extensions/Echo/modules/ui/mw.echo.ui.ReadStateButtonSelectWidget.js

raw symbols SCIP
1 ( function () {
2 /**
3 * A select widget for notification read state: 'all', 'read' or 'unread'
4 *
5 * @class
6 * @extends OO.ui.ButtonSelectWidget
7 *
8 * @constructor
9 * @param {Object} [config] Configuration object
10 */
11 mw.echo.ui.ReadStateButtonSelectWidget = function MwEchoUiReadStateButtonSelectWidget( config ) {
12 // Parent constructor
13 mw.echo.ui.ReadStateButtonSelectWidget.super.call( this, Object.assign( {}, config, {
14 items: [
15 new OO.ui.ButtonOptionWidget( {
16 data: 'all',
17 label: mw.msg( 'notification-inbox-filter-all' )
18 } ),
19 new OO.ui.ButtonOptionWidget( {
20 data: 'read',
21 label: mw.msg( 'notification-inbox-filter-read' )
22 } ),
23 new OO.ui.ButtonOptionWidget( {
24 data: 'unread',
25 label: mw.msg( 'notification-inbox-filter-unread' )
26 } )
27 ]
28 } ) );
29
30 this.connect( this, { choose: 'onChoose' } );
31
32 this.$element
33 .addClass( 'mw-echo-ui-readStateButtonSelectWidget' );
34 };
35
36 /* Initialization */
37
38 OO.inheritClass( mw.echo.ui.ReadStateButtonSelectWidget, OO.ui.ButtonSelectWidget );
39
40 /* Events */
41
42 /**
43 * @event mw.echo.ui.ReadStateButtonSelectWidget#filter
44 * @param {string} readState The chosen read state
45 */
46
47 /* Methods */
48
49 /**
50 * Respond to choose event
51 *
52 * @param {OO.ui.ButtonOptionWidget} item Chosen item
53 * @fires mw.echo.ui.ReadStateButtonSelectWidget#filter
54 */
55 mw.echo.ui.ReadStateButtonSelectWidget.prototype.onChoose = function ( item ) {
56 const data = item && item.getData();
57
58 if ( data ) {
59 this.emit( 'filter', data );
60 }
61 };
62 }() );