mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-28 00:40:12 +00:00
18f616b9b8
This code has been developed over three years now in the repo of MediaWiki's integration of VisualEditor. It has grown and developed significantly during that time, but now is pretty stable. A number of hacks inside the MediaWiki- VisualEditor code base have been used to prevent this code from being loaded on wikis where the Cite extension is not deployed, but this state of affairs is and always was meant to be temporary. This code is under the MIT licence which is a tad messy, but not impossible. It's clearly labelled as such. The list of authors has been updated to take into account the influx of new functionality. Bug: T41621 Bug: T104928 Change-Id: I39936ed83d5a60471a0a75da753f498e80aef234
61 lines
1.7 KiB
JavaScript
61 lines
1.7 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface MWReferenceGroupInput class.
|
|
*
|
|
* @copyright 2011-2016 Cite VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates an ve.ui.MWReferenceGroupInput object.
|
|
*
|
|
* @class
|
|
* @extends OO.ui.ComboBoxWidget
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration options
|
|
* @cfg {string} emptyGroupName Label of the placeholder item
|
|
*/
|
|
ve.ui.MWReferenceGroupInputWidget = function VeUiMWReferenceGroupInputWidget( config ) {
|
|
config = config || {};
|
|
|
|
this.emptyGroupName = config.emptyGroupName;
|
|
|
|
// Parent constructor
|
|
OO.ui.ComboBoxWidget.call( this, $.extend( true, { input: { placeholder: config.emptyGroupName } }, config ) );
|
|
|
|
this.$element.addClass( 've-ui-mwReferenceGroupInputWidget' );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWReferenceGroupInputWidget, OO.ui.ComboBoxWidget );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Populate the reference group menu
|
|
*
|
|
* @param {ve.dm.InternalList} internalList Internal list with which to populate the menu
|
|
*/
|
|
ve.ui.MWReferenceGroupInputWidget.prototype.populateMenu = function ( internalList ) {
|
|
var placeholderGroupItem = new OO.ui.MenuOptionWidget( {
|
|
data: '',
|
|
label: this.emptyGroupName,
|
|
flags: 'emptyGroupPlaceholder'
|
|
} );
|
|
this.menu.clearItems();
|
|
this.menu.addItems( [ placeholderGroupItem ].concat( $.map(
|
|
Object.keys( internalList.getNodeGroups() ),
|
|
function ( groupInternalName ) {
|
|
var groupName;
|
|
if ( groupInternalName.indexOf( 'mwReference/' ) === 0 ) {
|
|
groupName = groupInternalName.slice( 'mwReference/'.length );
|
|
if ( groupName ) {
|
|
return new OO.ui.MenuOptionWidget( { data: groupName, label: groupName } );
|
|
}
|
|
}
|
|
}
|
|
) ), 0 );
|
|
this.menu.toggle( false );
|
|
};
|