2 * MediaWiki Widgets - ComplexNamespaceInputWidget class.
4 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
10 * Namespace input widget. Displays a dropdown box with the choice of available namespaces, plus
11 * two checkboxes to include associated namespace or to invert selection.
14 * @extends OO.ui.Widget
17 * @param {Object} [config] Configuration options
18 * @cfg {Object} namespace Configuration for the NamespaceInputWidget dropdown with list
20 * @cfg {string} namespace.includeAllValue If specified, add a "all namespaces"
21 * option to the dropdown, and use this as the input value for it
22 * @cfg {Object} invert Configuration for the "invert selection" CheckboxInputWidget. If
23 * null, the checkbox will not be generated.
24 * @cfg {Object} associated Configuration for the "include associated namespace"
25 * CheckboxInputWidget. If null, the checkbox will not be generated.
26 * @cfg {Object} invertLabel Configuration for the FieldLayout with label wrapping the
27 * "invert selection" checkbox
28 * @cfg {string} invertLabel.label Label text for the label
29 * @cfg {Object} associatedLabel Configuration for the FieldLayout with label wrapping
30 * the "include associated namespace" checkbox
31 * @cfg {string} associatedLabel.label Label text for the label
33 mw
.widgets
.ComplexNamespaceInputWidget
= function MwWidgetsComplexNamespaceInputWidget( config
) {
34 // Configuration initialization
37 // Config options for nested widgets
48 mw
.widgets
.ComplexNamespaceInputWidget
.parent
.call( this, config
);
53 this.namespace = new mw
.widgets
.NamespaceInputWidget( config
.namespace );
54 if ( config
.associated
!== null ) {
55 this.associated
= new OO
.ui
.CheckboxInputWidget( $.extend(
59 // TODO Should use a LabelWidget? But they don't work like HTML <label>s yet
60 this.associatedLabel
= new OO
.ui
.FieldLayout(
64 config
.associatedLabel
68 if ( config
.invert
!== null ) {
69 this.invert
= new OO
.ui
.CheckboxInputWidget( $.extend(
73 // TODO Should use a LabelWidget? But they don't work like HTML <label>s yet
74 this.invertLabel
= new OO
.ui
.FieldLayout(
84 this.namespace.connect( this, { change
: 'updateCheckboxesState' } );
88 .addClass( 'mw-widget-complexNamespaceInputWidget' )
90 this.namespace.$element
,
91 this.invert
? this.invertLabel
.$element
: '',
92 this.associated
? this.associatedLabel
.$element
: ''
94 this.updateCheckboxesState();
99 OO
.inheritClass( mw
.widgets
.ComplexNamespaceInputWidget
, OO
.ui
.Widget
);
104 * Update the disabled state of checkboxes when the value of namespace dropdown changes.
108 mw
.widgets
.ComplexNamespaceInputWidget
.prototype.updateCheckboxesState = function () {
109 var disabled
= this.namespace.getValue() === this.namespace.allValue
;
111 this.invert
.setDisabled( disabled
);
113 if ( this.associated
) {
114 this.associated
.setDisabled( disabled
);
118 }( jQuery
, mediaWiki
) );