| 1 |
- MWF.APPDD=MWF.xApplication.process.DictionaryDesigner;MWF.APPDD.options={multitask:true,executable:false};MWF.xDesktop.requireApp("process.DictionaryDesigner","Dictionary",null,false);MWF.xApplication.process.DictionaryDesigner.Main=new Class({Extends:MWF.xApplication.Common.Main,Implements:[Options,Events],options:{style:"default",name:"process.DictionaryDesigner",icon:"icon.png",title:MWF.APPDD.LP.title,appTitle:MWF.APPDD.LP.title,id:"",width:"1200",height:"600",actions:null,category:null,processData:null},onQueryLoad:function(){this.shortcut=true;if(this.status){this.options.application=this.status.applicationId;this.application=this.status.application||this.status.applicationId;this.options.id=this.status.id;this.setOptions(this.status.options)}if(!this.options.id){this.options.desktopReload=false;this.options.title=this.options.title+"-"+MWF.APPDD.LP.newDictionary}if(!this.actions){this.actions=MWF.Actions.get("x_processplatform_assemble_designer");debugger;this.actions.application=this.application}this.lp=MWF.xApplication.process.DictionaryDesigner.LP;this.addEvent("queryClose",function(t){if(this.explorer){this.explorer.reload()}}.bind(this))},loadApplication:function(t){this.createNode();if(!this.options.isRefresh){this.maxSize(function(){this.openForm()}.bind(this))}else{this.openForm()}if(!this.options.readMode)this.addKeyboardEvents();if(t)t()},addKeyboardEvents:function(){this.addEvent("copy",function(){this.copyModule()}.bind(this));this.addEvent("paste",function(){this.pasteModule()}.bind(this));this.addEvent("cut",function(){this.cutModule()}.bind(this));this.addEvent("keySave",function(t){this.keySave(t)}.bind(this));this.addEvent("keyDelete",function(t){this.keyDelete(t)}.bind(this))},keySave:function(t){if(this.shortcut){if(this.tab.showPage){var i=this.tab.showPage.dictionary;if(i){i.save();t.preventDefault()}}}},keyDelete:function(){if(this.shortcut){if(this.tab.showPage){var t=this.tab.showPage.dictionary;if(t){if(t.currentSelectedItem){var i=t.currentSelectedItem;i.delItem(i.itemTextNode)}}}}},copyModule:function(){if(this.shortcut){if(this.tab.showPage){var t=this.tab.showPage.dictionary;if(t){if(t.currentSelectedItem){var i=t.currentSelectedItem;MWF.clipboard.data={type:"dictionary",data:{key:i.key,value:typeOf(i.value)=="object"?Object.clone(i.value):i.value}}}}}}},cutModule:function(){if(this.shortcut){if(this.tab.showPage){var t=this.tab.showPage.dictionary;if(t){if(t.currentSelectedItem){this.copyModule();var i=t.currentSelectedItem;i.destroy()}}}}},pasteModule:function(){if(this.shortcut){if(MWF.clipboard.data){if(MWF.clipboard.data.type=="dictionary"){if(this.tab.showPage){var t=this.tab.showPage.dictionary;if(t){if(t.currentSelectedItem){var i=t.currentSelectedItem;var e=MWF.clipboard.data.data.key;var o=typeOf(MWF.clipboard.data.data.value)=="object"?Object.clone(MWF.clipboard.data.data.value):MWF.clipboard.data.data.value;var s=i.level;var n=i;var a=null;if(!i.parent){s=1}else{if(i.type!="array"&&i.type!="object"){n=i.parent;a=i}else{if(i.exp){s=i.level+1}else{n=i.parent;a=i}}}var r=n.children.length;if(i.type=="array"){if(a){e=a.key;n.value.splice(a.key,0,o);for(var d=a.key;d<n.children.length;d++){subItem=n.children[d];subItem.key=subItem.key+1;subItem.setNodeText()}}else{var e=n.value.length;n.value.push(o)}r=e}else{var h=e;var d=0;while(n.value[e]!=undefined){d++;e=h+d}n.value[e]=o;if(a)var r=n.children.indexOf(a)}var i=new MWF.xApplication.process.DictionaryDesigner.Dictionary.item(e,o,n,s,this.dictionary,true,a);if(r)n.children[r-1].nextSibling=i;n.children.splice(r,0,i)}}}}}}},createNode:function(){this.content.setStyle("overflow","hidden");this.node=new Element("div",{styles:{width:"100%",height:"100%",overflow:"hidden"}}).inject(this.content)},getApplication:function(t){if(!this.application){this.actions.getApplication(this.options.application,function(i){this.application={name:i.data.name,id:i.data.id};if(t)t()}.bind(this))}else{if(t)t()}},openForm:function(){this.getApplication(function(){this.initOptions();this.loadNodes();this.loadDictionaryListNodes();this.loadContentNode();this.loadProperty();this.resizeNode();this.addEvent("resize",this.resizeNode.bind(this));this.loadDictionary();if(this.toolbarContentNode){this.setScrollBar(this.toolbarContentNode,null,{V:{x:0,y:0},H:{x:0,y:0}});this.setScrollBar(this.propertyDomArea,null,{V:{x:0,y:0},H:{x:0,y:0}})}}.bind(this))},initOptions:function(){},loadNodes:function(){this.dictionaryListNode=new Element("div",{styles:this.css.dictionaryListNode}).inject(this.node);this.propertyNode=new Element("div",{styles:this.css.propertyNode}).inject(this.node);this.contentNode=new Element("div",{styles:this.css.contentNode}).inject(this.node)},loadDictionaryListNodes:function(){this.dictionaryListTitleNode=new Element("div",{styles:this.css.dictionaryListTitleNode,text:MWF.APPDD.LP.dictionary}).inject(this.dictionaryListNode);this.dictionaryListResizeNode=new Element("div",{styles:this.css.dictionaryListResizeNode}).inject(this.dictionaryListNode);this.dictionaryListAreaSccrollNode=new Element("div",{styles:this.css.dictionaryListAreaSccrollNode}).inject(this.dictionaryListNode);this.dictionaryListAreaNode=new Element("div",{styles:this.css.dictionaryListAreaNode}).inject(this.dictionaryListAreaSccrollNode);this.loadDictionaryListResize();this.loadDictionaryList()},loadDictionaryListResize:function(){this.dictionaryListResize=new Drag(this.dictionaryListResizeNode,{snap:1,onStart:function(t,i){var e=Browser.name=="firefox"?i.event.clientX:i.event.x;var o=Browser.name=="firefox"?i.event.clientY:i.event.y;t.store("position",{x:e,y:o});var s=this.dictionaryListAreaSccrollNode.getSize();t.store("initialWidth",s.x)}.bind(this),onDrag:function(t,i){var e=Browser.name=="firefox"?i.event.clientX:i.event.x;var o=this.content.getSize();var s=t.retrieve("position");var n=t.retrieve("initialWidth").toFloat();var a=e.toFloat()-s.x.toFloat();var r=n+a;if(r>o.x/2)r=o.x/2;if(r<40)r=40;this.contentNode.setStyle("margin-left",r+1);this.dictionaryListNode.setStyle("width",r)}.bind(this)})},loadDictionaryList:function(){this.actions.listDictionary(this.application.id||this.application,function(t){t.data.each(function(t){this.createListDictionaryItem(t)}.bind(this))}.bind(this),null,false)},createListDictionaryItem:function(t,i){var e=this;var o=new Element("div",{styles:this.css.listDictionaryItem}).inject(this.dictionaryListAreaNode,i?"top":"bottom");var s=new Element("div",{styles:this.css.listDictionaryItemIcon}).inject(o);var n=new Element("div",{styles:this.css.listDictionaryItemText,text:t.name?t.name+" ("+t.alias+")":this.lp.newDictionary}).inject(o);o.store("dictionary",t);o.addEvents({dblclick:function(t){e.loadDictionaryByData(this,t)},mouseover:function(){if(e.currentListDictionaryItem!=this)this.setStyles(e.css.listDictionaryItem_over)},mouseout:function(){if(e.currentListDictionaryItem!=this)this.setStyles(e.css.listDictionaryItem)}})},loadDictionaryByData:function(t,i){var e=t.retrieve("dictionary");var o=true;for(var s=0;s<this.tab.pages.length;s++){if(e.id==this.tab.pages[s].dictionary.data.id){this.tab.pages[s].showTabIm();o=false;break}}if(o){this.loadDictionaryData(e.id,function(t){var i=new MWF.xApplication.process.DictionaryDesigner.Dictionary(this,t);i.load()}.bind(this),true)}},loadContentNode:function(){this.contentToolbarNode=new Element("div#contentToolbarNode",{styles:this.css.contentToolbarNode}).inject(this.contentNode);if(!this.options.readMode)this.loadContentToolbar();this.editContentNode=new Element("div",{styles:this.css.editContentNode}).inject(this.contentNode);this.loadEditContent(function(){if(this.designNode)this.designNode.setStyles(this.css.designNode)}.bind(this))},loadContentToolbar:function(t){this.getFormToolbarHTML(function(i){var e=i.getElements("span");e.each(function(t,i){var e=t.get("MWFButtonImage");if(e){t.set("MWFButtonImage",this.path+""+this.options.style+"/toolbar/"+e)}}.bind(this));$(i).inject(this.contentToolbarNode);MWF.require("MWF.widget.Toolbar",function(){this.toolbar=new MWF.widget.Toolbar(i,{style:"ProcessCategory"},this);this.toolbar.load();if(t)t()}.bind(this))}.bind(this))},getFormToolbarHTML:function(t){var i=this.path+this.options.style+"/toolbars.html";var e=new Request.HTML({url:i,method:"get",onSuccess:function(i,e,o,s){var n=i[0];if(t)t(n)}.bind(this),onFailure:function(t){this.notice("request processToolbars error: "+t.responseText,"error")}.bind(this)});e.send()},maxOrReturnEditor:function(){if(!this.isMax){this.designNode.inject(this.node);this.designNode.setStyles({position:"absolute",width:"100%",height:"100%",top:"0px",margin:"0px",left:"0px"});this.tab.pages.each(function(t){t.dictionary.setAreaNodeSize()});this.isMax=true}else{this.isMax=false;this.designNode.inject(this.editContentNode);this.designNode.setStyles(this.css.designNode);this.designNode.setStyles({position:"static"});this.resizeNode();this.tab.pages.each(function(t){t.dictionary.setAreaNodeSize()})}},loadEditContent:function(t){this.designNode=new Element("div",{styles:this.css.designNode}).inject(this.editContentNode);MWF.require("MWF.widget.Tab",function(){this.tab=new MWF.widget.Tab(this.designNode,{style:"dictionary"});this.tab.load()}.bind(this),false)},loadProperty:function(){this.propertyTitleNode=new Element("div",{styles:this.css.propertyTitleNode,text:MWF.APPDD.LP.property}).inject(this.propertyNode);this.propertyResizeBar=new Element("div",{styles:this.css.propertyResizeBar}).inject(this.propertyNode);this.loadPropertyResize();this.propertyContentNode=new Element("div",{styles:this.css.propertyContentNode}).inject(this.propertyNode);this.propertyDomArea=new Element("div",{styles:this.css.propertyDomArea}).inject(this.propertyContentNode);this.propertyDomPercent=.3;this.propertyContentResizeNode=new Element("div",{styles:this.css.propertyContentResizeNode}).inject(this.propertyContentNode);this.propertyContentArea=new Element("div",{styles:this.css.propertyContentArea}).inject(this.propertyContentNode);this.loadPropertyContentResize();this.setPropertyContent();this.propertyNode.addEvent("keydown",function(t){t.stopPropagation()})},setPropertyContent:function(){this.dictionaryPropertyNode=new Element("div",{styles:this.css.dictionaryPropertyNode});this.jsonDomNode=new Element("div",{styles:this.css.jsonDomNode});this.jsonTextNode=new Element("div",{styles:this.css.jsonTextNode});this.jsonTextAreaNode=new Element("textarea",{styles:this.css.jsonTextAreaNode}).inject(this.jsonTextNode);MWF.require("MWF.widget.Tab",function(){var t=new MWF.widget.Tab(this.propertyContentArea,{style:"moduleList"});t.load();t.addTab(this.dictionaryPropertyNode,this.lp.property,false);t.addTab(this.jsonDomNode,"JSON",false);t.addTab(this.jsonTextNode,"TEXT",false);t.pages[0].showTab()}.bind(this));var t=new Element("div",{styles:this.css.propertyTitleNode,text:this.lp.id+":"}).inject(this.dictionaryPropertyNode);this.propertyIdNode=new Element("div",{styles:this.css.propertyTextNode}).inject(this.dictionaryPropertyNode);t=new Element("div",{styles:this.css.propertyTitleNode,text:this.lp.name+":"}).inject(this.dictionaryPropertyNode);this.propertyNameNode=new Element("input",{styles:this.css.propertyInputNode}).inject(this.dictionaryPropertyNode);if(this.options.noModifyName||this.options.readMode){this.propertyNameNode.set("readonly",true);this.propertyNameNode.addEvent("keydown",function(){this.notice(this.lp.notice.noModifyName,"error")}.bind(this))}t=new Element("div",{styles:this.css.propertyTitleNode,text:this.lp.alias+":"}).inject(this.dictionaryPropertyNode);this.propertyAliasNode=new Element("input",{styles:this.css.propertyInputNode}).inject(this.dictionaryPropertyNode);if(this.options.noModifyName||this.options.readMode){this.propertyAliasNode.set("readonly",true);this.propertyAliasNode.addEvent("keydown",function(){this.notice(this.lp.notice.noModifyName,"error")}.bind(this))}t=new Element("div",{styles:this.css.propertyTitleNode,text:this.lp.description+":"}).inject(this.dictionaryPropertyNode);this.propertyDescriptionNode=new Element("textarea",{styles:this.css.propertyInputAreaNode}).inject(this.dictionaryPropertyNode);if(this.options.noModifyName||this.options.readMode){this.propertyDescriptionNode.set("readonly",true)}},loadPropertyResize:function(){this.propertyResize=new Drag(this.propertyResizeBar,{snap:1,onStart:function(t,i){var e=Browser.name=="firefox"?i.event.clientX:i.event.x;var o=Browser.name=="firefox"?i.event.clientY:i.event.y;t.store("position",{x:e,y:o});var s=this.propertyNode.getSize();t.store("initialWidth",s.x)}.bind(this),onDrag:function(t,i){var e=Browser.name=="firefox"?i.event.clientX:i.event.x;var o=this.content.getSize();var s=t.retrieve("position");var n=t.retrieve("initialWidth").toFloat();var a=s.x.toFloat()-e.toFloat();var r=n+a;if(r>o.x/2)r=o.x/2;if(r<40)r=40;this.contentNode.setStyle("margin-right",r+1);this.propertyNode.setStyle("width",r)}.bind(this)})},loadPropertyContentResize:function(){this.propertyContentResize=new Drag(this.propertyContentResizeNode,{snap:1,onStart:function(t,i){var e=Browser.name=="firefox"?i.event.clientX:i.event.x;var o=Browser.name=="firefox"?i.event.clientY:i.event.y;t.store("position",{x:e,y:o});var s=this.propertyDomArea.getSize();t.store("initialHeight",s.y)}.bind(this),onDrag:function(t,i){var e=this.propertyContentNode.getSize();var o=Browser.name=="firefox"?i.event.clientY:i.event.y;var s=t.retrieve("position");var n=o.toFloat()-s.y.toFloat();var a=t.retrieve("initialHeight").toFloat();var r=a+n;if(r<40)r=40;if(r>e.y-40)r=e.y-40;this.propertyDomPercent=r/e.y;this.setPropertyContentResize()}.bind(this)})},setPropertyContentResize:function(){var t=this.propertyContentNode.getSize();var i=this.propertyContentResizeNode.getSize();var e=t.y-i.y;var o=this.propertyDomPercent*e;var s=e-o;this.propertyDomArea.setStyle("height",""+o+"px");this.propertyContentArea.setStyle("height",""+s+"px");if(this.form){if(this.form.currentSelectedModule){if(this.form.currentSelectedModule.property){var n=this.form.currentSelectedModule.property.propertyTab;if(n){var a=n.tabNodeContainer.getSize();n.pages.each(function(t){var i=t.contentNodeArea.getStyle("margin-top").toFloat();var e=t.contentNodeArea.getStyle("margin-bottom").toFloat();var o=s-i-e-a.y.toFloat()-15;t.contentNodeArea.setStyle("height",o)}.bind(this))}}}}},resizeNode:function(){var t=this.node.getSize();this.contentNode.setStyle("height",""+t.y+"px");this.propertyNode.setStyle("height",""+t.y+"px");var i=this.contentToolbarNode.getStyle("margin-top").toFloat();var e=this.contentToolbarNode.getStyle("margin-bottom").toFloat();var o=this.contentToolbarNode.getComputedSize();var s=t.y-o.totalHeight-i-e;this.editContentNode.setStyle("height",""+s+"px");if(this.designNode){var n=this.designNode.getStyle("margin-top").toFloat();var a=this.designNode.getStyle("margin-bottom").toFloat();s=t.y-o.totalHeight-i-e-n-a;this.designNode.setStyle("height",""+s+"px")}titleSize=this.propertyTitleNode.getSize();titleMarginTop=this.propertyTitleNode.getStyle("margin-top").toFloat();titleMarginBottom=this.propertyTitleNode.getStyle("margin-bottom").toFloat();titlePaddingTop=this.propertyTitleNode.getStyle("padding-top").toFloat();titlePaddingBottom=this.propertyTitleNode.getStyle("padding-bottom").toFloat();s=titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom;s=t.y-s;this.propertyContentNode.setStyle("height",""+s+"px");this.propertyResizeBar.setStyle("height",""+s+"px");this.setPropertyContentResize();titleSize=this.dictionaryListTitleNode.getSize();titleMarginTop=this.dictionaryListTitleNode.getStyle("margin-top").toFloat();titleMarginBottom=this.dictionaryListTitleNode.getStyle("margin-bottom").toFloat();titlePaddingTop=this.dictionaryListTitleNode.getStyle("padding-top").toFloat();titlePaddingBottom=this.dictionaryListTitleNode.getStyle("padding-bottom").toFloat();nodeMarginTop=this.dictionaryListAreaSccrollNode.getStyle("margin-top").toFloat();nodeMarginBottom=this.dictionaryListAreaSccrollNode.getStyle("margin-bottom").toFloat();s=titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom+nodeMarginTop+nodeMarginBottom;s=t.y-s;this.dictionaryListAreaSccrollNode.setStyle("height",""+s+"px");this.dictionaryListResizeNode.setStyle("height",""+s+"px")},loadDictionary:function(){debugger;this.getDictionaryData(this.options.id,function(t){this.setTitle(this.options.appTitle+"-"+t.name);this.taskitem.setText(this.options.appTitle+"-"+t.name);this.options.appTitle=this.options.appTitle+"-"+t.name;if(this.options.readMode){this.dictionary=new MWF.xApplication.process.DictionaryDesigner.DictionaryReader(this,t)}else{this.dictionary=new MWF.xApplication.process.DictionaryDesigner.Dictionary(this,t)}this.dictionary.load();if(this.status){if(this.status.openDictionarys){this.status.openDictionarys.each(function(t){this.loadDictionaryData(t,function(t){var i=true;if(this.status.currentId){if(this.status.currentId!=t.id)i=false}if(this.options.readMode){var e=new MWF.xApplication.process.DictionaryDesigner.DictionaryReader(this,t,{showTab:i})}else{var e=new MWF.xApplication.process.DictionaryDesigner.Dictionary(this,t,{showTab:i})}e.load()}.bind(this),true)}.bind(this))}}}.bind(this))},getDictionaryData:function(t,i){if(!this.options.id){this.loadNewDictionaryData(i)}else{this.loadDictionaryData(t,i)}},loadNewDictionaryData:function(t){var i={name:"",id:"",application:this.application.id,alias:"",description:"",data:{}};this.createListDictionaryItem(i,true);if(t)t(i)},loadDictionaryData:function(t,i){debugger;this.actions.getDictionary(t,function(t){if(t){var e=t.data;if(!this.application){this.actions.getApplication(e.application,function(t){this.application={name:t.data.name,id:t.data.id};if(i)i(e)}.bind(this))}else{if(i)i(e)}}}.bind(this))},saveDictionary:function(){if(this.tab.showPage){var t=this.tab.showPage.dictionary;t.save(function(){if(t==this.dictionary){var i=t.data.name;this.setTitle(MWF.APPDD.LP.title+"-"+i);this.options.desktopReload=true;this.options.id=t.data.id}}.bind(this))}},saveDictionaryAs:function(){this.dictionary.saveAs()},dictionaryExplode:function(){this.dictionary.explode()},dictionaryImplode:function(){this.dictionary.implode()},dictionarySearch:function(){this.dictionary.loadSearch()},recordStatus:function(){if(this.tab){var t=[];this.tab.pages.each(function(i){if(i.dictionary.data.id!=this.options.id)t.push(i.dictionary.data.id)}.bind(this));var i=this.tab.showPage.dictionary.data.id;var e={id:this.options.id,application:this.application,applicationId:this.application.id||this.application,openDictionarys:t,currentId:i,options:{action:this.options.action,noCreate:this.options.noCreate,noDelete:this.options.noDelete,noModifyName:this.options.noModifyName,readMode:this.options.readMode}};return e}return{id:this.options.id,application:this.application}}});
|