mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
96e49858fa
Objective: * Add multiline option to text input widget which uses a text area instead of a text input Changes: ve.ui.Widget.css * Add text area support for styles otherwise only targeting input elements ve.ui.InputWidget.js * Initialize input element using a method, so it can be fully customized (like making a text area or select input * Use val() to set the initial value, using jQuery's abstraction around inputs of various types ve.ui.TextInputWidget.js * Add multiline option which uses a text area instead of an input Change-Id: I1bf17c8c76b7f1708c57ee5e95160c071ddd00e9
45 lines
1 KiB
JavaScript
45 lines
1 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface TextInputWidget class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates an ve.ui.TextInputWidget object.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.InputWidget
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Config options
|
|
* @cfg {string} [placeholder] Placeholder text
|
|
*/
|
|
ve.ui.TextInputWidget = function VeUiTextInputWidget( config ) {
|
|
// Parent constructor
|
|
ve.ui.InputWidget.call( this, config );
|
|
|
|
// Initialization
|
|
this.$.addClass( 've-ui-textInputWidget' );
|
|
if ( config.placeholder ) {
|
|
this.$input.attr( 'placeholder', config.placeholder );
|
|
}
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.TextInputWidget, ve.ui.InputWidget );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Get input element.
|
|
*
|
|
* @method
|
|
* @param {Object} [config] Config options
|
|
* @return {jQuery} Input element
|
|
*/
|
|
ve.ui.TextInputWidget.prototype.getInputElement = function ( config ) {
|
|
return config.multiline ? this.$$( '<textarea>' ) : this.$$( '<input>' ).attr( 'type', 'text' );
|
|
};
|