20e4e6bb82b7092a8a95ee0b22c07d3f18f10941
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Resources / Public / JavaScript / Wizard / Elements / Predefined / Name.js
1 Ext.namespace('TYPO3.Form.Wizard.Elements.Predefined');
2
3 /**
4 * The predefined NAME element
5 *
6 * @class TYPO3.Form.Wizard.Elements.Predefined.Name
7 * @extends TYPO3.Form.Wizard.Elements.Basic.Fieldset
8 */
9 TYPO3.Form.Wizard.Elements.Predefined.Name = Ext.extend(TYPO3.Form.Wizard.Elements.Basic.Fieldset, {
10 /**
11 * Initialize the component
12 */
13 initComponent: function() {
14 var config = {
15 configuration: {
16 attributes: {
17 "class": 'predefined-name fieldset-subgroup fieldset-horizontal label-below',
18 dir: '',
19 id: '',
20 lang: '',
21 style: ''
22 },
23 legend: {
24 value: TYPO3.l10n.localize('elements_legend_name')
25 },
26 various: {
27 prefix: true,
28 suffix: true,
29 middleName: true
30 }
31 }
32 };
33
34 // apply config
35 Ext.apply(this, Ext.apply(config, this.initialConfig));
36
37 // call parent
38 TYPO3.Form.Wizard.Elements.Predefined.Name.superclass.initComponent.apply(this, arguments);
39
40 this.on('configurationChange', this.rebuild, this);
41
42 this.on('afterrender', this.rebuild, this);
43 },
44
45 /**
46 * Add the fields to the containerComponent of this fieldset,
47 * according to the configuration options.
48 *
49 * @param component
50 */
51 rebuild: function(component) {
52 this.containerComponent.removeAll();
53 var dummy = this.containerComponent.findById('dummy');
54 if (dummy) {
55 this.containerComponent.remove(dummy, true);
56 }
57 if (this.configuration.various.prefix) {
58 var prefix = this.containerComponent.add({
59 xtype: 'typo3-form-wizard-elements-basic-textline',
60 isEditable: false,
61 cls: '',
62 configuration: {
63 label: {
64 value: TYPO3.l10n.localize('elements_label_prefix')
65 },
66 attributes: {
67 name: 'prefix',
68 size: 4
69 },
70 layout: 'back'
71 }
72 });
73 }
74 var firstName = this.containerComponent.add({
75 xtype: 'typo3-form-wizard-elements-basic-textline',
76 isEditable: false,
77 cls: '',
78 configuration: {
79 label: {
80 value: TYPO3.l10n.localize('elements_label_firstname')
81 },
82 attributes: {
83 name: 'firstName',
84 size: 10
85 },
86 layout: 'back',
87 validation: {
88 required: {
89 breakOnError: 0,
90 showMessage: true,
91 message: '*',
92 error: 'Required'
93 }
94 }
95 }
96 });
97 if (this.configuration.various.middleName) {
98 var middleName = this.containerComponent.add({
99 xtype: 'typo3-form-wizard-elements-basic-textline',
100 isEditable: false,
101 cls: '',
102 configuration: {
103 label: {
104 value: TYPO3.l10n.localize('elements_label_middlename')
105 },
106 attributes: {
107 name: 'middleName',
108 size: 6
109 },
110 layout: 'back'
111 }
112 });
113 }
114 var lastName = this.containerComponent.add({
115 xtype: 'typo3-form-wizard-elements-basic-textline',
116 isEditable: false,
117 cls: '',
118 configuration: {
119 label: {
120 value: TYPO3.l10n.localize('elements_label_lastname')
121 },
122 attributes: {
123 name: 'lastName',
124 size: 15
125 },
126 layout: 'back',
127 validation: {
128 required: {
129 breakOnError: 0,
130 showMessage: true,
131 message: '*',
132 error: 'Required'
133 }
134 }
135 }
136 });
137 if (this.configuration.various.suffix) {
138 var suffix = this.containerComponent.add({
139 xtype: 'typo3-form-wizard-elements-basic-textline',
140 isEditable: false,
141 cls: '',
142 configuration: {
143 label: {
144 value: TYPO3.l10n.localize('elements_label_suffix')
145 },
146 attributes: {
147 name: 'suffix',
148 size: 4
149 },
150 layout: 'back'
151 }
152 });
153 }
154 this.containerComponent.doLayout();
155 }
156 });
157
158 Ext.reg('typo3-form-wizard-elements-predefined-name', TYPO3.Form.Wizard.Elements.Predefined.Name);