mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 19:09:29 +00:00
a2e59f7c86
*.php * Updated links to files ve.ui.MetaDialog * Added stack panel that now contains category and language editor panels * Attached outline widget to stack panel ve.ui.FlaggableWidget -> ve.ui.FlaggableElement * Moved to elements ve.ui.GroupWidget -> ve.ui.GroupElement * Moved to elements * Removed invalid event documentation ve.ui.LabledWidget -> ve.ui.LabledElement * Moved to elements ve.ui.StackPanelLayout.js * New class, mutually exclusive panel container ve.ui.TitledPanelLayout * Remvoed, using labeled element instead ve.ui.Element.css * Added for elements * Moved label style here, from widget styles *.css, ve.ui.ButtonWidget.js, ve.ui.InputLabelWidget, ve.ui.OptionWidget, ve.ui.SelectWidget * Adjusted class names to reflect widget -> element migration Change-Id: I32f504c844dba7aae1b286eef06ca046627bdc8d
63 lines
1.3 KiB
JavaScript
63 lines
1.3 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface LabeledElement class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Labeled element.
|
|
*
|
|
* @class
|
|
* @abstract
|
|
*
|
|
* @constructor
|
|
* @param {jQuery} $label Label element
|
|
* @param {Object} [config] Config options
|
|
* @cfg {jQuery|string} [label=''] Label text
|
|
*/
|
|
ve.ui.LabeledElement = function VeUiLabeledElement( $label, config ) {
|
|
// Config intialization
|
|
config = config || {};
|
|
|
|
// Properties
|
|
this.$label = $label;
|
|
|
|
// Initialization
|
|
this.$label.addClass( 've-ui-labeledElement-label' );
|
|
this.setLabel( config.label );
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Set the label.
|
|
*
|
|
* @method
|
|
* @param {jQuery|string} [value] jQuery HTML node selection or string text value to use for label
|
|
* @chainable
|
|
*/
|
|
ve.ui.LabeledElement.prototype.setLabel = function ( value ) {
|
|
if ( typeof value === 'string' && value.length && /[^\s]*/.test( value ) ) {
|
|
this.$label.text( value );
|
|
} else if ( value instanceof jQuery ) {
|
|
this.$label.empty().append( value );
|
|
} else {
|
|
this.$label.html( ' ' );
|
|
}
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Fit the label.
|
|
*
|
|
* @method
|
|
* @chainable
|
|
*/
|
|
ve.ui.LabeledElement.prototype.fitLabel = function () {
|
|
if ( this.$label.autoEllipsis ) {
|
|
this.$label.autoEllipsis( { 'hasSpan': false, 'tooltip': true } );
|
|
}
|
|
return this;
|
|
};
|