Main.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. //MWF.xDesktop.requireApp("Organization", "Selector.package", null, false);
  2. MWF.xApplication.Org.Main = new Class({
  3. Extends: MWF.xApplication.Common.Main,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "name": "Org",
  8. "icon": "icon.png",
  9. "width": (layout.desktop.size) ? layout.desktop.size.x*0.7 : 1000,
  10. "height": (layout.desktop.size) ? layout.desktop.size.y*0.7: 700,
  11. "title": MWF.xApplication.Org.LP.title
  12. },
  13. onQueryLoad: function(){
  14. this.lp = MWF.xApplication.Org.LP;
  15. this.restActions = MWF.Actions.get("x_organization_assemble_control");
  16. },
  17. loadApplication: function(callback){
  18. this.createNode();
  19. this.loadApplicationContent();
  20. if (callback) callback();
  21. },
  22. createNode: function(){
  23. this.content.setStyle("overflow", "hidden");
  24. this.node = new Element("div", {
  25. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  26. }).inject(this.content);
  27. },
  28. loadApplicationContent: function(){
  29. this.loadStartMenu();
  30. // this.loadApplicationLayout();
  31. },
  32. loadStartMenu: function(){
  33. this.startMenuNode = new Element("div", {
  34. "styles": this.css.startMenuNode
  35. }).inject(this.node);
  36. this.menu = new MWF.xApplication.Org.Menu(this, this.startMenuNode, {
  37. "onPostLoad": function(){
  38. if (this.status){
  39. if (this.status.navi!==null){
  40. this.menu.doAction(this.menu.startNavis[this.status.navi]);
  41. }
  42. }
  43. }.bind(this)
  44. });
  45. this.addEvent("resize", function(){
  46. if (this.menu) this.menu.onResize();
  47. }.bind(this));
  48. },
  49. clearContent: function(){
  50. if (this.orgConfiguratorContentNode){
  51. if (this.orgConfigurator){
  52. this.orgConfigurator.destroy();
  53. this.orgConfigurator = null;
  54. }
  55. this.orgConfiguratorContentNode.destroy();
  56. this.orgConfiguratorContentNode = null;
  57. }
  58. if (this.identityConfiguratorContentNode){
  59. if (this.identityConfigurator) delete this.identityConfigurator;
  60. this.identityConfiguratorContentNode.destroy();
  61. }
  62. if (this.groupConfiguratorContentNode){
  63. if (this.groupConfigurator){
  64. this.groupConfigurator.destroy();
  65. this.groupConfigurator = null;
  66. }
  67. this.groupConfiguratorContentNode.destroy();
  68. }
  69. if (this.roleConfiguratorContentNode){
  70. if (this.roleConfigurator){
  71. this.roleConfigurator.destroy();
  72. this.roleConfigurator = null;
  73. }
  74. this.roleConfiguratorContentNode.destroy();
  75. }
  76. if (this.personConfiguratorContentNode){
  77. if (this.personConfigurator){
  78. this.personConfigurator.destroy();
  79. this.personConfigurator = null;
  80. }
  81. this.personConfiguratorContentNode.destroy();
  82. }
  83. if (this.pingyinArea) this.pingyinArea.empty();
  84. },
  85. orgConfig: function(){
  86. this.clearContent();
  87. this.orgConfiguratorContentNode = new Element("div", {
  88. "styles": this.css.rightContentNode
  89. }).inject(this.node);
  90. this.loadOrgConfig();
  91. },
  92. loadOrgConfig: function(){
  93. MWF.xDesktop.requireApp("Org", "UnitExplorer", function(){
  94. //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
  95. // if (!this.restActions) this.restActions = new MWF.xApplication.Org.Actions.RestActions();
  96. this.orgConfigurator = new MWF.xApplication.Org.UnitExplorer(this.orgConfiguratorContentNode, this.restActions);
  97. this.orgConfigurator.app = this;
  98. this.orgConfigurator.load();
  99. //}.bind(this));
  100. }.bind(this));
  101. },
  102. groupConfig: function(){
  103. this.clearContent();
  104. this.groupConfiguratorContentNode = new Element("div", {
  105. "styles": this.css.rightContentNode
  106. }).inject(this.node);
  107. this.loadGroupConfig();
  108. },
  109. loadGroupConfig: function(){
  110. MWF.xDesktop.requireApp("Org", "GroupExplorer", function(){
  111. //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
  112. // if (!this.restActions) this.restActions = new MWF.xApplication.Org.Actions.RestActions();
  113. this.groupConfigurator = new MWF.xApplication.Org.GroupExplorer(this.groupConfiguratorContentNode, this.restActions);
  114. this.groupConfigurator.app = this;
  115. this.groupConfigurator.load();
  116. //}.bind(this));
  117. }.bind(this));
  118. },
  119. roleConfig: function(){
  120. this.clearContent();
  121. this.roleConfiguratorContentNode = new Element("div", {
  122. "styles": this.css.rightContentNode
  123. }).inject(this.node);
  124. this.loadRoleConfig();
  125. },
  126. loadRoleConfig: function(){
  127. MWF.xDesktop.requireApp("Org", "RoleExplorer", function(){
  128. //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
  129. // if (!this.restActions) this.restActions = new MWF.xApplication.Org.Actions.RestActions();
  130. this.roleConfigurator = new MWF.xApplication.Org.RoleExplorer(this.roleConfiguratorContentNode, this.restActions);
  131. this.roleConfigurator.app = this;
  132. this.roleConfigurator.load();
  133. //}.bind(this));
  134. }.bind(this));
  135. },
  136. personConfig: function(){
  137. this.clearContent();
  138. this.personConfiguratorContentNode = new Element("div", {
  139. "styles": this.css.rightContentNode
  140. }).inject(this.node);
  141. this.loadPersonConfig();
  142. },
  143. loadPersonConfig: function(){
  144. MWF.xDesktop.requireApp("Org", "PersonExplorer", function(){
  145. //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
  146. // if (!this.restActions) this.restActions = new MWF.xApplication.Org.Actions.RestActions();
  147. this.personConfigurator = new MWF.xApplication.Org.PersonExplorer(this.personConfiguratorContentNode, this.restActions);
  148. this.personConfigurator.app = this;
  149. this.personConfigurator.load();
  150. debugger;
  151. //}.bind(this));
  152. }.bind(this));
  153. },
  154. recordStatus: function(){
  155. var idx = null;
  156. if (this.menu.currentNavi){
  157. idx = this.menu.startNavis.indexOf(this.menu.currentNavi);
  158. }
  159. return {"navi": idx};
  160. }
  161. });
  162. MWF.xApplication.Org.Menu = new Class({
  163. Implements: [Options, Events],
  164. initialize: function(app, node, options){
  165. this.setOptions(options);
  166. this.app = app;
  167. this.node = $(node);
  168. this.currentNavi = null;
  169. this.status = "start";
  170. this.startNavis = [];
  171. this.load();
  172. },
  173. load: function(){
  174. var menuUrl = (MWF.AC.isOrganizationManager()) ? this.app.path+"startMenu_admin.json" : this.app.path+"startMenu.json";
  175. MWF.getJSON(menuUrl, function(json){
  176. json.each(function(navi){
  177. var naviNode = new Element("div", {
  178. "styles": this.app.css.startMenuNaviNode,
  179. "title": navi.title
  180. });
  181. naviNode.store("naviData", navi);
  182. var iconNode = new Element("div", {
  183. "styles": this.app.css.startMenuIconNode
  184. }).inject(naviNode);
  185. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+"60.png)");
  186. var textNode = new Element("div", {
  187. "styles": this.app.css.startMenuTextNode,
  188. "text": navi.title
  189. });
  190. textNode.inject(naviNode);
  191. naviNode.inject(this.node);
  192. this.startNavis.push(naviNode);
  193. this.setStartNaviEvent(naviNode, navi);
  194. this.setNodeCenter(this.node);
  195. }.bind(this));
  196. this.setStartMenuWidth();
  197. this.fireEvent("postLoad");
  198. }.bind(this));
  199. },
  200. setStartNaviEvent: function(naviNode){
  201. var _self = this;
  202. naviNode.addEvents({
  203. "mouseover": function(){
  204. //debugger;
  205. if (_self.currentNavi!==this){
  206. var iconNode = this.getFirst();
  207. this.setStyles(_self.app.css.startMenuNaviNode_over);
  208. var navi = this.retrieve("naviData");
  209. iconNode.setStyle("background-image", "url("+_self.app.path+_self.app.options.style+"/icon/"+navi.icon+".png)");
  210. iconNode.setStyles(_self.app.css.startMenuIconNode_over);
  211. }
  212. },
  213. "mouseout": function(){
  214. var iconNode = this.getFirst();
  215. if (_self.currentNavi!==this) this.setStyles(_self.app.css.startMenuNaviNode);
  216. var navi = this.retrieve("naviData");
  217. iconNode.setStyle("background-image", "url("+_self.app.path+_self.app.options.style+"/icon/"+navi.icon+"60.png)");
  218. iconNode.setStyles(_self.app.css.startMenuIconNode);
  219. },
  220. "mousedown": function(){
  221. if (_self.currentNavi!==this) this.setStyles(_self.app.css.startMenuNaviNode_down);
  222. },
  223. "mouseup": function(){if (_self.currentNavi!==this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  224. "click": function(){
  225. _self.doAction.apply(_self, [this]);
  226. }
  227. });
  228. },
  229. doAction: function(naviNode){
  230. var navi = naviNode.retrieve("naviData");
  231. var action = navi.action;
  232. this.startNavis.each(function(node){
  233. node.removeEvents("mouseover");
  234. node.removeEvents("mouseout");
  235. node.removeEvents("mousedown");
  236. node.removeEvents("mouseup");
  237. node.setStyles(this.app.css.startMenuNaviLeftNode);
  238. var iconNode = node.getFirst();
  239. var textNode = node.getLast();
  240. var tmpnavi = node.retrieve("naviData");
  241. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+tmpnavi.icon+"32.png)");
  242. iconNode.setStyles(this.app.css.startMenuIconLeftNode);
  243. textNode.setStyles(this.app.css.startMenuTextLeftNode);
  244. }.bind(this));
  245. naviNode.setStyles(this.app.css.startMenuNaviLeftNode_current);
  246. this.currentNavi = naviNode;
  247. if (this.status === "start"){
  248. this.toNormal();
  249. this.status = "normal";
  250. }
  251. if (this.app[action]) this.app[action].apply(this.app);
  252. },
  253. toNormal: function(){
  254. debugger;
  255. var css = this.app.css.normalStartMenuNode;
  256. if (!this.morph){
  257. this.morph = new Fx.Morph(this.node, {duration: 50, link: "chain"});
  258. }
  259. this.app.pingyinArea = new Element("div", {"styles": this.app.css.startMenuNaviLeftPingyinNode}).inject(this.node, "top");
  260. this.morph.start(css).chain(function(){
  261. this.node.setStyles(css);
  262. // MWF.require("MWF.widget.ScrollBar", function(){
  263. // new MWF.widget.ScrollBar(this.node, {
  264. // "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  265. // });
  266. // }.bind(this));
  267. }.bind(this));
  268. },
  269. setNodeCenter: function(node){
  270. var size = node.getSize();
  271. var contentSize = this.app.node.getSize();
  272. var top = contentSize.y/2 - size.y/2;
  273. var left = contentSize.x/2 - size.x/2;
  274. if (left<0) left = 0;
  275. if (top<0) top = 0;
  276. node.setStyles({"left": left, "top": top});
  277. },
  278. getStartMenuNormalSize: function(){
  279. var naviItemNode = this.node.getFirst();
  280. var size = naviItemNode.getComputedSize();
  281. var mt = naviItemNode.getStyle("margin-top").toFloat();
  282. var mb = naviItemNode.getStyle("margin-bottom").toFloat();
  283. var height = size.totalWidth+mt+mb;
  284. var ml = naviItemNode.getStyle("margin-left").toFloat();
  285. var mr = naviItemNode.getStyle("margin-right").toFloat();
  286. var width = size.totalWidth+ml+mr;
  287. return {"width": width, "height": height*this.startNavis.length};
  288. },
  289. setStartMenuWidth: function(){
  290. var naviItemNode = this.node.getFirst();
  291. var size = naviItemNode.getComputedSize();
  292. var ml = naviItemNode.getStyle("margin-left").toFloat();
  293. var mr = naviItemNode.getStyle("margin-right").toFloat();
  294. var width = size.totalWidth+ml+mr;
  295. this.node.setStyle("width", (width*this.startNavis.length)+"px");
  296. },
  297. onResize: function(){
  298. if (this.status === "start"){
  299. this.setNodeCenter(this.node);
  300. }
  301. }
  302. });