MWF.CMSDD=MWF.xApplication.cms.DictionaryDesigner;MWF.CMSDD.options={multitask:true,executable:false};MWF.xDesktop.requireApp("cms.DictionaryDesigner","Dictionary",null,false);MWF.xApplication.cms.DictionaryDesigner.Main=new Class({Extends:MWF.xApplication.Common.Main,Implements:[Options,Events],options:{style:"default",name:"cms.DictionaryDesigner",icon:"icon.png",title:MWF.CMSDD.LP.title,appTitle:MWF.CMSDD.LP.title,id:"",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.options.id=this.status.id}if(!this.options.id){this.options.desktopReload=false;this.options.title=this.options.title+"-"+MWF.CMSDD.LP.newDictionary}this.actions=MWF.Actions.get("x_cms_assemble_control");this.lp=MWF.xApplication.cms.DictionaryDesigner.LP},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 e=this.tab.showPage.dictionary;if(e){e.save();t.preventDefault()}}}},keyDelete:function(){if(this.shortcut){if(this.tab.showPage){var t=this.tab.showPage.dictionary;if(t){if(t.currentSelectedItem){var e=t.currentSelectedItem;e.delItem(e.itemTextNode)}}}}},copyModule:function(){if(this.shortcut){if(this.tab.showPage){var t=this.tab.showPage.dictionary;if(t){if(t.currentSelectedItem){var e=t.currentSelectedItem;MWF.clipboard.data={type:"dictionary",data:{key:e.key,value:typeOf(e.value)=="object"?Object.clone(e.value):e.value}}}}}}},cutModule:function(){if(this.shortcut){if(this.tab.showPage){var t=this.tab.showPage.dictionary;if(t){if(t.currentSelectedItem){this.copyModule();var e=t.currentSelectedItem;e.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 e=t.currentSelectedItem;var i=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=e.level;var n=e;var a=null;if(!e.parent){s=1}else{if(e.type!="array"&&e.type!="object"){n=e.parent;a=e}else{if(e.exp){s=e.level+1}else{n=e.parent;a=e}}}var r=n.children.length;if(e.type=="array"){if(a){i=a.key;n.value.splice(a.key,0,o);for(var d=a.key;do.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,function(t){t.data.each(function(t){this.createListDictionaryItem(t)}.bind(this))}.bind(this),null,false)},createListDictionaryItem:function(t,e){var i=this;var o=new Element("div",{styles:this.css.listDictionaryItem}).inject(this.dictionaryListAreaNode,e?"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){i.loadDictionaryByData(this,t)},mouseover:function(){if(i.currentListDictionaryItem!=this)this.setStyles(i.css.listDictionaryItem_over)},mouseout:function(){if(i.currentListDictionaryItem!=this)this.setStyles(i.css.listDictionaryItem)}})},loadDictionaryByData:function(t,e){var i=t.retrieve("dictionary");var o=true;for(var s=0;so.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,e){var i=Browser.name=="firefox"?e.event.clientX:e.event.x;var o=Browser.name=="firefox"?e.event.clientY:e.event.y;t.store("position",{x:i,y:o});var s=this.propertyDomArea.getSize();t.store("initialHeight",s.y)}.bind(this),onDrag:function(t,e){var i=this.propertyContentNode.getSize();var o=Browser.name=="firefox"?e.event.clientY:e.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>i.y-40)r=i.y-40;this.propertyDomPercent=r/i.y;this.setPropertyContentResize()}.bind(this)})},setPropertyContentResize:function(){var t=this.propertyContentNode.getSize();var e=this.propertyContentResizeNode.getSize();var i=t.y-e.y;var o=this.propertyDomPercent*i;var s=i-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 e=t.contentNodeArea.getStyle("margin-top").toFloat();var i=t.contentNodeArea.getStyle("margin-bottom").toFloat();var o=s-e-i-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 e=this.contentToolbarNode.getStyle("margin-top").toFloat();var i=this.contentToolbarNode.getStyle("margin-bottom").toFloat();var o=this.contentToolbarNode.getComputedSize();var s=t.y-o.totalHeight-e-i;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-e-i-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(){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.cms.DictionaryDesigner.DictionaryReader(this,t)}else{this.dictionary=new MWF.xApplication.cms.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 e=true;if(this.status.currentId){if(this.status.currentId!=t.id)e=false}if(this.options.readMode){var i=new MWF.xApplication.cms.DictionaryDesigner.DictionaryReader(this,t,{showTab:e})}else{var i=new MWF.xApplication.cms.DictionaryDesigner.Dictionary(this,t,{showTab:e})}i.load()}.bind(this),true)}.bind(this))}}}.bind(this))},getDictionaryData:function(t,e){if(!this.options.id){this.loadNewDictionaryData(e)}else{this.loadDictionaryData(t,e)}},loadNewDictionaryData:function(t){var e={name:"",id:"",application:this.application.id,alias:"",description:"",data:{}};this.createListDictionaryItem(e,true);if(t)t(e)},loadDictionaryData:function(t,i){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 e=this.tab.showPage.dictionary;e.save(function(){if(e==this.dictionary){var t=e.data.name;this.setTitle(MWF.CMSDD.LP.title+"-"+t);this.options.desktopReload=true;this.options.id=e.data.id}this.fireAppEvent("postSave")}.bind(this))}},saveDictionaryAs:function(){this.dictionary.saveAs()},dictionaryExplode:function(){this.dictionary.explode()},dictionaryImplode:function(){this.dictionary.implode()},recordStatus:function(){if(this.tab){var e=[];this.tab.pages.each(function(t){if(t.dictionary.data.id!=this.options.id)e.push(t.dictionary.data.id)}.bind(this));var t=this.tab.showPage.dictionary.data.id;var i={id:this.options.id,application:this.application,openDictionarys:e,currentId:t};return i}return{id:this.options.id,application:this.application}}});