4fce08c9826409435d481520707fba18e79aa62e
3 * Widget to select to view changes that link TO or FROM the target page
4 * on Special:RecentChangesLinked (AKA Related Changes)
6 * @extends OO.ui.DropdownWidget
9 * @param {mw.rcfilters.Controller} controller
10 * @param {mw.rcfilters.dm.FilterItem} showLinkedToModel model this widget is bound to
11 * @param {Object} [config] Configuration object
13 mw
.rcfilters
.ui
.RclToOrFromWidget
= function MwRcfiltersUiRclToOrFromWidget(
14 controller
, showLinkedToModel
, config
16 config
= config
|| {};
18 this.showLinkedFrom
= new OO
.ui
.MenuOptionWidget( {
19 data
: 'from', // default (showlinkedto=0)
20 label
: new OO
.ui
.HtmlSnippet( mw
.msg( 'rcfilters-filter-showlinkedfrom-option-label' ) )
22 this.showLinkedTo
= new OO
.ui
.MenuOptionWidget( {
23 data
: 'to', // showlinkedto=1
24 label
: new OO
.ui
.HtmlSnippet( mw
.msg( 'rcfilters-filter-showlinkedto-option-label' ) )
28 mw
.rcfilters
.ui
.RclToOrFromWidget
.parent
.call( this, $.extend( {
29 classes
: [ 'mw-rcfilters-ui-rclToOrFromWidget' ],
30 menu
: { items
: [ this.showLinkedFrom
, this.showLinkedTo
] }
33 this.controller
= controller
;
34 this.model
= showLinkedToModel
;
36 this.getMenu().connect( this, { choose
: 'onUserChooseItem' } );
37 this.model
.connect( this, { update
: 'onModelUpdate' } );
39 // force an initial update of the component based on the state
45 OO
.inheritClass( mw
.rcfilters
.ui
.RclToOrFromWidget
, OO
.ui
.DropdownWidget
);
50 * Respond to the user choosing an item in the menu
52 * @param {OO.ui.MenuOptionWidget} chosenItem
54 mw
.rcfilters
.ui
.RclToOrFromWidget
.prototype.onUserChooseItem = function ( chosenItem
) {
55 this.controller
.setShowLinkedTo( chosenItem
.getData() === 'to' );
59 * Respond to model update
61 mw
.rcfilters
.ui
.RclToOrFromWidget
.prototype.onModelUpdate = function () {
62 this.getMenu().selectItem(
63 this.model
.isSelected() ?
67 this.setLabel( mw
.msg(
68 this.model
.isSelected() ?
69 'rcfilters-filter-showlinkedto-label' :
70 'rcfilters-filter-showlinkedfrom-label'