Main.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. MWF.xApplication.process.Application.options = {
  2. "multitask": true,
  3. "executable": false
  4. };
  5. MWF.xApplication.process.Application.Main = new Class({
  6. Extends: MWF.xApplication.Common.Main,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default",
  10. "name": "process.Application",
  11. "icon": "icon.png",
  12. "width": "1200",
  13. "height": "700",
  14. "application": "",
  15. "id": "",
  16. "title": MWF.xApplication.process.Application.LP.title
  17. },
  18. onQueryLoad: function() {
  19. this.lp = MWF.xApplication.process.Application.LP;
  20. if (this.status) this.options.id = this.status.id;
  21. },
  22. getApplication: function(success, failure){
  23. if (!this.options.application){
  24. this.getAction(function(){
  25. this.action.getApplication(this.options.id, function(json){
  26. if (json.data){
  27. this.setTitle(this.options.title+"-"+json.data.name);
  28. this.options.application = json.data;
  29. if (success) success();
  30. }else{
  31. if (failure) failure();
  32. }
  33. }.bind(this), function(){if (failure) failure();}.bind(this), false)
  34. }.bind(this));
  35. }else{
  36. if (success) success();
  37. }
  38. },
  39. getAction: function(callback){
  40. if (!this.action){
  41. this.action = MWF.Actions.get("x_processplatform_assemble_surface");
  42. if (callback) callback();
  43. // MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  44. // this.action = new MWF.xApplication.process.Application.Actions.RestActions();
  45. // if (callback) callback();
  46. // }.bind(this));
  47. }else{
  48. if (callback) callback();
  49. }
  50. },
  51. createNode: function(){
  52. this.content.setStyle("overflow", "hidden");
  53. this.node = new Element("div", {
  54. "styles": {"width": "100%", "height": "100%", "overflow": "hidden", "background-color": "#ffffff"}
  55. }).inject(this.content);
  56. },
  57. loadApplication: function(callback){
  58. debugger;
  59. this.getApplication(function(){
  60. this.createNode();
  61. this.loadStartMenu();
  62. if (callback) callback();
  63. }.bind(this), function(){
  64. this.close();
  65. }.bind(this));
  66. },
  67. loadStartMenu: function(callback){
  68. this.startMenuNode = new Element("div", {
  69. "styles": this.css.startMenuNode
  70. }).inject(this.node);
  71. this.menu = new MWF.xApplication.process.Application.Menu(this, this.startMenuNode, {
  72. "onPostLoad": function(){
  73. this.css.rightContentNode["margin-left"] = "140px";
  74. if (this.status){
  75. if (this.status.hideMenu){
  76. this.startMenuNode.setStyle("display", "none");
  77. this.css.rightContentNode["margin-left"] = "0px";
  78. }
  79. if (this.status.navi!=null){
  80. this.menu.doAction(this.menu.startNavis[this.status.navi]);
  81. }else{
  82. this.menu.doAction(this.menu.startNavis[0]);
  83. }
  84. }else{
  85. this.menu.doAction(this.menu.startNavis[0]);
  86. }
  87. }.bind(this)
  88. });
  89. this.addEvent("resize", function(){
  90. if (this.menu) this.menu.onResize();
  91. }.bind(this));
  92. },
  93. clearContent: function(){
  94. if (this.myWorkConfiguratorContentNode){
  95. if (this.myWorkConfigurator){
  96. if (this.myWorkConfigurator.setContentSizeFun) this.removeEvent("resize", this.myWorkConfigurator.setContentSizeFun);
  97. MWF.release(this.myWorkConfigurator);
  98. this.myWorkConfigurator = null;
  99. }
  100. this.myWorkConfiguratorContentNode.destroy();
  101. this.myWorkConfiguratorContentNode = null;
  102. }
  103. if (this.myCompletedConfiguratorContentNode){
  104. if (this.myCompletedConfigurator){
  105. if (this.myCompletedConfigurator.setContentSizeFun) this.removeEvent("resize", this.myCompletedConfigurator.setContentSizeFun);
  106. MWF.release(this.myCompletedConfigurator);
  107. this.myCompletedConfigurator = null;
  108. }
  109. this.myCompletedConfiguratorContentNode.destroy();
  110. this.myCompletedConfiguratorContentNode = null;
  111. }
  112. if (this.workConfiguratorContentNode){
  113. if (this.workConfigurator){
  114. if (this.workConfigurator.setContentSizeFun) this.removeEvent("resize", this.workConfigurator.setContentSizeFun);
  115. MWF.release(this.workConfigurator);
  116. this.workConfigurator = null;
  117. }
  118. this.workConfiguratorContentNode.destroy();
  119. this.workConfiguratorContentNode = null;
  120. }
  121. if (this.completedConfiguratorContentNode){
  122. if (this.completedConfigurator){
  123. if (this.completedConfigurator.setContentSizeFun) this.removeEvent("resize", this.completedConfigurator.setContentSizeFun);
  124. MWF.release(this.completedConfigurator);
  125. this.completedConfigurator = null;
  126. }
  127. this.completedConfiguratorContentNode.destroy();
  128. this.completedConfiguratorContentNode = null;
  129. }
  130. if (this.dataConfiguratorContent){
  131. if (this.dataConfigurator){
  132. if (this.dataConfigurator.setContentSizeFun) this.removeEvent("resize", this.dataConfigurator.setContentSizeFun);
  133. MWF.release(this.dataConfigurator);
  134. this.dataConfigurator = null;
  135. }
  136. this.dataConfiguratorContent.destroy();
  137. this.dataConfiguratorContent = null;
  138. }
  139. if (this.serialConfiguratorContent){
  140. if (this.serialConfigurator){
  141. if (this.serialConfigurator.setContentSizeFun) this.removeEvent("resize", this.serialConfigurator.setContentSizeFun);
  142. MWF.release(this.serialConfigurator);
  143. this.serialConfigurator = null;
  144. }
  145. this.serialConfiguratorContent.destroy();
  146. this.serialConfiguratorContent = null;
  147. }
  148. if (this.statConfiguratorContentNode){
  149. if (this.statConfigurator){
  150. if (this.statConfigurator.setContentSizeFun) this.removeEvent("resize", this.statConfigurator.setContentSizeFun);
  151. MWF.release(this.statConfigurator);
  152. this.statConfigurator = null;
  153. }
  154. this.statConfiguratorContentNode.destroy();
  155. this.statConfiguratorContentNode = null;
  156. }
  157. if (this.viewConfiguratorContentNode){
  158. if (this.viewConfigurator){
  159. if (this.viewConfigurator.setContentSizeFun) this.removeEvent("resize", this.viewConfigurator.setContentSizeFun);
  160. MWF.release(this.viewConfigurator);
  161. this.viewConfigurator = null;
  162. }
  163. this.viewConfiguratorContentNode.destroy();
  164. this.viewConfiguratorContentNode = null;
  165. }
  166. // if (this.statConfiguratorContentNode){
  167. // if (this.statConfigurator){
  168. // MWF.release(this.statConfigurator);
  169. // this.statConfigurator = null;
  170. // }
  171. // this.statConfiguratorContentNode.destroy();
  172. // this.statConfiguratorContentNode = null;
  173. // }
  174. },
  175. // statConfigTmp: function(){
  176. // this.clearContent();
  177. // this.statConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  178. // this.loadStatConfig();
  179. // },
  180. // loadStatConfigTmp: function(){
  181. // MWF.xDesktop.requireApp("process.Application", "StatExplorer", function(){
  182. // MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  183. // if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  184. // this.statConfigurator = new MWF.xApplication.process.Application.StatExplorer(this.statConfiguratorContentNode, this.restActions);
  185. // this.statConfigurator.app = this;
  186. // this.statConfigurator.load();
  187. // }.bind(this));
  188. // }.bind(this));
  189. // },
  190. statConfig: function(){
  191. this.clearContent();
  192. this.statConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  193. this.loadStatConfig();
  194. },
  195. loadStatConfig: function(){
  196. MWF.xDesktop.requireApp("process.Application", "StatExplorer", function(){
  197. //MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  198. //if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  199. if (!this.restActions) this.restActions = MWF.Actions.get("x_processplatform_assemble_surface");
  200. this.statConfigurator = new MWF.xApplication.process.Application.StatExplorer(this.statConfiguratorContentNode, this.restActions);
  201. this.statConfigurator.app = this;
  202. this.statConfigurator.load();
  203. //}.bind(this));
  204. }.bind(this));
  205. },
  206. viewConfig: function(){
  207. this.clearContent();
  208. this.viewConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  209. this.loadViewConfig();
  210. },
  211. loadViewConfig: function(){
  212. MWF.xDesktop.requireApp("process.Application", "ViewExplorer", function(){
  213. //MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  214. // if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  215. if (!this.restActions) this.restActions = MWF.Actions.get("x_processplatform_assemble_surface");
  216. this.viewConfigurator = new MWF.xApplication.process.Application.ViewExplorer(this.viewConfiguratorContentNode, this.restActions);
  217. this.viewConfigurator.app = this;
  218. this.viewConfigurator.load();
  219. //}.bind(this));
  220. }.bind(this));
  221. },
  222. myWorkConfig: function(){
  223. this.clearContent();
  224. this.myWorkConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  225. this.loadMyWorkConfig();
  226. },
  227. loadMyWorkConfig: function(){
  228. MWF.xDesktop.requireApp("process.Application", "MyWorkExplorer", function(){
  229. //MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  230. // if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  231. if (!this.restActions) this.restActions = MWF.Actions.get("x_processplatform_assemble_surface");
  232. this.myWorkConfigurator = new MWF.xApplication.process.Application.MyWorkExplorer(this.myWorkConfiguratorContentNode, this.restActions);
  233. this.myWorkConfigurator.app = this;
  234. this.myWorkConfigurator.load();
  235. //}.bind(this));
  236. }.bind(this));
  237. },
  238. myWorkCompletedConfig: function(){
  239. this.clearContent();
  240. this.myCompletedConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  241. this.loadMyWorkCompletedConfig();
  242. },
  243. loadMyWorkCompletedConfig: function(){
  244. MWF.xDesktop.requireApp("process.Application", "MyWorkCompletedExplorer", function(){
  245. //MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  246. // if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  247. if (!this.restActions) this.restActions = MWF.Actions.get("x_processplatform_assemble_surface");
  248. this.myCompletedConfigurator = new MWF.xApplication.process.Application.MyWorkCompletedExplorer(this.myCompletedConfiguratorContentNode, this.restActions);
  249. this.myCompletedConfigurator.app = this;
  250. this.myCompletedConfigurator.load();
  251. //}.bind(this));
  252. }.bind(this));
  253. },
  254. workConfig: function(){
  255. this.clearContent();
  256. this.workConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  257. this.loadWorkConfig();
  258. },
  259. loadWorkConfig: function(){
  260. MWF.xDesktop.requireApp("process.Application", "WorkExplorer", function(){
  261. //MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  262. // if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  263. if (!this.restActions) this.restActions = MWF.Actions.get("x_processplatform_assemble_surface");
  264. this.workConfigurator = new MWF.xApplication.process.Application.WorkExplorer(this.workConfiguratorContentNode, this.restActions);
  265. this.workConfigurator.app = this;
  266. this.workConfigurator.load();
  267. //}.bind(this));
  268. }.bind(this));
  269. },
  270. workCompletedConfig: function(){
  271. this.clearContent();
  272. this.completedConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  273. this.loadWorkCompletedConfig();
  274. },
  275. loadWorkCompletedConfig: function(){
  276. MWF.xDesktop.requireApp("process.Application", "WorkCompletedExplorer", function(){
  277. //MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  278. // if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  279. if (!this.restActions) this.restActions = MWF.Actions.get("x_processplatform_assemble_surface");
  280. this.completedConfigurator = new MWF.xApplication.process.Application.WorkCompletedExplorer(this.completedConfiguratorContentNode, this.restActions);
  281. this.completedConfigurator.app = this;
  282. this.completedConfigurator.load();
  283. //}.bind(this));
  284. }.bind(this));
  285. },
  286. dataConfig: function(){
  287. this.clearContent();
  288. this.dataConfiguratorContent = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  289. this.loadDataConfig();
  290. },
  291. loadDataConfig: function(){
  292. MWF.xDesktop.requireApp("process.Application", "DictionaryExplorer", function(){
  293. //MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  294. //if (!this.dictActions) this.dictActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  295. //if (!this.dictActions) this.dictActions = new MWF.xApplication.process.Application.Actions.RestActions();
  296. if (!this.dictActions) this.dictActions = MWF.Actions.get("x_processplatform_assemble_designer");
  297. this.dataConfigurator = new MWF.xApplication.process.Application.DictionaryExplorer(this.dataConfiguratorContent, this.dictActions, {
  298. "noCreate": true,
  299. "noDelete": true,
  300. "noModifyName": true,
  301. "readMode": !this.options.application.allowControl
  302. });
  303. this.dataConfigurator.app = this;
  304. this.dataConfigurator.load();
  305. //}.bind(this));
  306. }.bind(this));
  307. },
  308. serialConfig: function(){
  309. this.clearContent();
  310. this.serialConfiguratorContent = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  311. this.loadSerialConfig();
  312. },
  313. loadSerialConfig: function(){
  314. MWF.xDesktop.requireApp("process.Application", "SerialExplorer", function(){
  315. //MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  316. // if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  317. if (!this.restActions) this.restActions = MWF.Actions.get("x_processplatform_assemble_surface");
  318. this.serialConfigurator = new MWF.xApplication.process.Application.SerialExplorer(this.serialConfiguratorContent, this.restActions);
  319. this.serialConfigurator.app = this;
  320. this.serialConfigurator.load();
  321. //}.bind(this));
  322. }.bind(this));
  323. },
  324. recordStatus: function(){
  325. var idx = null;
  326. if (this.menu.currentNavi){
  327. idx = this.menu.startNavis.indexOf(this.menu.currentNavi);
  328. }
  329. return {"navi": idx, "id": this.options.id};
  330. }
  331. });
  332. MWF.xApplication.process.Application.Menu = new Class({
  333. Implements: [Options, Events],
  334. initialize: function(app, node, options){
  335. this.setOptions(options);
  336. this.app = app;
  337. this.node = $(node);
  338. this.currentNavi = null;
  339. this.status = "start";
  340. this.startNavis = [];
  341. this.load();
  342. },
  343. load: function(){
  344. var menuUrl = this.app.path+"startMenu.json";
  345. //if (MWF.AC.isAdministrator()) menuUrl = this.app.path+"startMenu_admin.json";
  346. MWF.getJSON(menuUrl, function(json){
  347. json.each(function(navi){
  348. var naviNode = new Element("div", {
  349. "styles": this.app.css.startMenuNaviNode
  350. });
  351. naviNode.store("naviData", navi);
  352. if (navi.hint) naviNode.set("title", navi.hint);
  353. var iconNode = new Element("div", {
  354. "styles": this.app.css.startMenuIconNode
  355. }).inject(naviNode);
  356. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+")");
  357. var textNode = new Element("div", {
  358. "styles": this.app.css.startMenuTextNode,
  359. "text": navi.title
  360. });
  361. textNode.inject(naviNode);
  362. naviNode.inject(this.node);
  363. this.startNavis.push(naviNode);
  364. this.setStartNaviEvent(naviNode, navi);
  365. this.setNodeCenter(this.node);
  366. }.bind(this));
  367. this.setStartMenuWidth();
  368. this.fireEvent("postLoad");
  369. }.bind(this));
  370. },
  371. setStartNaviEvent: function(naviNode){
  372. var _self = this;
  373. naviNode.addEvents({
  374. "mouseover": function(){ if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  375. "mouseout": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode);},
  376. "mousedown": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_down);},
  377. "mouseup": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  378. "click": function(){
  379. _self.doAction.apply(_self, [this]);
  380. }
  381. });
  382. },
  383. doAction: function(naviNode){
  384. var navi = naviNode.retrieve("naviData");
  385. var action = navi.action;
  386. if (this.currentNavi) this.currentNavi.setStyles(this.app.css.startMenuNaviNode);
  387. naviNode.setStyles(this.app.css.startMenuNaviNode_current);
  388. this.currentNavi = naviNode;
  389. if (this.app[action]) this.app[action].apply(this.app);
  390. if (this.status == "start"){
  391. this.toNormal();
  392. this.status = "normal";
  393. }
  394. },
  395. toNormal: function(){
  396. var css = this.app.css.normalStartMenuNode;
  397. if (!this.morph){
  398. this.morph = new Fx.Morph(this.node, {duration: 50, link: "chain"});
  399. }
  400. this.morph.start(css).chain(function(){
  401. this.node.setStyles(css);
  402. MWF.require("MWF.widget.ScrollBar", function(){
  403. new MWF.widget.ScrollBar(this.node, {
  404. "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  405. });
  406. }.bind(this));
  407. }.bind(this));
  408. },
  409. setNodeCenter: function(node){
  410. var size = node.getSize();
  411. var contentSize = this.app.node.getSize();
  412. var top = contentSize.y/2 - size.y/2;
  413. var left = contentSize.x/2 - size.x/2;
  414. if (left<0) left = 0;
  415. if (top<0) top = 0;
  416. node.setStyles({"left": left, "top": top});
  417. },
  418. getStartMenuNormalSize: function(){
  419. var naviItemNode = this.node.getFirst();
  420. var size = naviItemNode.getComputedSize();
  421. var mt = naviItemNode.getStyle("margin-top").toFloat();
  422. var mb = naviItemNode.getStyle("margin-bottom").toFloat();
  423. var height = size.totalWidth+mt+mb;
  424. var ml = naviItemNode.getStyle("margin-left").toFloat();
  425. var mr = naviItemNode.getStyle("margin-right").toFloat();
  426. var width = size.totalWidth+ml+mr;
  427. return {"width": width, "height": height*this.startNavis.length};
  428. },
  429. setStartMenuWidth: function(){
  430. var naviItemNode = this.node.getFirst();
  431. var size = naviItemNode.getComputedSize();
  432. var ml = naviItemNode.getStyle("margin-left").toFloat();
  433. var mr = naviItemNode.getStyle("margin-right").toFloat();
  434. var width = size.totalWidth+ml+mr;
  435. this.node.setStyle("width", (width*this.startNavis.length)+"px");
  436. },
  437. onResize: function(){
  438. if (this.status == "start"){
  439. this.setNodeCenter(this.node);
  440. }
  441. }
  442. });