mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 16:44:51 +00:00
cd6b54a4e8
Refactoring of externally sourced suggestions for text inputs. *.php * Added links to new file ve.ui.InputLabelWidget.js * Changed to focus input element, not wrapper div ve.ui.InputWidget.js * Fixed incorrect documentation ve.ui.LookupInputWidget.js * New mixing that abstracts placing a menu of options below a text input and filling it with data from an external source ve.ui.MenuWidget.js * Fixed to get reference to input element, no wrapper div ve.ui.MWLinkTargetInputWidget.js * Moved pending and lookup functionality to mixing * Implemented menu population using only matching pages, rather than a combination of that and page existence checks (fewer API calls) ve.ui.TextInputMenuWidget.js * Added configurable container to render underneath, rather than assuming this.input.$ * Added auto-position-on-window-resize functionality * Fixed frame position correction to ensure that it only is used when the overlay is in a different frame from the container to position underneath ve.ui.TextInputWidget.js * Added placeholder text feature Change-Id: If5ed1b64fd15982807691ce8bb0362970633108a
65 lines
1.4 KiB
JavaScript
65 lines
1.4 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface InputLabelWidget class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates an ve.ui.InputLabelWidget object.
|
|
*
|
|
* CSS classes will be added to the button for each flag, each prefixed with 've-ui-InputLabelWidget-'
|
|
*
|
|
* @class
|
|
* @extends ve.ui.Widget
|
|
* @mixins ve.ui.LabeledElement
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Config options
|
|
* @cfg {ve.ui.InputWidget|null} [input] Related input widget
|
|
*/
|
|
ve.ui.InputLabelWidget = function VeUiInputLabelWidget( config ) {
|
|
// Config intialization
|
|
config = ve.extendObject( { 'input': null }, config );
|
|
|
|
// Parent constructor
|
|
ve.ui.Widget.call( this, config );
|
|
|
|
// Mixin constructors
|
|
ve.ui.LabeledElement.call( this, this.$, config );
|
|
|
|
// Properties
|
|
this.input = config.input;
|
|
|
|
// Events
|
|
this.$.on( 'click', ve.bind( this.onClick, this ) );
|
|
|
|
// Initialization
|
|
this.$.addClass( 've-ui-inputLabelWidget' );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.InputLabelWidget, ve.ui.Widget );
|
|
|
|
ve.mixinClass( ve.ui.InputLabelWidget, ve.ui.LabeledElement );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ui.InputLabelWidget.static.tagName = 'label';
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handles mouse click events.
|
|
*
|
|
* @method
|
|
* @param {jQuery.Event} e Mouse click event
|
|
*/
|
|
ve.ui.InputLabelWidget.prototype.onClick = function () {
|
|
if ( !this.disabled && this.input ) {
|
|
this.input.$input.focus();
|
|
}
|
|
return false;
|
|
};
|