MWF.require("MWF.widget.Common",null,false);MWF.require("MWF.widget.JsonTemplate",null,false);MWF.xApplication.query.StatDesigner.Property=MWF.FVProperty=new Class({Extends:MWF.widget.Common,Implements:[Options,Events],options:{style:"default",path:"/x_component_query_FormDesigner/property/property.html"},initialize:function(module,propertyNode,designer,options){this.setOptions(options);this.module=module;this.view=module.view;this.data=module.json;this.htmlPath=this.options.path;this.designer=designer;this.propertyNode=propertyNode},load:function(){if(this.fireEvent("queryLoad")){MWF.getRequestText(this.htmlPath,function(responseText,responseXML){this.htmlString=responseText;this.fireEvent("postLoad")}.bind(this))}this.propertyNode.addEvent("keydown",function(e){e.stopPropagation()})},editProperty:function(td){},getHtmlString:function(callback){if(!this.htmlString){MWF.getRequestText(this.htmlPath,function(responseText,responseXML){this.htmlString=responseText;if(callback)callback()}.bind(this))}else{if(callback)callback()}},show:function(){if(!this.propertyContent){this.getHtmlString(function(){if(this.htmlString){this.JsonTemplate=new MWF.widget.JsonTemplate(this.data,this.htmlString);this.propertyContent=new Element("div",{styles:{overflow:"hidden"}}).inject(this.propertyNode);this.propertyContent.set("html",this.JsonTemplate.load());this.setEditNodeEvent();this.setEditNodeStyles(this.propertyContent);this.loadPropertyTab();this.loadPersonInput();this.loadPersonSelectInput();this.loadViewSelect();this.loadStatColumnSelect();this.loadArrayList();this.loadScriptArea();this.loadJSONArea();this.module.changeViewSelected()}}.bind(this))}else{this.propertyContent.setStyle("display","block")}},hide:function(){if(this.propertyContent)this.propertyContent.setStyle("display","none")},loadJSONArea:function(){var jsonNode=this.propertyContent.getElement(".MWFJSONArea");if(jsonNode){this.propertyTab.pages.each(function(page){if(page.contentNode==jsonNode.parentElement){page.setOptions({onShow:function(){jsonNode.empty();MWF.require("MWF.widget.JsonParse",function(){this.json=new MWF.widget.JsonParse(this.module.json,jsonNode,null);this.json.load()}.bind(this))}.bind(this)})}}.bind(this))}},loadPropertyTab:function(){var tabNodes=this.propertyContent.getElements(".MWFTab");if(tabNodes.length){var tmpNode=this.propertyContent.getFirst();var tabAreaNode=new Element("div",{styles:this.view.css.propertyTabNode}).inject(tmpNode,"before");MWF.require("MWF.widget.Tab",function(){var tab=new MWF.widget.Tab(tabAreaNode,{style:"formPropertyList"});tab.load();var tabPages=[];tabNodes.each(function(node){var page=tab.addTab(node,node.get("title"),false);tabPages.push(page);this.setScrollBar(page.contentNodeArea,"small",null,null)}.bind(this));tabPages[0].showTab();this.propertyTab=tab;this.designer.resizeNode()}.bind(this),false)}},setEditNodeEvent:function(){var property=this;var inputs=this.propertyContent.getElements("input");inputs.each(function(input){var jsondata=input.get("name");if(jsondata&&jsondata.substr(0,1)!="_"){if(this.module){var id=this.module.json.id;input.set("name",id+jsondata)}if(jsondata){var inputType=input.get("type").toLowerCase();switch(inputType){case"radio":input.addEvent("change",function(e){property.setRadioValue(jsondata,this)});input.addEvent("keydown",function(e){e.stopPropagation()});property.setRadioValue(jsondata,input);break;case"checkbox":input.addEvent("change",function(e){property.setCheckboxValue(jsondata,this)});input.addEvent("click",function(e){property.setCheckboxValue(jsondata,this)});input.addEvent("keydown",function(e){e.stopPropagation()});break;default:input.addEvent("change",function(e){property.setValue(jsondata,this.value,this)});input.addEvent("blur",function(e){property.setValue(jsondata,this.value,this)});input.addEvent("keydown",function(e){if(e.code==13){property.setValue(jsondata,this.value,this)}e.stopPropagation()});if(input.hasClass("editTableInputDate")){this.loadCalendar(input)}}}}}.bind(this));var selects=this.propertyContent.getElements("select");selects.each(function(select){var jsondata=select.get("name");if(jsondata){select.addEvent("change",function(e){property.setSelectValue(jsondata,this)})}});var textareas=this.propertyContent.getElements("textarea");textareas.each(function(input){var jsondata=input.get("name");if(jsondata){input.addEvent("change",function(e){property.setValue(jsondata,this.value)});input.addEvent("blur",function(e){property.setValue(jsondata,this.value)});input.addEvent("keydown",function(e){e.stopPropagation()})}}.bind(this))},loadCalendar:function(node){MWF.require("MWF.widget.Calendar",function(){this.calendar=new MWF.widget.Calendar(node,{style:"xform",isTime:false,target:this.module.designer.content,format:"%Y-%m-%d",onComplate:function(){}.bind(this)})}.bind(this))},changeStyle:function(name){this.module.setPropertiesOrStyles(name)},changeData:function(name,input,oldValue){this.module._setEditStyle(name,input,oldValue)},changeJsonDate:function(key,value){if(typeOf(key)!="array")key=[key];var o=this.data;var len=key.length-1;key.each(function(n,i){if(!o[n])o[n]={};if(i