2016-09-15 17:53:51 +00:00
|
|
|
/* [0] On efface le <body>
|
|
|
|
=========================================================*/
|
|
|
|
document.body.innerHTML = '';
|
2016-09-16 14:52:41 +00:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2016-09-17 08:02:22 +00:00
|
|
|
|
|
|
|
var default_definition = {
|
2016-09-17 14:04:03 +00:00
|
|
|
'input': { node_type: 'input' },
|
|
|
|
'/^h([1-6])$/': { node_type: 'h{$1}' },
|
|
|
|
'br': { node_type: 'br' },
|
|
|
|
'option': { node_type: 'option' },
|
|
|
|
'select': { node_type: 'select' },
|
|
|
|
'span': { node_type: 'span' }
|
2016-09-17 08:02:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var custom_definition = {
|
2016-09-17 16:58:18 +00:00
|
|
|
'/^input\.([a-z]+)$/': {
|
2016-09-17 08:02:22 +00:00
|
|
|
node: 'input',
|
|
|
|
attributes: {
|
|
|
|
'type': '{$1}',
|
|
|
|
'data-name': '{name}',
|
|
|
|
'value': '{value}',
|
|
|
|
'placeholder': '{placeholder}'
|
|
|
|
},
|
|
|
|
next_nodes: [{ node: 'br' }]
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
'custom-select': {
|
|
|
|
node: 'span',
|
|
|
|
attributes: { 'class': 'select-container nobold' },
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
node: 'select',
|
|
|
|
attributes: { 'data-name': '{name}' },
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
node: 'option',
|
|
|
|
attribute: { value: '{options.value}' },
|
|
|
|
text: '{options.value}',
|
|
|
|
repeat: '{{options}}'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
next_nodes: [{ node: 'br' }]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-09-16 14:52:41 +00:00
|
|
|
var form = {
|
|
|
|
node: 'h4',
|
|
|
|
attributes: { 'data-icon': 'o', 'class': 'new-contact color2' },
|
|
|
|
children: [
|
2016-09-18 09:29:46 +00:00
|
|
|
{ node: 'input.hidden', $name: 'uid', $value: '{uid}' },
|
|
|
|
{ node: 'input.hidden', $name: 'call', $value: '{call}' },
|
|
|
|
{ node: 'input.hidden', $name: 'sms', $value: '{sms}' },
|
|
|
|
{ node: 'input.hidden', $name: 'countcall', $value: '{countcall}' },
|
|
|
|
{ node: 'input.hidden', $name: 'countsms', $value: '{countsms}' },
|
|
|
|
{ node: 'input.hidden', $name: 'total', $value: '{countcall} calls + {countsms} sms to {number}' },
|
2016-09-17 16:58:18 +00:00
|
|
|
|
2016-09-18 09:29:46 +00:00
|
|
|
{ node: 'input.text', $name: 'number', $value: '{number}' },
|
2016-09-16 14:52:41 +00:00
|
|
|
|
2016-09-17 16:44:17 +00:00
|
|
|
{ node: 'custom-select', $name: 'existing', $$options: '{{options}}' }
|
2016-09-16 14:52:41 +00:00
|
|
|
]
|
|
|
|
};
|
2016-09-17 08:02:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fb = new FormBuilder(document.body, form);
|
|
|
|
fb.add_definition(default_definition);
|
|
|
|
fb.add_definition(custom_definition);
|
2016-09-18 09:29:46 +00:00
|
|
|
fb.build({
|
|
|
|
uid: 1,
|
|
|
|
call: 2,
|
|
|
|
sms: 3,
|
|
|
|
countcall: 4,
|
|
|
|
countsms: 5,
|
|
|
|
number: '01 02 03 04 05',
|
|
|
|
options: ['a', 'b', 'c', 'd']
|
|
|
|
});
|