2013-07-02 20:40:54 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MWParameterResultWidget class.
|
|
|
|
*
|
2016-01-03 22:56:59 +00:00
|
|
|
* @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
|
2013-07-02 20:40:54 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an ve.ui.MWParameterResultWidget object.
|
|
|
|
*
|
|
|
|
* @class
|
2014-10-28 00:46:32 +00:00
|
|
|
* @extends OO.ui.DecoratedOptionWidget
|
2013-07-02 20:40:54 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-07-02 20:40:54 +00:00
|
|
|
*/
|
2014-11-22 01:40:00 +00:00
|
|
|
ve.ui.MWParameterResultWidget = function VeUiMWParameterResultWidget( config ) {
|
2013-07-09 22:48:08 +00:00
|
|
|
// Configuration initialization
|
2014-08-22 20:50:48 +00:00
|
|
|
config = ve.extendObject( { icon: 'parameter' }, config );
|
2013-07-09 22:48:08 +00:00
|
|
|
|
2013-07-02 20:40:54 +00:00
|
|
|
// Parent constructor
|
2014-11-22 01:40:00 +00:00
|
|
|
OO.ui.DecoratedOptionWidget.call( this, config );
|
2013-07-02 20:40:54 +00:00
|
|
|
|
|
|
|
// Initialization
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$element.addClass( 've-ui-mwParameterResultWidget' );
|
2013-07-02 20:40:54 +00:00
|
|
|
this.setLabel( this.buildLabel() );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2014-10-28 00:46:32 +00:00
|
|
|
OO.inheritClass( ve.ui.MWParameterResultWidget, OO.ui.DecoratedOptionWidget );
|
2013-07-02 20:40:54 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
2013-07-31 22:53:29 +00:00
|
|
|
/** */
|
2013-07-02 20:40:54 +00:00
|
|
|
ve.ui.MWParameterResultWidget.prototype.buildLabel = function () {
|
|
|
|
var i, len,
|
2015-04-09 23:47:15 +00:00
|
|
|
$label = $( '<div>' )
|
2013-07-02 20:40:54 +00:00
|
|
|
.addClass( 've-ui-mwParameterResultWidget-label' )
|
|
|
|
.text( this.data.label ),
|
2015-04-09 23:47:15 +00:00
|
|
|
$names = $( '<div>' )
|
2013-07-02 20:40:54 +00:00
|
|
|
.addClass( 've-ui-mwParameterResultWidget-names' ),
|
2015-04-09 23:47:15 +00:00
|
|
|
$description = $( '<div>' )
|
2013-07-02 20:40:54 +00:00
|
|
|
.addClass( 've-ui-mwParameterResultWidget-description' )
|
|
|
|
.text( this.data.description || '' );
|
|
|
|
|
|
|
|
if ( this.data.name ) {
|
|
|
|
$names.append(
|
2015-04-09 23:47:15 +00:00
|
|
|
$( '<span>' )
|
2013-07-02 20:40:54 +00:00
|
|
|
.addClass( 've-ui-mwParameterResultWidget-name' )
|
|
|
|
.text( this.data.name )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
for ( i = 0, len = this.data.aliases.length; i < len; i++ ) {
|
|
|
|
$names.append(
|
2015-04-09 23:47:15 +00:00
|
|
|
$( '<span>' )
|
2013-07-02 20:40:54 +00:00
|
|
|
.addClass( 've-ui-mwParameterResultWidget-name' )
|
2015-08-19 17:33:02 +00:00
|
|
|
.text( this.data.aliases[ i ] )
|
2013-07-02 20:40:54 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $label.add( $names ).add( $description );
|
2013-07-31 22:53:29 +00:00
|
|
|
};
|