mediawiki-extensions-Visual.../modules/ve-mw/ui/widgets/ve.ui.MWParameterResultWidget.js
Trevor Parscal 3a6e91dfb7 RTL Improvements
Objectives:

* Make option widget icons correctly placed in RTL
* Make embedded context toolbar correctly placed in RTL

Approach:

Use separate elements for icons within option widgets which have more
flexibility when rendering in either LTR or RTL when compared to CSS
background position. The simpler approach, using CSS background
position offsets, isn't cross-browser compatible at this time.

Changes:

ve.ui.OutlineItemWidget.js
* Remove custom icon implementation, using parent class implementation
  instead

ve.ui.OptionWidget.js
* Add icon option, which adds an icon element only if an icon was
  specified

ve.ui.MenuItemWidget.js, ve-mw/ve.ui.MWParameterResultWidget.js
* Add override for icon config option
* Document icon config as private

ve.ui.Context.js
* Add detection and special handling for positioning embedded context
  toolbar when rendering in RTL

ve.ui.Widget.css
* Add styles for option widget's new icon option
* Add styles to make indentation still work for outline item widgets
* Adjust styles for menu item widget as per changes in option widget

ve-mw/ve.ui.Widget.css
* Adjust styles for parameter result widget as per changes in option
  widget

Change-Id: Ibfa4b613e0fd7902f8a2c78b5717de402c5f82b8
2013-07-10 00:09:22 +00:00

72 lines
1.8 KiB
JavaScript

/*!
* VisualEditor UserInterface MWParameterResultWidget class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* Creates an ve.ui.MWParameterResultWidget object.
*
* @class
* @extends ve.ui.OptionWidget
*
* @constructor
* @param {Mixed} data Item data
* @param {Object} [config] Config options
*/
ve.ui.MWParameterResultWidget = function VeUiMWParameterResultWidget( data, config ) {
// Configuration initialization
config = ve.extendObject( {}, config, { 'icon': 'parameter' } );
// Parent constructor
ve.ui.OptionWidget.call( this, data, config );
// Initialization
this.$.addClass( 've-ui-mwParameterResultWidget' );
this.setLabel( this.buildLabel() );
};
/**
* @private
* @cfg {string} icon
*/
/* Inheritance */
ve.inheritClass( ve.ui.MWParameterResultWidget, ve.ui.OptionWidget );
/* Static Properties */
ve.ui.MWParameterResultWidget.static.highlightable = false;
/* Methods */
ve.ui.MWParameterResultWidget.prototype.buildLabel = function () {
var i, len,
$label = this.$$( '<div>' )
.addClass( 've-ui-mwParameterResultWidget-label' )
.text( this.data.label ),
$names = this.$$( '<div>' )
.addClass( 've-ui-mwParameterResultWidget-names' ),
$description = this.$$( '<div>' )
.addClass( 've-ui-mwParameterResultWidget-description' )
.text( this.data.description || '' );
if ( this.data.name ) {
$names.append(
this.$$( '<span>' )
.addClass( 've-ui-mwParameterResultWidget-name' )
.text( this.data.name )
);
}
for ( i = 0, len = this.data.aliases.length; i < len; i++ ) {
$names.append(
this.$$( '<span>' )
.addClass( 've-ui-mwParameterResultWidget-name' )
.text( this.data.aliases[i] )
);
}
return $label.add( $names ).add( $description );
};