mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-04 18:58:37 +00:00
eb757c4c9f
Change-Id: Ie25e90aeb0519b1e0f793348b27d4d4a6b686698
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface MWLazyMultilineTextInputWidget class.
|
|
*
|
|
* @copyright See AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates a ve.ui.MWLazyMultilineTextInputWidget object.
|
|
*
|
|
* This widget is a hack to be used when you are building a UI
|
|
* that potentially contains lots of multi-line text input widgets,
|
|
* such as the template param editor.
|
|
*
|
|
* It defers the calculation of the auto height until the first focus,
|
|
* as doing this hundreds of times is slow.
|
|
*
|
|
* @class
|
|
* @extends OO.ui.MultilineTextInputWidget
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration options
|
|
* @cfg {boolean} [autosize=false]
|
|
*/
|
|
ve.ui.MWLazyMultilineTextInputWidget = function VeUiMWLazyMultilineTextInputWidget() {
|
|
// Parent constructor
|
|
ve.ui.MWLazyMultilineTextInputWidget.super.apply( this, arguments );
|
|
|
|
// Check autosize is set, but if it isn't you probably shouldn't be using this widget!
|
|
if ( this.autosize ) {
|
|
this.$input.addClass( 've-ui-mwLazyMultilineTextInputWidget-collapsed' );
|
|
this.autosize = false;
|
|
this.$input.one( 'focus', () => {
|
|
this.$input.removeClass( 've-ui-mwLazyMultilineTextInputWidget-collapsed' );
|
|
this.autosize = true;
|
|
this.adjustSize();
|
|
} );
|
|
}
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWLazyMultilineTextInputWidget, OO.ui.MultilineTextInputWidget );
|