Main.js 21 KB

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