10e8c1fc5384eb3cc05a5014c001e42908cf4af2
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Resources / Public / JavaScript / Wizard / Elements / Basic / Textarea.js
1 Ext.namespace('TYPO3.Form.Wizard.Elements.Basic');
2
3 /**
4 * The TEXTAREA element
5 *
6 * @class TYPO3.Form.Wizard.Elements.Basic.Textarea
7 * @extends TYPO3.Form.Wizard.Elements
8 */
9 TYPO3.Form.Wizard.Elements.Basic.Textarea = Ext.extend(TYPO3.Form.Wizard.Elements, {
10 /**
11 * @cfg {String} elementClass
12 * An extra CSS class that will be added to this component's Element
13 */
14 elementClass: 'textarea',
15
16 /**
17 * @cfg {Mixed} tpl
18 * An Ext.Template, Ext.XTemplate or an array of strings to form an
19 * Ext.XTemplate. Used in conjunction with the data and tplWriteMode
20 * configurations.
21 */
22 tpl: new Ext.XTemplate(
23 '<div class="overflow-hidden">',
24 '<tpl for="label">',
25 '<tpl if="value && parent.layout == \'front\'">',
26 '<label for="">{value}{[this.getMessage(parent.validation)]}</label>',
27 '</tpl>',
28 '</tpl>',
29 '<textarea {[this.getAttributes(values.attributes)]}>{data}</textarea>',
30 '<tpl for="label">',
31 '<tpl if="value && parent.layout == \'back\'">',
32 '<label for="">{value}{[this.getMessage(parent.validation)]}</label>',
33 '</tpl>',
34 '</tpl>',
35 '</div>',
36 {
37 compiled: true,
38 getMessage: function(rules) {
39 var messageHtml = '';
40 var messages = [];
41 Ext.iterate(rules, function(rule, configuration) {
42 if (configuration.showMessage) {
43 messages.push(configuration.message);
44 }
45 }, this);
46
47 messageHtml = ' <em>' + messages.join(', ') + '</em>';
48 return messageHtml;
49
50 },
51 getAttributes: function(attributes) {
52 var attributesHtml = '';
53 Ext.iterate(attributes, function(key, value) {
54 if (value) {
55 attributesHtml += key + '="' + value + '" ';
56 }
57 }, this);
58 return attributesHtml;
59 }
60 }
61 ),
62
63 /**
64 * Constructor
65 *
66 * Add the configuration object to this component
67 * @param config
68 */
69 constructor: function(config) {
70 Ext.apply(this, {
71 configuration: {
72 attributes: {
73 accesskey: '',
74 "class": '',
75 cols: '40',
76 dir: '',
77 disabled: '',
78 id: '',
79 lang: '',
80 name: '',
81 readonly: '',
82 rows: '5',
83 style: '',
84 tabindex: '',
85 title: ''
86 },
87 data: '',
88 filters: {},
89 label: {
90 value: TYPO3.l10n.localize('elements_label')
91 },
92 layout: 'front',
93 validation: {}
94 }
95 });
96 TYPO3.Form.Wizard.Elements.Basic.Textarea.superclass.constructor.apply(this, arguments);
97 }
98 });
99
100 Ext.reg('typo3-form-wizard-elements-basic-textarea', TYPO3.Form.Wizard.Elements.Basic.Textarea);