diff --git a/js/lib/form-builder-min.js b/js/lib/form-builder-min.js index bd2db51..9769645 100644 --- a/js/lib/form-builder-min.js +++ b/js/lib/form-builder-min.js @@ -1,7 +1,7 @@ var FormBuilder=function(a,c){this.parent_element=a;this.form_object=c};FormBuilder.prototype={form_object:this.form_object,defs_object:{},parent_element:this.parent_element,built_form:null};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-]+)$/}; FormBuilder.spread_attr=["children","next_nodes","prev_nodes","attributes","node_link"];FormBuilder.allowed_attr="node node_type next_nodes prev_nodes attributes children text repeat".split(" ");FormBuilder.prototype.add_definition=function(a){for(var c in a)this.defs_object[c]=a[c]};FormBuilder.prototype.build=function(a){a=null==a?{}:a;this.built_form=FormBuilder.formatFormObject(this.form_object,this.defs_object);this.built_form=FormBuilder.replaceStatements(this.form_object,a)}; FormBuilder.formatFormObject=function(a,c){if(a.hasOwnProperty("node")&&"string"==typeof a.node){var f=FormBuilder.fetchNodeDefinition(a.node,c);"undefined"!=typeof f.def&&(a.node_link=JSON.parse(JSON.stringify(f.def)),f.hasOwnProperty("scope")&&(a.scope=f.scope))}if(a.hasOwnProperty("children"))for(var b in a.children)a.children[b].parent=a,FormBuilder.formatFormObject(a.children[b],c);return a}; -FormBuilder.fetchNodeDefinition=function(a,c){var f,b;r=FormBuilder.regex.reg_in_key;if(null!=c&&c.hasOwnProperty(a))return{def:c.node};for(f in c)if(r.test(f)&&(b=new RegExp(f.slice(1,-1)),b.test(a))){matches={};for(b=1;bb;b++)matches["$"+b]=RegExp["$"+b];return{def:c[f],scope:matches}}return{}}; +FormBuilder.fetchNodeDefinition=function(a,c){var f,b;r=FormBuilder.regex.reg_in_key;if(null!=c&&c.hasOwnProperty(a))return{def:c[a]};for(f in c)if(r.test(f)&&(b=new RegExp(f.slice(1,-1)),b.test(a))){matches={};for(b=1;bb;b++)matches["$"+b]=RegExp["$"+b];return{def:c[f],scope:matches}}return{}}; FormBuilder.replaceStatements=function(a,c,f){a=a instanceof Object?a:{};c=c instanceof Object?JSON.parse(JSON.stringify(c)):{};f=null==f?"":f+" ";var b,g,e;if(a.hasOwnProperty("scope")&&a.scope instanceof Object)for(b in a.scope)c[b]=a.scope[b];a.received=JSON.parse(JSON.stringify(c));for(b in a)if("string"==typeof a[b]){g=FormBuilder.regex.arr_out_set;var d=[];(e=g.exec(a[b]))&&d.push(e[1]);for(e in d)c.hasOwnProperty(d[e])||(c[d[e]]=[]),a[b]=c[d[e]];if(!(0=g.lastIndex);)lasti=g.lastIndex,d.push(e[1]);for(e in d)c.hasOwnProperty(d[e])||(c[d[e]]=""),g=new RegExp("{\\$"+d[e][1]+"}","g"),a[b]=a[b].replace(g,c[d[e]]);if(!(0