/*! * MediaWiki Widgets - UsersMultiselectWidget class. * * @copyright 2017 MediaWiki Widgets Team and others; see AUTHORS.txt * @license The MIT License (MIT); see LICENSE.txt */ ( function ( $, mw ) { /** * UsersMultiselectWidget can be used to input list of users in a single * line. * * If used inside HTML form the results will be sent as the list of * newline-separated usernames. * * @class * @extends OO.ui.MenuTagMultiselectWidget * * @constructor * @param {Object} [config] Configuration options * @cfg {mw.Api} [api] Instance of mw.Api (or subclass thereof) to use for queries * @cfg {number} [limit=10] Number of results to show in autocomplete menu * @cfg {string} [name] Name of input to submit results (when used in HTML forms) */ mw.widgets.UsersMultiselectWidget = function MwWidgetsUsersMultiselectWidget( config ) { // Config initialization config = $.extend( { limit: 10 }, config, { // Because of using autocomplete (constantly changing menu), we need to // allow adding usernames, which do not present in the menu. allowArbitrary: true } ); // Parent constructor mw.widgets.UsersMultiselectWidget.parent.call( this, $.extend( {}, config, {} ) ); // Mixin constructors OO.ui.mixin.PendingElement.call( this, $.extend( {}, config, { $pending: this.$handle } ) ); // Properties this.limit = config.limit; 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 = $( '