]> git.proxmox.com Git - extjs.git/blame - extjs/modern/modern/src/field/TextArea.js
add extjs 6.0.1 sources
[extjs.git] / extjs / modern / modern / src / field / TextArea.js
CommitLineData
6527f429
DM
1/**\r
2 * Creates an HTML textarea field on the page. This is useful whenever you need the user to enter large amounts of text\r
3 * (i.e. more than a few words). Typically, text entry on mobile devices is not a pleasant experience for the user so\r
4 * it's good to limit your use of text areas to only those occasions when free form text is required or alternative\r
5 * input methods like select boxes or radio buttons are not possible. Text Areas are usually created inside forms, like\r
6 * this:\r
7 *\r
8 * @example\r
9 * Ext.create('Ext.form.Panel', {\r
10 * fullscreen: true,\r
11 * items: [\r
12 * {\r
13 * xtype: 'fieldset',\r
14 * title: 'About you',\r
15 * items: [\r
16 * {\r
17 * xtype: 'textfield',\r
18 * label: 'Name',\r
19 * name: 'name'\r
20 * },\r
21 * {\r
22 * xtype: 'textareafield',\r
23 * label: 'Bio',\r
24 * maxRows: 4,\r
25 * name: 'bio'\r
26 * }\r
27 * ]\r
28 * }\r
29 * ]\r
30 * });\r
31 *\r
32 * In the example above we're creating a form with a {@link Ext.field.Text text field} for the user's name and a text\r
33 * area for their bio. We used the {@link #maxRows} configuration on the text area to tell it to grow to a maximum of 4\r
34 * rows of text before it starts using a scroll bar inside the text area to scroll the text.\r
35 *\r
36 * We can also create a text area outside the context of a form, like this:\r
37 *\r
38 * This creates two text fields inside a form. Text Fields can also be created outside of a Form, like this:\r
39 *\r
40 * Ext.create('Ext.field.TextArea', {\r
41 * label: 'About You',\r
42 * {@link #placeHolder}: 'Tell us about yourself...'\r
43 * });\r
44 */\r
45Ext.define('Ext.field.TextArea', {\r
46 extend: 'Ext.field.Text',\r
47 xtype: 'textareafield',\r
48 requires: ['Ext.field.TextAreaInput'],\r
49 alternateClassName: 'Ext.form.TextArea',\r
50\r
51 config: {\r
52 /**\r
53 * @cfg\r
54 * @inheritdoc\r
55 */\r
56 ui: 'textarea',\r
57\r
58 /**\r
59 * @cfg\r
60 * @inheritdoc\r
61 */\r
62 autoCapitalize: false,\r
63\r
64 /**\r
65 * @cfg\r
66 * @inheritdoc\r
67 */\r
68 component: {\r
69 xtype: 'textareainput'\r
70 },\r
71\r
72 /**\r
73 * @cfg {Number} maxRows The maximum number of lines made visible by the input.\r
74 * @accessor\r
75 */\r
76 maxRows: null\r
77 },\r
78\r
79 /**\r
80 * @private\r
81 */\r
82 updateMaxRows: function(newRows) {\r
83 this.getComponent().setMaxRows(newRows);\r
84 },\r
85\r
86 updateHeight: function(height, oldHeight) {\r
87 this.callParent([height, oldHeight]);\r
88 this.getComponent().input.setHeight(height);\r
89 },\r
90\r
91 updateWidth: function(width, oldWidth) {\r
92 this.callParent([width, oldWidth]);\r
93 this.getComponent().input.setWidth(width);\r
94 },\r
95\r
96 /**\r
97 * Called when a key has been pressed in the `<input>`\r
98 * @private\r
99 */\r
100 doKeyUp: function(me) {\r
101 // getValue to ensure that we are in sync with the dom\r
102 this.toggleClearIcon(this.getValue());\r
103 }\r
104});\r