[TASK] EXT:form - Set proper default values in form wizard
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Resources / Public / JavaScript / Wizard / Elements / Basic / Button.js
1 Ext.namespace('TYPO3.Form.Wizard.Elements.Basic');
2
3 /**
4 * The BUTTON element
5 *
6 * @class TYPO3.Form.Wizard.Elements.Basic.Button
7 * @extends TYPO3.Form.Wizard.Elements
8 */
9 TYPO3.Form.Wizard.Elements.Basic.Button = 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: 'button',
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 'class': '',
75 'contenteditable': '',
76 'contextmenu': '',
77 'dir': '',
78 'draggable': '',
79 'dropzone': '',
80 'hidden': '',
81 'id': '',
82 'lang': '',
83 'spellcheck': '',
84 'style': '',
85 'tabindex': '',
86 'title': '',
87 'translate': '',
88
89 'autofocus': '',
90 'disabled': '',
91 'name': '',
92 'type': 'button',
93 'value': TYPO3.l10n.localize('tx_form_domain_model_element_button.value')
94 },
95 filters: {},
96 label: {
97 value: TYPO3.l10n.localize('elements_label')
98 },
99 layout: 'front',
100 validation: {}
101 }
102 });
103 TYPO3.Form.Wizard.Elements.Basic.Button.superclass.constructor.apply(this, arguments);
104 }
105 });
106
107 Ext.reg('typo3-form-wizard-elements-basic-button', TYPO3.Form.Wizard.Elements.Basic.Button);