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,
32 this.model
.connect( this, { update
: 'updateUiBasedOnModel' } );
34 this.titleSearch
.$input
.on( {
35 blur
: this.onLookupInputBlur
.bind( this )
38 this.titleSearch
.lookupMenu
.connect( this, {
39 choose
: 'onLookupMenuItemChoose'
44 .addClass( 'mw-rcfilters-ui-rclTargetPageWidget' )
45 .append( this.titleSearch
.$element
);
47 this.updateUiBasedOnModel();
52 OO
.inheritClass( mw
.rcfilters
.ui
.RclTargetPageWidget
, OO
.ui
.Widget
);
57 * Respond to the user choosing a title
59 mw
.rcfilters
.ui
.RclTargetPageWidget
.prototype.onLookupMenuItemChoose = function () {
60 this.titleSearch
.$input
.blur();
64 * Respond to titleSearch $input blur
66 mw
.rcfilters
.ui
.RclTargetPageWidget
.prototype.onLookupInputBlur = function () {
67 this.controller
.setTargetPage( this.titleSearch
.getQueryValue() );
71 * Respond to the model being updated
73 mw
.rcfilters
.ui
.RclTargetPageWidget
.prototype.updateUiBasedOnModel = function () {
74 var title
= mw
.Title
.newFromText( this.model
.getValue() ),
75 text
= title
? title
.toText() : this.model
.getValue();
76 this.titleSearch
.setValue( text
);
77 this.titleSearch
.setTitle( text
);