3 * Widget to select and display target page on Special:RecentChangesLinked (AKA Related Changes)
5 * @extends OO.ui.Widget
8 * @param {mw.rcfilters.Controller} controller
9 * @param {mw.rcfilters.dm.FilterItem} targetPageModel
10 * @param {Object} [config] Configuration object
12 mw
.rcfilters
.ui
.RclTargetPageWidget
= function MwRcfiltersUiRclTargetPageWidget(
13 controller
, targetPageModel
, config
15 config
= config
|| {};
18 mw
.rcfilters
.ui
.RclTargetPageWidget
.parent
.call( this, config
);
20 this.controller
= controller
;
21 this.model
= targetPageModel
;
23 this.titleSearch
= new mw
.widgets
.TitleInputWidget( {
25 placeholder
: mw
.msg( 'rcfilters-target-page-placeholder' ),
27 showDescriptions
: true
31 this.model
.connect( this, { update
: 'updateUiBasedOnModel' } );
33 this.titleSearch
.$input
.on( {
34 blur
: this.onLookupInputBlur
.bind( this )
37 this.titleSearch
.lookupMenu
.connect( this, {
38 choose
: 'onLookupMenuItemChoose'
43 .addClass( 'mw-rcfilters-ui-rclTargetPageWidget' )
44 .append( this.titleSearch
.$element
);
46 this.updateUiBasedOnModel();
51 OO
.inheritClass( mw
.rcfilters
.ui
.RclTargetPageWidget
, OO
.ui
.Widget
);
56 * Respond to the user choosing a title
58 mw
.rcfilters
.ui
.RclTargetPageWidget
.prototype.onLookupMenuItemChoose = function () {
59 this.titleSearch
.$input
.blur();
63 * Respond to titleSearch $input blur
65 mw
.rcfilters
.ui
.RclTargetPageWidget
.prototype.onLookupInputBlur = function () {
66 this.controller
.setTargetPage( this.titleSearch
.getQueryValue() );
70 * Respond to the model being updated
72 mw
.rcfilters
.ui
.RclTargetPageWidget
.prototype.updateUiBasedOnModel = function () {
73 this.titleSearch
.setValue( this.model
.getValue() );