2 * MediaWiki Widgets - NamespaceInputWidget 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.
13 * @extends OO.ui.DropdownInputWidget
16 * @param {Object} [config] Configuration options
17 * @cfg {string|null} includeAllValue Value for "all namespaces" option, if any
19 mw
.widgets
.NamespaceInputWidget
= function MwWidgetsNamespaceInputWidget( config
) {
20 // Configuration initialization
21 config
= $.extend( {}, config
, { options
: this.getNamespaceDropdownOptions( config
) } );
24 mw
.widgets
.NamespaceInputWidget
.parent
.call( this, config
);
27 this.$element
.addClass( 'mw-widget-namespaceInputWidget' );
32 OO
.inheritClass( mw
.widgets
.NamespaceInputWidget
, OO
.ui
.DropdownInputWidget
);
39 mw
.widgets
.NamespaceInputWidget
.prototype.getNamespaceDropdownOptions = function ( config
) {
43 options
= $.map( mw
.config
.get( 'wgFormattedNamespaces' ), function ( name
, ns
) {
48 if ( ns
=== String( NS_MAIN
) ) {
49 name
= mw
.message( 'blanknamespace' ).text();
51 return { data
: ns
, label
: name
};
52 } ).sort( function ( a
, b
) {
53 // wgFormattedNamespaces is an object, and so technically doesn't have to be ordered
54 return a
.data
- b
.data
;
57 if ( config
.includeAllValue
!== null && config
.includeAllValue
!== undefined ) {
59 data
: config
.includeAllValue
,
60 label
: mw
.message( 'namespacesall' ).text()
67 }( jQuery
, mediaWiki
) );