diff --git a/js/lib/form-builder-min.js b/js/lib/form-builder-min.js index 4f4e826..17ff805 100644 --- a/js/lib/form-builder-min.js +++ b/js/lib/form-builder-min.js @@ -1,29 +1,29 @@ -var ref=function(a,b){for(var c=null;null==c||a.hasOwnProperty(c);)c="$"+(268435456+Math.floor(4026531839*Math.random())).toString(16)+"$";a[c]=b;return c},FormBuilder=function(a){this.form_object=a;this.observer=new MutationObserver(FormBuilder.DOMUpdates)};FormBuilder.prototype={form_object:this.form_object,defs_object:{},parent_element:null,built_form:null,root_element:null,ref_table:{$00000000$:null},ref_assoc:{NULL:"$00000000$"},observer:this.observer,scope:{}}; -FormBuilder.regex={reg_in_key:/^\/\^(.+)\$\/$/,reg_out_val:/\{(\$[1-9])\}/,pri_out_val:/\{([a-z_]+)\}/g,pri_in_key:/^\$([a-z_]+)$/,arr_out_set:/^\{([a-z_]+)\[\]\}$/,arr_out_val:/\{([a-z_]+)([\.:])([a-z_]+)\}/g,arr_in_key:/^\$([a-z_]+)$/,fun_out_val:/^\{([a-z_]+)\(\)\}$/,ref_pri:/^\$[a-f0-9]{8}\$$/};FormBuilder.spread_attr="children next_nodes prev_nodes attributes node_link listeners repeat browse funcs".split(" "); +var ref=function(a,b){for(var d=null;null==d||a.hasOwnProperty(d);)d="$"+(268435456+Math.floor(4026531839*Math.random())).toString(16)+"$";a[d]=b;return d},FormBuilder=function(a){this.form_object=a;this.observer=new MutationObserver(FormBuilder.DOMUpdates)};FormBuilder.prototype={form_object:this.form_object,defs_object:{},parent_element:null,built_form:null,root_element:null,ref_table:{$00000000$:null},ref_assoc:{NULL:"$00000000$"},observer:this.observer,scope:{}}; +FormBuilder.regex={reg_in_key:/^\/\^(.+)\$\/$/,reg_out_val:/\{(\$[1-9])\}/,pri_out_val:/\{([a-z_]+)\}/g,pri_in_key:/^\$([a-z_]+)$/,arr_out_set:/^\{([a-z_]+)\[\]\}$/,arr_out_val:/\{([a-z_]+)([\.:])([a-z_]+)\}/g,arr_in_key:/^\$([a-z_]+)$/,fun_out_val:/^\{([a-z_]+)\(\)\}$/,ref_pri:/^\$[a-f0-9]{8}\$$/};FormBuilder.spread_attr="children next_nodes prev_nodes attributes node_link listeners repeat browse funcs".split(" ");FormBuilder.spec_attr=["_value","_selected"]; FormBuilder.observe={attributes:{attributes:!0,attributeOldValue:!0,childList:!1,characterData:!1,subtree:!1,characterDataOldValue:!1},characterData:{attributes:!1,attributeOldValue:!1,childList:!1,characterData:!0,subtree:!1,characterDataOldValue:!0}};FormBuilder.debug_time=!1;FormBuilder.debug_time_details=!1; -FormBuilder.debugStart=function(a,b){if(1!=b||!FormBuilder.debug_time)if(2!=b||!FormBuilder.debug_time_details)return{type:0};var c="["+parseInt(64424509439*Math.random()).toString(16)+"]";console.time(c);console.group(a);return{type:b,time_r:c,group:a}};FormBuilder.debug=function(a,b){if(1!=b||!FormBuilder.debug_time)if(2!=b||!FormBuilder.debug_time_details)return{type:0};console.debug(a)}; -FormBuilder.debugStop=function(a){if(1!=a.type||!FormBuilder.debug_time)if(2!=a.type||!FormBuilder.debug_time_details)return null;console.timeEnd(a.time_r);console.groupEnd(a.group)};FormBuilder.prototype.add_definition=function(a){var b=FormBuilder.debugStart("FormBuilder.add_definition",1),c;for(c in a)this.defs_object[c]=a[c];FormBuilder.debugStop(b)}; -FormBuilder.prototype.build=function(a){var b=FormBuilder.debugStart("FormBuilder.build",1);a=null==a?{}:a;for(var c in a)a[c]=ref(this.ref_table,a[c]),this.ref_assoc[c]=a[c],this.scope["$"+c]=this.ref_assoc[c],this.__defineGetter__("$"+c,function(a,b){return function(){return a.ref_table[a.scope["$"+b]]}}(this,c)),this.__defineSetter__("$"+c,function(a,b){return function(c){a.ref_table[a.scope["$"+b]]=c;a.attach()}}(this,c));this.built_form=JSON.parse(JSON.stringify(this.form_object));this.built_form= -FormBuilder.replaceStatements(this.built_form,a,this.defs_object,this.ref_table,this.ref_assoc);FormBuilder.debugStop(b)};FormBuilder.prototype.update=function(a){var b=FormBuilder.debugStart("FormBuilder.update",1);a=null==a?{}:a;for(var c in a)this.ref_assoc.hasOwnProperty(c)&&(this.ref_table[this.ref_assoc[c]]=a[c]);FormBuilder.debugStop(b)}; +FormBuilder.debugStart=function(a,b){if(1!=b||!FormBuilder.debug_time)if(2!=b||!FormBuilder.debug_time_details)return{type:0};var d="["+parseInt(64424509439*Math.random()).toString(16)+"]";console.time(d);console.group(a);return{type:b,time_r:d,group:a}};FormBuilder.debug=function(a,b){if(1!=b||!FormBuilder.debug_time)if(2!=b||!FormBuilder.debug_time_details)return{type:0};console.debug(a)}; +FormBuilder.debugStop=function(a){if(1!=a.type||!FormBuilder.debug_time)if(2!=a.type||!FormBuilder.debug_time_details)return null;console.timeEnd(a.time_r);console.groupEnd(a.group)};FormBuilder.prototype.add_definition=function(a){var b=FormBuilder.debugStart("FormBuilder.add_definition",1),d;for(d in a)this.defs_object[d]=a[d];FormBuilder.debugStop(b)}; +FormBuilder.prototype.build=function(a){var b=FormBuilder.debugStart("FormBuilder.build",1);a=null==a?{}:a;for(var d in a)a[d]=ref(this.ref_table,a[d]),this.ref_assoc[d]=a[d],this.scope["$"+d]=this.ref_assoc[d],this.__defineGetter__("$"+d,function(a,b){return function(){return a.ref_table[a.scope["$"+b]]}}(this,d)),this.__defineSetter__("$"+d,function(a,b){return function(d){a.ref_table[a.scope["$"+b]]=d;a.attach()}}(this,d));this.built_form=JSON.parse(JSON.stringify(this.form_object));this.built_form= +FormBuilder.replaceStatements(this.built_form,a,this.defs_object,this.ref_table,this.ref_assoc);FormBuilder.debugStop(b)};FormBuilder.prototype.update=function(a){var b=FormBuilder.debugStart("FormBuilder.update",1);a=null==a?{}:a;for(var d in a)this.ref_assoc.hasOwnProperty(d)&&(this.ref_table[this.ref_assoc[d]]=a[d]);FormBuilder.debugStop(b)}; FormBuilder.prototype.attach=function(a){var b=FormBuilder.debugStart("FormBuilder.attach",1);if(!(a instanceof Element)&&null===this.parent_element)return!1;this.parent_element=a instanceof Element?a:this.parent_element;this.built_form.hasOwnProperty("dom")&&(this.observer.disconnect(),FormBuilder.detachElements(this.parent_element,this.built_form.dom));FormBuilder.createElements(this.built_form,this.ref_table,this.ref_assoc);FormBuilder.attachElements(this.parent_element,this.built_form.dom);this.observer.observe(this.parent_element, FormBuilder.observe.attributes);FormBuilder.debugStop(b)}; -FormBuilder.fetchNodeDefinition=function(a,b){var c=FormBuilder.debugStart("FormBuilder::fetchNodeDefinition",2);FormBuilder.debug('node = "'+a+'"',2);var e,f;r=FormBuilder.regex.reg_in_key;if("undefined"!=typeof b&&b.hasOwnProperty(a))return FormBuilder.debugStop(c),{def:b[a]};for(e in b)if(r.test(e)&&(f=new RegExp(e.slice(1,-1)),f.test(a))){matches={};for(f=1;ff;f++)matches["$"+f]=RegExp["$"+f];FormBuilder.debugStop(c);return{def:b[e],scope:matches}}FormBuilder.debugStop(c);return{}}; -FormBuilder.replaceStatements=function(a,b,c,e,f){var g=FormBuilder.debugStart("FormBuilder::replaceStatements",2);a=a instanceof Object?a:{};b=b instanceof Object?JSON.parse(JSON.stringify(b)):{};var d,h;if(a.hasOwnProperty("scope")&&a.scope instanceof Object)for(d in a.scope)b[d]=a.scope[d];if(a.hasOwnProperty("node")&&"string"==typeof a.node&&(h=FormBuilder.fetchNodeDefinition(a.node,c),h.hasOwnProperty("def")&&(a.node_link=JSON.parse(JSON.stringify(h.def)),h.hasOwnProperty("scope"))))for(d in h.scope)b[d]= -h.scope[d];a.hasOwnProperty("browse")&&(a.browse.hasOwnProperty("array")&&FormBuilder.regex.arr_out_set.test(a.browse.array)?a.browse.id=RegExp.$1:delete a.browse);for(d in a)"string"==typeof a[d]?(a[d]=[a[d]],h=FormBuilder.replaceStatementsFunction(a[d][0],b,e),!1!==h?a[d]=h:(h=FormBuilder.replaceStatementsArray(a[d][0],b,e),!1!==h?a[d]=h:(a[d]=FormBuilder.replaceStatementsRegex(a[d],b),a[d]=FormBuilder.replaceStatementsPrimary(a[d],b),a[d]=FormBuilder.replaceStatementsArrayValue(a[d],b,e,f)))): -"number"===typeof a[d]&&(a[d]=[ref(e,a[d])]);for(d in a)FormBuilder.regex.pri_in_key.test(d)?b[d.substring(1)]=ref(e,a[d]):FormBuilder.regex.arr_in_key.test(d)&&(b[d.substring(2)]=ref(e,a[d]));b=JSON.parse(JSON.stringify(b));for(d in a)if(-1=c.lastIndex);)g=c.lastIndex,f.push(e);for(e=g=0;e",2);FormBuilder.debugStop(e);return a.dom=f}; -FormBuilder.attachElements=function(a,b){var c=FormBuilder.debugStart("FormBuilder::attachElements",2),e,f;for(e in b){for(f in b[e].prev)b[e].prev[f]instanceof Element&&a.appendChild(b[e].prev[f]),b[e].prev[f]instanceof Object&&FormBuilder.attachElements(a,[b[e].prev[f]]);for(f in b[e].node)b[e].node[f]instanceof Element&&a.appendChild(b[e].node[f]),b[e].node[f]instanceof Object&&FormBuilder.attachElements(a,[b[e].node[f]]);for(f in b[e].next)b[e].next[f]instanceof Element&&a.appendChild(b[e].next[f]), -b[e].next[f]instanceof Object&&FormBuilder.attachElements(a,[b[e].next[f]])}FormBuilder.debugStop(c)}; -FormBuilder.detachElements=function(a,b){var c,e;for(c in b){for(e in b[c].prev)b[c].prev[e]instanceof Element&&a.removeChild(b[c].prev[e]),b[c].prev[e]instanceof Object&&FormBuilder.detachElements(a,[b[c].prev[e]]);for(e in b[c].node)b[c].node[e]instanceof Element&&a.removeChild(b[c].node[e]),b[c].node[e]instanceof Object&&FormBuilder.detachElements(a,[b[c].node[e]]);for(e in b[c].next)b[c].next[e]instanceof Element&&a.removeChild(b[c].next[e]),b[c].next[e]instanceof Object&&FormBuilder.detachElements(a, -[b[c].next[e]])}};FormBuilder.applyCSS=function(a,b){for(var c in b)a.style[c]=b[c]};FormBuilder.DOMUpdates=function(a){for(var b in a)console.log(a[b]),console.log(a[b].target),console.log(a[b].type)}; +FormBuilder.fetchNodeDefinition=function(a,b){var d=FormBuilder.debugStart("FormBuilder::fetchNodeDefinition",2);FormBuilder.debug('node = "'+a+'"',2);var e,f;r=FormBuilder.regex.reg_in_key;if("undefined"!=typeof b&&b.hasOwnProperty(a))return FormBuilder.debugStop(d),{def:b[a]};for(e in b)if(r.test(e)&&(f=new RegExp(e.slice(1,-1)),f.test(a))){matches={};for(f=1;ff;f++)matches["$"+f]=RegExp["$"+f];FormBuilder.debugStop(d);return{def:b[e],scope:matches}}FormBuilder.debugStop(d);return{}}; +FormBuilder.replaceStatements=function(a,b,d,e,f){var g=FormBuilder.debugStart("FormBuilder::replaceStatements",2);a=a instanceof Object?a:{};b=b instanceof Object?JSON.parse(JSON.stringify(b)):{};var c,h;if(a.hasOwnProperty("scope")&&a.scope instanceof Object)for(c in a.scope)b[c]=a.scope[c];if(a.hasOwnProperty("node")&&"string"==typeof a.node&&(h=FormBuilder.fetchNodeDefinition(a.node,d),h.hasOwnProperty("def")&&(a.node_link=JSON.parse(JSON.stringify(h.def)),h.hasOwnProperty("scope"))))for(c in h.scope)b[c]= +h.scope[c];a.hasOwnProperty("browse")&&(a.browse.hasOwnProperty("array")&&FormBuilder.regex.arr_out_set.test(a.browse.array)?a.browse.id=RegExp.$1:delete a.browse);for(c in a)"string"==typeof a[c]?(a[c]=[a[c]],h=FormBuilder.replaceStatementsFunction(a[c][0],b,e),!1!==h?a[c]=h:(h=FormBuilder.replaceStatementsArray(a[c][0],b,e),!1!==h?a[c]=h:(a[c]=FormBuilder.replaceStatementsRegex(a[c],b),a[c]=FormBuilder.replaceStatementsPrimary(a[c],b),a[c]=FormBuilder.replaceStatementsArrayValue(a[c],b,e,f)))): +"number"===typeof a[c]&&(a[c]=[ref(e,a[c])]);for(c in a)FormBuilder.regex.pri_in_key.test(c)?b[c.substring(1)]=ref(e,a[c]):FormBuilder.regex.arr_in_key.test(c)&&(b[c.substring(2)]=ref(e,a[c]));b=JSON.parse(JSON.stringify(b));for(c in a)if(-1=d.lastIndex);)g=d.lastIndex,f.push(e);for(e=g=0;e",2);FormBuilder.debugStop(e);return a.dom=f}; +FormBuilder.attachElements=function(a,b){var d=FormBuilder.debugStart("FormBuilder::attachElements",2),e,f;for(e in b){for(f in b[e].prev)b[e].prev[f]instanceof Element&&a.appendChild(b[e].prev[f]),b[e].prev[f]instanceof Object&&FormBuilder.attachElements(a,[b[e].prev[f]]);for(f in b[e].node)b[e].node[f]instanceof Element&&a.appendChild(b[e].node[f]),b[e].node[f]instanceof Object&&FormBuilder.attachElements(a,[b[e].node[f]]);for(f in b[e].next)b[e].next[f]instanceof Element&&a.appendChild(b[e].next[f]), +b[e].next[f]instanceof Object&&FormBuilder.attachElements(a,[b[e].next[f]])}FormBuilder.debugStop(d)}; +FormBuilder.detachElements=function(a,b){var d,e;for(d in b){for(e in b[d].prev)b[d].prev[e]instanceof Element&&a.removeChild(b[d].prev[e]),b[d].prev[e]instanceof Object&&FormBuilder.detachElements(a,[b[d].prev[e]]);for(e in b[d].node)b[d].node[e]instanceof Element&&a.removeChild(b[d].node[e]),b[d].node[e]instanceof Object&&FormBuilder.detachElements(a,[b[d].node[e]]);for(e in b[d].next)b[d].next[e]instanceof Element&&a.removeChild(b[d].next[e]),b[d].next[e]instanceof Object&&FormBuilder.detachElements(a, +[b[d].next[e]])}};FormBuilder.applyCSS=function(a,b){for(var d in b)a.style[d]=b[d]};FormBuilder.fetchNodeType=function(a){if(a.hasOwnProperty("node_type"))return a.node_type;if(a.hasOwnProperty("node_link"))return FormBuilder.fetchNodeType(a.node_link)};FormBuilder.DOMUpdates=function(a){for(var b in a)console.log(a[b]),console.log(a[b].target),console.log(a[b].type)}; diff --git a/js/lib/form-builder.js b/js/lib/form-builder.js index aa7a981..8d7d42f 100644 --- a/js/lib/form-builder.js +++ b/js/lib/form-builder.js @@ -112,6 +112,11 @@ FormBuilder.spread_attr = [ // Liste des attributs diffusant le scope 'funcs' ]; +FormBuilder.spec_attr = [ // Liste des attributs à dupliquer jusque dans la definition primaire + '_value', + '_selected' +]; + // Configuration des observers FormBuilder.observe = { attributes: { @@ -1150,78 +1155,7 @@ FormBuilder.createElements = function(definition, ref_table, ref_assoc){ else if( definition.hasOwnProperty('node_type') ){ // {1} Création de l'élément // - var created = built[b].node.push( document.createElement( FormBuilder.readRef(ref_table, definition.node_type) ) ) - 1; - - // {2} Determination du type // - var input = definition.node_type == 'input' && definition.hasOwnProperty('value'); - var select = definition.node_type == 'select' && definition.hasOwnProperty('selected'); - - // {3} Si de type texte // - if( input ){ - - // On met à jour la valeur - built[b].node[created].addEventListener('input', function(e){ - - // Uniquement si tableau de taille 1 avec une reference - if( !(definition.value instanceof Array) ) return; - if( definition.value.length > 1 ) return; - if( !FormBuilder.regex.ref_pri.test(definition.value[0]) ) return; - - // on recupere cette reference - var value_ref = definition.value[0]; - - // On recupere la derniere reference - var last = value_ref, - curr = value_ref; - - // On var jusqu'a la valeur - while( FormBuilder.regex.ref_pri.test(curr) ){ - last = curr; - curr = ref_table[ curr ]; - - if( curr instanceof Array ) - curr = curr[0]; - } - - // On attribut la valeur modifiee - ref_table[ last ] = this.value; - - }, false); - - } + built[b].node.push( document.createElement( FormBuilder.readRef(ref_table, definition.node_type) ) ) - 1; } @@ -1291,8 +1225,101 @@ FormBuilder.createElements = function(definition, ref_table, ref_assoc){ } + + } + + + /* (8) Gestion de la récupération dynamique */ + for( n in built[b].node ){ + + // {2} Determination du type // + var input = FormBuilder.fetchNodeType(definition) == 'input' && definition.hasOwnProperty('_value'); + var select = FormBuilder.fetchNodeType(definition) == 'select' && definition.hasOwnProperty('_selected'); + + // {3} Si de type texte // + if( input ){ + + // On met à jour la valeur + built[b].node[n].addEventListener('input', function(e){ + + // Uniquement si tableau de taille 1 avec une reference + if( !(definition._value instanceof Array) ) return; + if( definition._value.length > 1 ) return; + if( !FormBuilder.regex.ref_pri.test(definition._value[0]) ) return; + + // on recupere cette reference + var value_ref = definition._value[0]; + + // On recupere la derniere reference + var last = value_ref, + curr = value_ref; + + // On var jusqu'a la valeur + while( FormBuilder.regex.ref_pri.test(curr) ){ + last = curr; + curr = ref_table[ curr ]; + + if( curr instanceof Array ) + curr = curr[0]; + } + + // On attribut la valeur modifiee + ref_table[ last ] = this.value; + + }, false); + + } + + // TODO: Gestion de la transmission de 'value' / 'selected' lors de la construction + + } } @@ -1457,6 +1484,26 @@ FormBuilder.applyCSS = function(element, css){ }; +/* RETOURNE LE NODE_TYPE EN PARCOURANT LES DEFINITION RECURSIVEMENT +* +* @definition Definition contenant node_link ou node_type +* +* @return node_type Node_type final en suivant les définition +* +*/ +FormBuilder.fetchNodeType = function(definition){ + + /* (1) Si c'est la définition finale */ + if( definition.hasOwnProperty('node_type') ) + return definition.node_type; + + /* (2) Si on trouve un lien vers définition, on lance récursivement */ + else if( definition.hasOwnProperty('node_link') ) + return FormBuilder.fetchNodeType(definition.node_link); + +}; + + FormBuilder.DOMUpdates = function(events){ var e; diff --git a/js/lib/form-builder/main-min.js b/js/lib/form-builder/main-min.js index b1d8b72..3cace7e 100644 --- a/js/lib/form-builder/main-min.js +++ b/js/lib/form-builder/main-min.js @@ -1,6 +1,6 @@ document.body.innerHTML="";"use strict"; -var default_definition={input:{node_type:"input",value:"{value}"},"/^h([1-6])$/":{node_type:"h{$1}"},br:{node_type:"br"},option:{node_type:"option"},select:{node_type:"select",selected:"{selected}"},span:{node_type:"span"},"/^br([0-9]+)$/":{node:"br",repeat:{n:"{$1}",id:"brs"}}},custom_definition={"/^input.([a-z]+)$/":{node:"input",attributes:{type:"{$1}","data-name":"{name}",value:"{value}",placeholder:"{placeholder}"},listeners:{click:"{click_listener()}"}},"custom-select":{node:"span",attributes:{"class":"select-container nobold"}, -children:[{node:"select",attributes:{"data-name":"{name}"},children:[{node:"option",attributes:{value:"{options:i}"},text:"{options.value}",browse:{array:"{options[]}",funcs:{"options.value":"{getoptval()}"}}}],listeners:{change:"{listener()}"},$selected:"{selected}"}]}},contactForm={node:"h4",attributes:{"data-icon":"o","class":"new-contact colo2"},children:[{node:"input.hidden",$name:"uid",$value:"{uid}"},{node:"input.hidden",$name:"call",$value:"{call}"},{node:"input.hidden",$name:"sms",$value:"{sms}"}, +var default_definition={input:{node_type:"input",_value:"{value}"},"/^h([1-6])$/":{node_type:"h{$1}"},br:{node_type:"br"},option:{node_type:"option"},select:{node_type:"select"},span:{node_type:"span"},"/^br([0-9]+)$/":{node:"br",repeat:{n:"{$1}",id:"brs"}}},custom_definition={"/^input.([a-z]+)$/":{node:"input",attributes:{type:"{$1}","data-name":"{name}",value:"{value}",placeholder:"{placeholder}"},listeners:{click:"{click_listener()}"}},"custom-select":{node:"span",attributes:{"class":"select-container nobold"}, +children:[{node:"select",attributes:{"data-name":"{name}"},children:[{node:"option",attributes:{value:"{options:i}"},text:"{options.value}",browse:{array:"{options[]}",funcs:{"options.value":"{getoptval()}"}}}],_selected:"{selected}",listeners:{change:"{listener()}"}}]}},contactForm={node:"h4",attributes:{"data-icon":"o","class":"new-contact colo2"},children:[{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:"{count_call}",$click_listener:"{my_listener()}"},{node:"input.hidden",$name:"countsms",$value:"{count_sms}"},{node:"input.text",$name:"number",$value:"{number}"},{node:"custom-select",$name:"existing",$options:"{existing[]}",$listener:"{existingsel()}",$selected:"{s}"},{node:"input.text",$name:"username",$placeholder:"{username_ph}",$value:"{username}"},{node:"input.submit",$value:"Enregistrer",attributes:{"class":"primary sub-number"}}],next_nodes:[{node:"br"}]}, a="

\n\t\n\t\n\t\n\t\n\t\n\t \n\t\n\t    ou    \n\t \n\t\n

\n\n", fb=new FormBuilder(contactForm);fb.add_definition(default_definition);fb.add_definition(custom_definition);fb.build({s:1,uid:1,call:2,sms:3,count_call:4,count_sms:5,number:"01 02 03 04 05",existing:["Jean","Archibald","Daniel","Maurice"],username:"moi-meme",username_ph:"Pseudo",my_listener:function(b){console.log("clicked",b)},existingsel:function(b){console.log("selected",b)},getoptval:function(b){return b}});fb.attach(document.body); diff --git a/js/lib/form-builder/main.js b/js/lib/form-builder/main.js index f594f7b..1bda7c4 100644 --- a/js/lib/form-builder/main.js +++ b/js/lib/form-builder/main.js @@ -6,11 +6,11 @@ document.body.innerHTML = ''; var default_definition = { - 'input': { node_type: 'input', value: '{value}' }, + 'input': { node_type: 'input', _value: '{value}' }, '/^h([1-6])$/': { node_type: 'h{$1}' }, 'br': { node_type: 'br' }, 'option': { node_type: 'option' }, - 'select': { node_type: 'select', selected: '{selected}' }, + 'select': { node_type: 'select' }, 'span': { node_type: 'span' }, '/^br([0-9]+)$/': { node: 'br', repeat: { n: '{$1}', id: 'brs' } } }; @@ -46,8 +46,8 @@ var custom_definition = { } } ], - listeners: { 'change': '{listener()}' }, - $selected: '{selected}' + _selected: '{selected}', + listeners: { 'change': '{listener()}' } } ] }