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 );
59 mw.widgets.ComplexTitleInputWidget.static.reusePreInfuseDOM = function ( node, config ) {
60 config = mw.widgets.ComplexTitleInputWidget.parent.static.reusePreInfuseDOM( node, config );
61 config.namespace = mw.widgets.NamespaceInputWidget.static.reusePreInfuseDOM(
62 $( node ).find( '.mw-widget-namespaceInputWidget' ),
65 config.title = mw.widgets.TitleInputWidget.static.reusePreInfuseDOM(
66 $( node ).find( '.mw-widget-titleInputWidget' ),
75 mw.widgets.ComplexTitleInputWidget.static.gatherPreInfuseState = function ( node, config ) {
76 var state = mw.widgets.ComplexTitleInputWidget.parent.static.gatherPreInfuseState( node, config );
77 state.namespace = mw.widgets.NamespaceInputWidget.static.gatherPreInfuseState(
78 $( node ).find( '.mw-widget-namespaceInputWidget' ),
81 state.title = mw.widgets.TitleInputWidget.static.gatherPreInfuseState(
82 $( node ).find( '.mw-widget-titleInputWidget' ),
93 * Update the namespace to use for search suggestions of the title when the value of namespace
96 mw.widgets.ComplexTitleInputWidget.prototype.updateTitleNamespace = function () {
97 this.title.setNamespace( Number( this.namespace.getValue() ) );
103 mw.widgets.ComplexTitleInputWidget.prototype.restorePreInfuseState = function ( state ) {
104 mw.widgets.ComplexTitleInputWidget.parent.prototype.restorePreInfuseState.call( this, state );
105 this.namespace.restorePreInfuseState( state.namespace );
106 this.title.restorePreInfuseState( state.title );
109 }( jQuery, mediaWiki ) );