MWF.require("MWF.widget.Common",null,false);MWF.require("MWF.widget.JsonTemplate",null,false);MWF.xApplication.process.FormDesigner.Property=MWF.FCProperty=new Class({Extends:MWF.widget.Common,Implements:[Options,Events],options:{style:"default",path:"/x_component_process_FormDesigner/property/property.html"},initialize:function(module,propertyNode,designer,options){this.setOptions(options);this.module=module;this.form=module.form;this.data=module.json;this.data.pid=this.form.json.id+this.data.id;this.htmlPath=this.options.path;this.designer=designer;this.maplists={};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.loadMaplist();this.loadStylesList();this.loadDivTemplateType();this.loadPersonInput();this.loadFormFieldInput();this.loadScriptArea();this.loadHtmlEditorArea();this.loadTreeData();this.loadArrayList();this.loadEventsEditor();this.loadActionArea();this.loadHTMLArea();this.loadJSONArea();this.loadFormSelect();this.loadValidation();this.loadIconSelect();this.loadLabelFlagSelect();this.loadImageClipper();this.loadParameterEditor();this.loadContextRoot();this.loadUnitTypeSelector();this.loadSourceTestRestful();this.loadSidebarPosition();this.loadViewFilter()}}.bind(this))}else{this.propertyContent.setStyle("display","block")}new Fx.Scroll(layout.desktop.node).toTop()},hide:function(){if(this.propertyContent)this.propertyContent.setStyle("display","none")},destroy:function(){if(this.propertyContent){this.propertyContent.destroy();MWF.release(this)}},loadTreeData:function(){var arrays=this.propertyContent.getElements(".MWFTreeData");arrays.each(function(node){var title=node.get("title");var name=node.get("name");var json=this.data[name];if(!json)json=[];MWF.require("MWF.widget.TreeEditor",function(){var treeEditor=new MWF.widget.TreeEditor(node,{title:title,maxObj:this.propertyNode.parentElement.parentElement.parentElement,onChange:function(){this.data[name]=treeEditor.toJson();this.module.json[name]=this.data[name];this.module._refreshTree()}.bind(this)});treeEditor.load(json)}.bind(this));node.addEvent("keydown",function(e){e.stopPropagation()})}.bind(this))},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))}},loadHTMLArea:function(){var htmlNode=this.propertyContent.getElement(".MWFHTMLArea");if(htmlNode){var copy=this.module.node.clone(true,true);copy.clearStyles(true);htmlNode.set("text",copy.outerHTML);copy.destroy();this.propertyTab.pages.each(function(page){if(page.contentNode==htmlNode.parentElement){page.setOptions({onShow:function(){var copy=this.module.node.clone(true,true);copy.clearStyles(true);htmlNode.set("text",copy.outerHTML);copy.destroy()}.bind(this)})}}.bind(this))}},loadSidebarPosition:function(){var nodes=this.propertyContent.getElements(".MWFSidebarReposition");if(nodes.length){nodes.each(function(node){node.addEvent("click",function(){this.module.json.styles.top="";this.module.loadPosition()}.bind(this))}.bind(this))}},loadFormSelect:function(){var formNodes=this.propertyContent.getElements(".MWFFormSelect");if(formNodes.length){this.getFormList(function(){formNodes.each(function(node){var select=new Element("select").inject(node);select.addEvent("change",function(e){this.setValue(e.target.getParent("div").get("name"),e.target.options[e.target.selectedIndex].value,select)}.bind(this));this.setFormSelectOptions(node,select);var refreshNode=new Element("div",{styles:this.form.css.propertyRefreshFormNode}).inject(node);refreshNode.addEvent("click",function(e){this.getFormList(function(){this.setFormSelectOptions(node,select)}.bind(this),true)}.bind(this))}.bind(this))}.bind(this))}},setFormSelectOptions:function(node,select){var name=node.get("name");select.empty();var option=new Element("option",{text:"none"}).inject(select);this.forms.each(function(form){var option=new Element("option",{text:form.name,value:form.id,selected:this.data[name]==form.id}).inject(select)}.bind(this))},getFormList:function(callback,refresh){if(!this.forms||refresh){this.form.designer.actions.listForm(this.form.designer.application.id,function(json){this.forms=json.data;if(callback)callback()}.bind(this))}else{if(callback)callback()}},loadViewFilter:function(){var nodes=this.propertyContent.getElements(".MWFViewFilter");var filtrData=this.data.filterList;nodes.each(function(node){MWF.xDesktop.requireApp("query.ViewDesigner","widget.ViewFilter",function(){var _slef=this;new MWF.xApplication.query.ViewDesigner.widget.ViewFilter(node,this.form.designer,{filtrData:filtrData,customData:null},{onChange:function(ids){var data=this.getData();_slef.changeJsonDate(["filterList"],data.data)}})}.bind(this))}.bind(this))},loadViewSelect:function(){var viewNodes=this.propertyContent.getElements(".MWFViewSelect");if(viewNodes.length){this.getViewList(function(){viewNodes.each(function(node){var select=new Element("select").inject(node);select.addEvent("change",function(e){var viewId=e.target.options[e.target.selectedIndex].value;var viewName=e.target.options[e.target.selectedIndex].get("text");this.setValue(e.target.getParent("div").get("name"),viewId);this.setValue(e.target.getParent("div").get("name")+"Name",viewName)}.bind(this));this.setViewSelectOptions(node,select);var refreshNode=new Element("div",{styles:this.form.css.propertyRefreshFormNode}).inject(node);refreshNode.addEvent("click",function(e){this.getViewList(function(){this.setViewSelectOptions(node,select)}.bind(this),true)}.bind(this))}.bind(this))}.bind(this))}},setViewSelectOptions:function(node,select){var name=node.get("name");select.empty();var option=new Element("option",{text:"none"}).inject(select);this.views.each(function(view){var option=new Element("option",{text:view.name,value:view.id,selected:this.data[name]==view.id}).inject(select)}.bind(this))},getViewList:function(callback,refresh){if(!this.views||refresh){this.form.designer.actions.listView(this.form.designer.application.id,function(json){this.views=json.data;if(callback)callback()}.bind(this))}else{if(callback)callback()}},loadValidation:function(){var nodes=this.propertyContent.getElements(".MWFValidation");if(nodes.length){nodes.each(function(node){var name=node.get("name");MWF.xDesktop.requireApp("process.FormDesigner","widget.ValidationEditor",function(){var validationEditor=new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node,this.designer,{onChange:function(){var data=validationEditor.getValidationData();this.data[name]=data}.bind(this)});validationEditor.load(this.data[name])}.bind(this))}.bind(this))}},loadIconSelect:function(){var nodes=this.propertyContent.getElements(".MWFIcon");if(nodes.length){nodes.each(function(node){var id=node.get("name");var icon=this.data[id];var iconNode=new Element("div",{styles:this.form.css.processIconNode}).inject(node);if(icon)iconNode.setStyles({background:"url("+icon+") center center no-repeat"});var selectNode=new Element("div",{styles:this.form.css.processIconSelectNode,text:this.form.designer.lp.selectIcon}).inject(node);selectNode.addEvent("click",function(){this.selectIcon(node)}.bind(this))}.bind(this))}},selectIcon:function(node){if(!node.iconMenu){var iconSelectMenu=new MWF.widget.Menu(node,{event:"click",style:"processIcon"});iconSelectMenu.load();node.iconMenu=iconSelectMenu;var _self=this;for(var i=0;i<=48;i++){var icon="/x_component_process_ProcessManager/$Explorer/default/processIcon/process_icon_"+i+".png";var item=iconSelectMenu.addMenuItem("","click",function(){var id=node.get("name");var src=this.item.getElement("img").get("src");_self.data[id]=src;node.getFirst("div").setStyle("background-image","url("+src+")")},icon);item.iconName=icon}}},loadLabelFlagSelect:function(){var nodes=this.propertyContent.getElements(".MWFLabelFlag");if(nodes.length){nodes.each(function(node){var id=node.get("name");var icon=this.data[id];var iconNode=new Element("div",{styles:this.form.css.labelFlagNode}).inject(node);if(icon)iconNode.setStyles({background:"url("+icon+") center center no-repeat"});var selectNode=new Element("div",{styles:this.form.css.processIconSelectNode,text:this.form.designer.lp.empty}).inject(node);selectNode.addEvent("click",function(e){var id=node.get("name");this.data[id]="";node.getFirst("div").setStyle("background-image","");this.changeData(id);e.stopPropagation()}.bind(this));var selectNode=new Element("div",{styles:this.form.css.processIconSelectNode,text:this.form.designer.lp.select}).inject(node);selectNode.addEvent("click",function(){this.selectLabelFlag(node)}.bind(this))}.bind(this))}},selectLabelFlag:function(node){if(!node.iconMenu){var iconSelectMenu=new MWF.widget.Menu(node,{event:"click",style:"labelFlag"});iconSelectMenu.load();node.iconMenu=iconSelectMenu;var _self=this;for(var i=1;i<=21;i++){var icon="/x_component_process_FormDesigner/Module/Label/default/icon/flag/"+i+".png";var item=iconSelectMenu.addMenuItem("","click",function(){var id=node.get("name");var src=this.item.getElement("img").get("src");_self.data[id]=src;node.getFirst("div").setStyle("background-image","url("+src+")");_self.changeData(id)},icon);item.iconName=icon}}},loadImageClipper:function(){var nodes=this.propertyContent.getElements(".MWFImageClipper");if(nodes.length){nodes.each(function(node){var id=node.get("name");var selectNode=new Element("div",{styles:this.form.css.processIconSelectNode,text:this.form.designer.lp.selectImage}).inject(node);selectNode.addEvent("click",function(){this.selectImage(node,id)}.bind(this))}.bind(this))}},createUploadFileAreaNode:function(node,name){this.uploadFileAreaNode=new Element("div");var html='';this.uploadFileAreaNode.set("html",html);this.fileUploadNode=this.uploadFileAreaNode.getFirst();this.fileUploadNode.addEvent("change",function(){var files=this.fileUploadNode.files;if(files.length){var count=files.length;for(var i=0;i