2 * MediaWiki Widgets - ComplexTitleInputWidget class.
4 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
10 * Like TitleInputWidget, but the namespace has to be input through a separate dropdown field.
13 * @extends OO.ui.Widget
16 * @param {Object} [config] Configuration options
17 * @cfg {Object} namespace Configuration for the NamespaceInputWidget dropdown with list of
19 * @cfg {Object} title Configuration for the TitleInputWidget text field
21 mw
.widgets
.ComplexTitleInputWidget
= function MwWidgetsComplexTitleInputWidget( config
) {
23 mw
.widgets
.ComplexTitleInputWidget
.parent
.call( this, config
);
26 this.namespace = new mw
.widgets
.NamespaceInputWidget( config
.namespace );
27 this.title
= new mw
.widgets
.TitleInputWidget( $.extend(
32 namespace: config
.namespace.value
|| null
37 this.namespace.connect( this, { change
: 'updateTitleNamespace' } );
41 .addClass( 'mw-widget-complexTitleInputWidget' )
43 this.namespace.$element
,
46 this.updateTitleNamespace();
51 OO
.inheritClass( mw
.widgets
.ComplexTitleInputWidget
, OO
.ui
.Widget
);
58 mw
.widgets
.ComplexTitleInputWidget
.static.reusePreInfuseDOM = function ( node
, config
) {
59 config
= mw
.widgets
.ComplexTitleInputWidget
.parent
.static.reusePreInfuseDOM( node
, config
);
60 config
.namespace = mw
.widgets
.NamespaceInputWidget
.static.reusePreInfuseDOM(
61 $( node
).find( '.mw-widget-namespaceInputWidget' ),
64 config
.title
= mw
.widgets
.TitleInputWidget
.static.reusePreInfuseDOM(
65 $( node
).find( '.mw-widget-titleInputWidget' ),
74 mw
.widgets
.ComplexTitleInputWidget
.static.gatherPreInfuseState = function ( node
, config
) {
75 var state
= mw
.widgets
.ComplexTitleInputWidget
.parent
.static.gatherPreInfuseState( node
, config
);
76 state
.namespace = mw
.widgets
.NamespaceInputWidget
.static.gatherPreInfuseState(
77 $( node
).find( '.mw-widget-namespaceInputWidget' ),
80 state
.title
= mw
.widgets
.TitleInputWidget
.static.gatherPreInfuseState(
81 $( node
).find( '.mw-widget-titleInputWidget' ),
90 * Update the namespace to use for search suggestions of the title when the value of namespace
93 mw
.widgets
.ComplexTitleInputWidget
.prototype.updateTitleNamespace = function () {
94 this.title
.setNamespace( Number( this.namespace.getValue() ) );
100 mw
.widgets
.ComplexTitleInputWidget
.prototype.restorePreInfuseState = function ( state
) {
101 mw
.widgets
.ComplexTitleInputWidget
.parent
.prototype.restorePreInfuseState
.call( this, state
);
102 this.namespace.restorePreInfuseState( state
.namespace );
103 this.title
.restorePreInfuseState( state
.title
);
106 }( jQuery
, mediaWiki
) );