修复缺失的组件
parent
bd8d1f2b98
commit
5a4f74f919
@ -0,0 +1,48 @@
|
||||
/*!
|
||||
* VisualEditor UserInterface MWParameterDropdownInputWidget class.
|
||||
*
|
||||
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
|
||||
* @license The MIT License (MIT); see LICENSE.txt
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates an ve.ui.MWParameterDropdownInputWidget object.
|
||||
*
|
||||
* @class
|
||||
* @extends OO.ui.DropdownWidget
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
ve.ui.MWParameterDropdownInputWidget = function VeUiMWParameterDropdownInputWidget( config, defaultValue ) {
|
||||
console.log('MWParameterDropdownInputWidget defaultValue', defaultValue);
|
||||
if ( typeof config !== "undefined" ) {
|
||||
config.options = parseOptions( defaultValue );
|
||||
}
|
||||
console.log('MWParameterDropdownInputWidget params', config.options);
|
||||
// Parent constructor
|
||||
ve.ui.MWParameterDropdownInputWidget.parent.apply( this, [ config ] );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
||||
OO.inheritClass( ve.ui.MWParameterDropdownInputWidget, OO.ui.DropdownInputWidget );
|
||||
|
||||
/* Methods */
|
||||
function parseOptions ( optionsText ) {
|
||||
var optionLine = optionsText.split('\n');
|
||||
var options = [];
|
||||
optionLine.forEach( ( optionText ) => {
|
||||
if ( optionText.trim().length > 0 ) {
|
||||
var data = optionText.split( ':' );
|
||||
if ( data.length >= 2 ) {
|
||||
var optionValue = data[ 0 ].trim();
|
||||
var optionLabel = data.slice( 1 ).join( ':' ).trim();
|
||||
options.push( {
|
||||
data: optionValue,
|
||||
label: optionLabel
|
||||
} );
|
||||
}
|
||||
}
|
||||
} );
|
||||
return options;
|
||||
}
|
Loading…
Reference in New Issue