[TASK] EXT:form - Add HTML4 / HTML5 attributes for RADIO to wizard
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Resources / Public / JavaScript / Wizard / Elements / Basic / Radio.js
1 Ext.namespace('TYPO3.Form.Wizard.Elements.Basic');
2
3 /**
4 * The RADIO element
5 *
6 * @class TYPO3.Form.Wizard.Elements.Basic.Radio
7 * @extends TYPO3.Form.Wizard.Elements
8 */
9 TYPO3.Form.Wizard.Elements.Basic.Radio = 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: 'x-radio',
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 'checked': '',
91 'disabled': '',
92 'name': '',
93 'readonly': '',
94 'required': '',
95 'type': 'radio',
96 'value': ''
97 },
98 filters: {},
99 label: {
100 value: TYPO3.l10n.localize('elements_label')
101 },
102 layout: 'back',
103 validation: {}
104 }
105 });
106 TYPO3.Form.Wizard.Elements.Basic.Radio.superclass.constructor.apply(this, arguments);
107 }
108 });
109
110 Ext.reg('typo3-form-wizard-elements-basic-radio', TYPO3.Form.Wizard.Elements.Basic.Radio);