define("qui/controls/elements/FormList",["qui/QUI","qui/controls/Control","qui/controls/buttons/Button"],function(t,e,n){"use strict";return new Class({Extends:e,Type:"qui/controls/elements/FormList",Binds:["$onInject","$createEntry","$refreshDate"],options:{entry:""},initialize:function(t){this.parent(t),this.$Buttons=null,this.$Container=null,this.$Input=null,this.addEvents({onImport:this.$onImport})},create:function(){return this.$Elm=new Element("div",{"class":"qui-controls-formlist",html:'<div class="qui-controls-formlist-buttons"></div><div class="qui-controls-formlist-container"></div>'}),this.$Container=this.$Elm.getElement(".qui-controls-formlist-container"),this.$Buttons=this.$Elm.getElement(".qui-controls-formlist-buttons"),new n({text:"Eintrag hinzufügen",textimage:"icon-plus fa fa-add",events:{onClick:this.$createEntry}}).inject(this.$Buttons),this.$Elm},$onImport:function(){this.$Input=this.getElm();var t=this.$Input.nodeName;("INPUT"==t||"TEXTAREA"==t||"SELECT"==t)&&(this.$Input.type="hidden"),this.create().wraps(this.$Input);var e=this.$Input.value;if(""!==e){if(e=JSON.decode(e),"array"!==typeOf(e))return;var n,i,s,r;for(n=0,s=e.length;s>n;n++){r=this.$createEntry();for(i in e[n])e[n].hasOwnProperty(i)&&r.getElements('[name="'+i+'"]').set("value",e[n][i])}}},getData:function(){var t,e,n,i,s,r,o=[],l=this.$Container.getElements(".qui-controls-formlist-entry");for(e=0,n=l.length;n>e;e++){for(s=l[e].getElements("input,select,textarea"),r={},t=0,i=s.length;i>t;t++)r[s[t].name]=s[t].value;o.push(r)}return o},$refreshDate:function(){this.$Input&&(this.$Input.value=JSON.encode(this.getData()))},$createEntry:function(){var t=new Element("div",{"class":"qui-controls-formlist-entry",html:this.getAttribute("entry")}).inject(this.$Container);return t.getElements("input,select,textarea").addEvents({blur:this.$refreshDate,change:this.$refreshDate}),t}})});
//# sourceMappingURL=FormList.js.map