/*! * MediaWiki Widgets - NamespacesMultiselectWidget class. * * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt * @license The MIT License (MIT); see LICENSE.txt */ ( function () { /** * @classdesc Namespaces multiselect widget. * * TODO: A lot of this is duplicated in mw.widgets.UsersMultiselectWidget * and mw.widgets.TitlesMultiselectWidget. These classes should be * refactored. * * @class * @extends OO.ui.MenuTagMultiselectWidget * * @constructor * @description Create an mw.widgets.NamespacesMultiselectWidget object. * @param {Object} [config] Configuration options */ mw.widgets.NamespacesMultiselectWidget = function MwWidgetsNamespacesMultiselectWidget( config ) { const namespaces = {}, options = mw.widgets.NamespaceInputWidget.static.getNamespaceDropdownOptions( {} ); for ( let i = 0, ilen = options.length; i < ilen; i++ ) { const option = options[ i ]; namespaces[ option.data ] = option.label; } config = $.extend( true, { options: mw.widgets.NamespaceInputWidget.static.getNamespaceDropdownOptions( {} ) }, config ); // Parent constructor mw.widgets.NamespacesMultiselectWidget.super.call( this, $.extend( true, { menu: { filterMode: 'substring' } }, config, { selected: config && config.selected ? config.selected.map( ( id ) => ( { data: id, label: namespaces[ id ] } ) ) : undefined } ) ); // Initialization this.$element .addClass( 'mw-widgets-namespacesMultiselectWidget' ); if ( 'name' in config ) { // Use this instead of , because hidden inputs do not have separate // 'value' and 'defaultValue' properties. The script on Special:Preferences // (mw.special.preferences.confirmClose) checks this property to see if a field was changed. this.$hiddenInput = $( '