OrgExplorer_bak.min.js 4.6 KB

1
  1. MWF.require("MWF.widget.MWFRaphael",null,false);MWF.xApplication.Organization.OrgExplorer=new Class({Extends:MWF.widget.Common,Implements:[Options,Events],options:{style:"default"},initialize:function(t,e,i){this.setOptions(i);this.path="/x_component_Organization/$OrgExplorer/";this.cssPath="/x_component_Organization/$OrgExplorer/"+this.options.style+"/css.wcss";this._loadCss();this.actions=e;this.node=$(t)},load:function(){this.loadLayout();this.loadChart()},loadLayout:function(){this.propertyAreaNode=new Element("div",{styles:this.css.propertyAreaNode}).inject(this.node);this.chartAreaNode=new Element("div",{styles:this.css.chartAreaNode}).inject(this.node);this.resizeBarNode=new Element("div",{styles:this.css.resizeBarNode}).inject(this.propertyAreaNode);this.propertyNode=new Element("div",{styles:this.css.propertyNode}).inject(this.propertyAreaNode);this.propertyTitleNode=new Element("div",{styles:this.css.propertyTitleNode}).inject(this.propertyNode);this.propertyContentNode=new Element("div",{styles:this.css.propertyContentNode}).inject(this.propertyNode);this.resizePropertyContentNode();this.app.addEvent("resize",function(){this.resizePropertyContentNode()}.bind(this));this.chartNode=new Element("div",{styles:this.css.chartNode}).inject(this.chartAreaNode);this.propertyResize=new Drag(this.resizeBarNode,{snap:1,onStart:function(t,e){var i=e.event.clientX;var s=e.event.clientY;t.store("position",{x:i,y:s});var o=this.propertyAreaNode.getSize();t.store("initialWidth",o.x)}.bind(this),onDrag:function(t,e){var i=e.event.clientX;var s=this.node.getSize();var o=t.retrieve("position");var n=t.retrieve("initialWidth").toFloat();var r=o.x.toFloat()-i.toFloat();var a=n+r;if(a>s.x/1.5)a=s.x/1.5;if(a<40)a=40;this.chartAreaNode.setStyle("margin-right",a+1);this.propertyAreaNode.setStyle("width",a)}.bind(this)})},resizePropertyContentNode:function(){var t=this.node.getSize();var e=this.propertyTitleNode.getSize();var i=this.propertyTitleNode.getStyle("margin-top").toFloat();var s=this.propertyTitleNode.getStyle("margin-bottom").toFloat();var o=this.propertyContentNode.getStyle("margin-top").toFloat();var n=this.propertyContentNode.getStyle("margin-bottom").toFloat();var r=t.y-e.y-i-s-o-n;this.propertyContentNode.setStyle("height",r)},loadChart:function(){this.actions.listTopCompany(function(t){MWFRaphael.load(function(){this.paper=Raphael(this.chartNode,"100%","99%");this.paper.container=this.chartNode;this.loadChartContent(t.data,"company")}.bind(this))}.bind(this))},loadChartContent:function(t,e){var i=null;t.each(function(t){var e=new MWF.xApplication.Organization.OrgExplorer.Company(t,this);if(i)e.prevItem=i;e.load();i=e}.bind(this))}});MWF.xApplication.Organization.OrgExplorer.Item=new Class({initialize:function(t,e){this.data=t;this.explorer=e;this.paper=this.explorer.paper;this.prevItem=null;this.nextItem=null;this.parentItem=null;this.children=[];this.position={x:0,y:0,maxY:0,center:{x:0,y:0}};this.initStyles()},initStyles:function(){this.style=this.explorer.css.chart.company},load:function(){this.getItemPostion();this.shap=this.createShap();this.text=this.createText();this.icon=this.createIcon();if(!this.set)this.set=this.paper.set();this.set.push(this.shap,this.text,this.icon)},getItemPostion:function(){var t=this.style.width*(this.data.level-1)+20;var e=0;if(this.prevItem){e=this.prevItem.position.maxY+20}else if(this.parentItem){e=this.parentItem.position.y}else{e=20}this.position.x=t;this.position.y=e;this.position.maxY=e+this.style.height;this.setParentMaxY()},setParentMaxY:function(){var t=this.parentItem;if(t){if(t.position.maxY<this.position.maxY){t.position.maxY=this.position.maxY;t.setParentMaxY()}}},createShap:function(){var t;t=this.paper.rectPath(this.position.x,this.position.y,this.style.width,this.style.height,this.style.radius);t.attr(this.style.shap);t.data("bind",this);return t},createText:function(){var t=this.getTextIconPoint();text=this.paper.text(t.tatt.x,t.tatt.y,this.data.name);text.attr(this.style.text);if(this.style.text.display=="none"){text.hide()}return text},createIcon:function(){var t=this.getTextIconPoint();var e=this.paper.image(this.style.src,t.iatt.x,t.iatt.y,48,48);e.attr(this.style.icon);return e},getTextIconPoint:function(){var t={x:this.position.x,y:this.position.y+this.style.height/2};var e={x:this.position.x+6,y:this.position.y+6};return{tatt:t,iatt:e}}});MWF.xApplication.Organization.OrgExplorer.Company=new Class({Extends:MWF.xApplication.Organization.OrgExplorer.Item});MWF.xApplication.Organization.OrgExplorer.Department=new Class({Extends:MWF.xApplication.Organization.OrgExplorer.Item,initStyles:function(){this.style=this.explorer.css.chart.department}});