Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/ui/widgets/ve.ui.MWLazyMultilineTextInputWidget.js

raw symbols SCIP
1 /*!
2 * VisualEditor UserInterface MWLazyMultilineTextInputWidget class.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 /**
9 * Creates a ve.ui.MWLazyMultilineTextInputWidget object.
10 *
11 * This widget is a hack to be used when you are building a UI
12 * that potentially contains lots of multi-line text input widgets,
13 * such as the template param editor.
14 *
15 * It defers the calculation of the auto height until the first focus,
16 * as doing this hundreds of times is slow.
17 *
18 * @class
19 * @extends OO.ui.MultilineTextInputWidget
20 *
21 * @constructor
22 * @param {Object} [config] Configuration options
23 * @param {boolean} [config.autosize=false]
24 */
25 ve.ui.MWLazyMultilineTextInputWidget = function VeUiMWLazyMultilineTextInputWidget() {
26 // Parent constructor
27 ve.ui.MWLazyMultilineTextInputWidget.super.apply( this, arguments );
28
29 // Check autosize is set, but if it isn't you probably shouldn't be using this widget!
30 if ( this.autosize ) {
31 this.$input.addClass( 've-ui-mwLazyMultilineTextInputWidget-collapsed' );
32 this.autosize = false;
33 this.$input.one( 'focus', () => {
34 this.$input.removeClass( 've-ui-mwLazyMultilineTextInputWidget-collapsed' );
35 this.autosize = true;
36 this.adjustSize();
37 } );
38 }
39 };
40
41 /* Inheritance */
42
43 OO.inheritClass( ve.ui.MWLazyMultilineTextInputWidget, OO.ui.MultilineTextInputWidget );