2013-07-02 20:40:54 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MWParameterResultWidget class.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 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
|
2013-10-09 20:09:59 +00:00
|
|
|
* @extends OO.ui.OptionWidget
|
2013-07-02 20:40:54 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Mixed} data Item data
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-07-02 20:40:54 +00:00
|
|
|
*/
|
|
|
|
ve.ui.MWParameterResultWidget = function VeUiMWParameterResultWidget( data, 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
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.ui.OptionWidget.call( this, data, 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 */
|
|
|
|
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.inheritClass( ve.ui.MWParameterResultWidget, OO.ui.OptionWidget );
|
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,
|
2013-11-01 19:45:59 +00:00
|
|
|
$label = this.$( '<div>' )
|
2013-07-02 20:40:54 +00:00
|
|
|
.addClass( 've-ui-mwParameterResultWidget-label' )
|
|
|
|
.text( this.data.label ),
|
2013-11-01 19:45:59 +00:00
|
|
|
$names = this.$( '<div>' )
|
2013-07-02 20:40:54 +00:00
|
|
|
.addClass( 've-ui-mwParameterResultWidget-names' ),
|
2013-11-01 19:45:59 +00:00
|
|
|
$description = this.$( '<div>' )
|
2013-07-02 20:40:54 +00:00
|
|
|
.addClass( 've-ui-mwParameterResultWidget-description' )
|
|
|
|
.text( this.data.description || '' );
|
|
|
|
|
|
|
|
if ( this.data.name ) {
|
|
|
|
$names.append(
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$( '<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(
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$( '<span>' )
|
2013-07-02 20:40:54 +00:00
|
|
|
.addClass( 've-ui-mwParameterResultWidget-name' )
|
|
|
|
.text( this.data.aliases[i] )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $label.add( $names ).add( $description );
|
2013-07-31 22:53:29 +00:00
|
|
|
};
|