2018-08-07 11:39:14 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MWLazyMultilineTextInputWidget class.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2018-08-07 11:39:14 +00:00
|
|
|
* @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
|
2024-05-27 04:59:02 +00:00
|
|
|
* @param {boolean} [config.autosize=false]
|
2018-08-07 11:39:14 +00:00
|
|
|
*/
|
|
|
|
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 ) {
|
2023-01-20 11:20:34 +00:00
|
|
|
this.$input.addClass( 've-ui-mwLazyMultilineTextInputWidget-collapsed' );
|
2018-08-07 11:39:14 +00:00
|
|
|
this.autosize = false;
|
2024-04-30 16:44:25 +00:00
|
|
|
this.$input.one( 'focus', () => {
|
2024-05-01 12:32:49 +00:00
|
|
|
this.$input.removeClass( 've-ui-mwLazyMultilineTextInputWidget-collapsed' );
|
|
|
|
this.autosize = true;
|
|
|
|
this.adjustSize();
|
2018-08-07 11:39:14 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWLazyMultilineTextInputWidget, OO.ui.MultilineTextInputWidget );
|