610001aa5c162735451d2c91990bc0e068d2619a
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Resources / Public / JavaScript / Wizard / Elements / Basic / Textline.js
1 Ext.namespace('TYPO3.Form.Wizard.Elements.Basic');
2
3 /**
4 * The TEXTLINE element
5 *
6 * @class TYPO3.Form.Wizard.Elements.Basic.Textline
7 * @extends TYPO3.Form.Wizard.Elements
8 */
9 TYPO3.Form.Wizard.Elements.Basic.Textline = 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: 'textline',
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 '<input {[this.getAttributes(values.attributes)]} />',
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 alt: '',
75 "class": '',
76 dir: '',
77 disabled: '',
78 id: '',
79 lang: '',
80 maxlength: '',
81 name: '',
82 readonly: '',
83 size: '',
84 style: '',
85 tabindex: '',
86 title: '',
87 type: 'text',
88 value: ''
89 },
90 filters: {},
91 label: {
92 value: TYPO3.l10n.localize('elements_label')
93 },
94 layout: 'front',
95 validation: {}
96 }
97 });
98 TYPO3.Form.Wizard.Elements.Basic.Textline.superclass.constructor.apply(this, arguments);
99 }
100 });
101
102 Ext.reg('typo3-form-wizard-elements-basic-textline', TYPO3.Form.Wizard.Elements.Basic.Textline);