3 * Widget to select and display target page on Special:RecentChangesLinked (AKA Related Changes)
5 * @class mw.rcfilters.ui.RclTargetPageWidget
6 * @extends OO.ui.Widget
9 * @param {mw.rcfilters.Controller} controller
10 * @param {mw.rcfilters.dm.FilterItem} targetPageModel
11 * @param {Object} [config] Configuration object
13 var RclTargetPageWidget
= function MwRcfiltersUiRclTargetPageWidget(
14 controller
, targetPageModel
, config
16 config
= config
|| {};
19 RclTargetPageWidget
.parent
.call( this, config
);
21 this.controller
= controller
;
22 this.model
= targetPageModel
;
24 this.titleSearch
= new mw
.widgets
.TitleInputWidget( {
26 placeholder
: mw
.msg( 'rcfilters-target-page-placeholder' ),
28 showDescriptions
: true,
33 this.model
.connect( this, { update
: 'updateUiBasedOnModel' } );
35 this.titleSearch
.$input
.on( {
36 blur
: this.onLookupInputBlur
.bind( this )
39 this.titleSearch
.lookupMenu
.connect( this, {
40 choose
: 'onLookupMenuItemChoose'
45 .addClass( 'mw-rcfilters-ui-rclTargetPageWidget' )
46 .append( this.titleSearch
.$element
);
48 this.updateUiBasedOnModel();
53 OO
.inheritClass( RclTargetPageWidget
, OO
.ui
.Widget
);
58 * Respond to the user choosing a title
60 RclTargetPageWidget
.prototype.onLookupMenuItemChoose = function () {
61 this.titleSearch
.$input
.trigger( 'blur' );
65 * Respond to titleSearch $input blur
67 RclTargetPageWidget
.prototype.onLookupInputBlur = function () {
68 this.controller
.setTargetPage( this.titleSearch
.getQueryValue() );
72 * Respond to the model being updated
74 RclTargetPageWidget
.prototype.updateUiBasedOnModel = function () {
75 var title
= mw
.Title
.newFromText( this.model
.getValue() ),
76 text
= title
? title
.toText() : this.model
.getValue();
77 this.titleSearch
.setValue( text
);
78 this.titleSearch
.setTitle( text
);
81 module
.exports
= RclTargetPageWidget
;