Monthly.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. MWF.xApplication.BAM.monthly = MWF.xApplication.BAM.monthly || {};
  2. MWF.xApplication.BAM.Monthly = new Class({
  3. Implements: [Options, Events],
  4. options: {
  5. "style": "default"
  6. },
  7. initialize: function(app, node, options){
  8. this.setOptions(options);
  9. this.app = app;
  10. this.css = this.app.css;
  11. this.lp = this.app.lp;
  12. this.container = $(node);
  13. this.actions = this.app.actions;
  14. this.initData();
  15. this.load();
  16. },
  17. initData: function(){
  18. this.categoryDataLoaded = false;
  19. this.organizationDataLoaded = false;
  20. this.overviewDataLoaded = false;
  21. //////////////
  22. ///////////
  23. //////////////
  24. ////////////
  25. },
  26. load: function(){
  27. this.loadMonthlyLayout();
  28. //this.loadMonthly();
  29. //this.fireEvent("loaded");
  30. },
  31. loadMonthlyLayout: function(){
  32. this.tabAreaNode = new Element("div", {"styles": this.css.monthTabAreaNode}).inject(this.container);
  33. this.contentAreaNode = new Element("div", {"styles": this.css.monthContentAreaNode}).inject(this.container);
  34. this.createTab();
  35. },
  36. createTab: function(){
  37. var html = "<table border='0' cellpadding='0' cellSpacing='0' align='center'><tr>" +
  38. "<td></td><td></td><td></td><td></td><td></td><td></td>" +
  39. "</tr></table>";
  40. this.tabAreaNode.set("html", html);
  41. this.table = this.tabAreaNode.getElement("table");
  42. var cells = this.tabAreaNode.getElements("td");
  43. this.table.setStyles(this.css.monthTabTableNode);
  44. cells.setStyles(this.css.monthTabCellNode);
  45. cells[0].setStyle("border-left", "0px");
  46. this.taskTabItem = this.createTabItemNode(this.lp.monthly.task, "task", cells[0]);
  47. this.taskCompletedTabItem = this.createTabItemNode(this.lp.monthly.taskCompleted, "taskCompleted", cells[1]);
  48. this.workTabItem = this.createTabItemNode(this.lp.monthly.work, "work", cells[2]);
  49. this.workCompletedTabItem = this.createTabItemNode(this.lp.monthly.workCompleted, "workCompleted", cells[3]);
  50. this.taskExpiredTabItem = this.createTabItemNode(this.lp.monthly.taskExpired, "taskExpired", cells[4]);
  51. this.workExpiredTabItem = this.createTabItemNode(this.lp.monthly.workExpired, "workExpired", cells[5]);
  52. this.taskTabItem.addEvent("click", this.changeToTask.bind(this));
  53. this.taskCompletedTabItem.addEvent("click", this.changeToTaskCompleted.bind(this));
  54. this.workTabItem.addEvent("click", this.changeToWork.bind(this));
  55. this.workCompletedTabItem.addEvent("click", this.changeToWorkCompleted.bind(this));
  56. this.taskExpiredTabItem.addEvent("click", this.changeToTaskExpired.bind(this));
  57. this.workExpiredTabItem.addEvent("click", this.changeToWorkExpired.bind(this));
  58. this.taskTabItem.click();
  59. },
  60. createTabItemNode: function(text, icon, content){
  61. var node = new Element("div", {"styles": this.css.monthTabItemNode}).inject(content);
  62. node.store("icon", icon);
  63. var iconNode = new Element("div", {"styles": this.css.monthTabItemIconNode}).inject(node);
  64. iconNode.setStyle("background-image", "url(/x_component_BAM/$Main/"+this.app.options.style+"/monthly/"+icon+".png)");
  65. var textNode = new Element("div", {"styles": this.css.monthTabItemTextNode}).inject(node);
  66. textNode.set("text", text);
  67. return node;
  68. },
  69. changeToTask: function(){
  70. this.setCurrentTabItem(0);
  71. this.loadContent("task");
  72. if (this.taskCompletedContent) this.taskCompletedContent.hide();
  73. if (this.workContent) this.workContent.hide();
  74. if (this.workCompletedContent) this.workCompletedContent.hide();
  75. if (this.taskExpiredContent) this.taskExpiredContent.hide();
  76. if (this.workExpiredContent) this.workExpiredContent.hide();
  77. },
  78. changeToTaskCompleted: function(){
  79. this.setCurrentTabItem(1);
  80. this.loadContent("taskCompleted");
  81. if (this.taskContent) this.taskContent.hide();
  82. if (this.workContent) this.workContent.hide();
  83. if (this.workCompletedContent) this.workCompletedContent.hide();
  84. if (this.taskExpiredContent) this.taskExpiredContent.hide();
  85. if (this.workExpiredContent) this.workExpiredContent.hide();
  86. },
  87. changeToWork: function(){
  88. this.setCurrentTabItem(2);
  89. this.loadContent("work");
  90. if (this.taskContent) this.taskContent.hide();
  91. if (this.taskCompletedContent) this.taskCompletedContent.hide();
  92. if (this.workCompletedContent) this.workCompletedContent.hide();
  93. if (this.taskExpiredContent) this.taskExpiredContent.hide();
  94. if (this.workExpiredContent) this.workExpiredContent.hide();
  95. },
  96. changeToWorkCompleted: function(){
  97. this.setCurrentTabItem(3);
  98. this.loadContent("workCompleted");
  99. if (this.taskContent) this.taskContent.hide();
  100. if (this.taskCompletedContent) this.taskCompletedContent.hide();
  101. if (this.workContent) this.workContent.hide();
  102. if (this.taskExpiredContent) this.taskExpiredContent.hide();
  103. if (this.workExpiredContent) this.workExpiredContent.hide();
  104. },
  105. changeToTaskExpired: function(){
  106. this.setCurrentTabItem(4);
  107. this.loadContent("taskExpired");
  108. if (this.taskContent) this.taskContent.hide();
  109. if (this.taskCompletedContent) this.taskCompletedContent.hide();
  110. if (this.workContent) this.workContent.hide();
  111. if (this.workCompletedContent) this.workCompletedContent.hide();
  112. if (this.workExpiredContent) this.workExpiredContent.hide();
  113. },
  114. changeToWorkExpired: function(){
  115. this.setCurrentTabItem(5);
  116. this.loadContent("workExpired");
  117. if (this.taskContent) this.taskContent.hide();
  118. if (this.taskCompletedContent) this.taskCompletedContent.hide();
  119. if (this.workContent) this.workContent.hide();
  120. if (this.workCompletedContent) this.workCompletedContent.hide();
  121. if (this.taskExpiredContent) this.taskExpiredContent.hide();
  122. },
  123. setCurrentTabItem: function(idx){
  124. var cells = this.table.getElements("td");
  125. cells.each(function(cell, i){
  126. if (i==idx){
  127. debugger;
  128. var currentDiv = cell.getFirst("div");
  129. var currentIcon = currentDiv.retrieve("icon");
  130. currentDiv.setStyles(this.css.monthTabItemNode_current);
  131. currentDiv.getFirst("div").setStyle("background-image", "url(/x_component_BAM/$Main/"+this.app.options.style+"/monthly/"+currentIcon+"_current.png)");
  132. }else{
  133. var div = cell.getFirst("div");
  134. var icon = div.retrieve("icon");
  135. div.setStyles(this.css.monthTabItemNode);
  136. div.getFirst("div").setStyle("background-image", "url(/x_component_BAM/$Main/"+this.app.options.style+"/monthly/"+icon+".png)");
  137. }
  138. }.bind(this));
  139. },
  140. loadContent: function(name){
  141. debugger;
  142. var className = "Monthly"+name.capitalize()+"Content";
  143. if (this[name+"Content"]){
  144. this[name+"Content"].show();
  145. }else{
  146. MWF.xDesktop.requireApp("BAM", "monthly.MonthlyContent", function(){
  147. this[name+"Content"] = new MWF.xApplication.BAM.monthly[className](this, this.contentAreaNode, {
  148. "onLoaded": function(){
  149. this.fireEvent("loaded");
  150. }.bind(this)
  151. });
  152. }.bind(this));
  153. }
  154. },
  155. destroy: function(){
  156. //this.summaryChart.destroy();
  157. //this.rankChart.destroy();
  158. //this.dashboardChart.destroy();
  159. //this.taskChart.destroy();
  160. //this.taskCompletedChart.destroy();
  161. //this.workChart.destroy();
  162. //this.workCompletedChart.destroy();
  163. //if (this.taskContent) this.taskContent.destroy();
  164. //if (this.workContent) this.workContent.destroy();
  165. //if (this.workCompletedContent) this.workCompletedContent.destroy();
  166. //if (this.taskExpiredContent) this.taskExpiredContent.destroy();
  167. //if (this.workExpiredContent) this.workExpiredContent.destroy();
  168. this.container.empty();
  169. MWF.release(this);
  170. }
  171. //
  172. //
  173. //
  174. //
  175. //
  176. //
  177. //checkLoadDataCompleted: function(){
  178. // if (this.overviewDataLoaded && this.categoryDataLoaded && this.organizationDataLoaded){
  179. // this.fireEvent("loaded");
  180. // }
  181. //},
  182. //loadSummary: function(){
  183. // this.loadOverviewData(function(){
  184. // this.loadOverview();
  185. // this.overviewDataLoaded = true;
  186. // this.checkLoadDataCompleted();
  187. // }.bind(this));
  188. // this.loadCategoryData(function(){
  189. // this.loadTaskDashboard();
  190. // this.loadTaskContent();
  191. // this.loadTaskCompletedContent();
  192. // this.loadWorkContent();
  193. // this.loadWorkCompletedContent();
  194. // this.categoryDataLoaded = true;
  195. // this.checkLoadDataCompleted();
  196. // }.bind(this));
  197. // this.loadOrganizationData(function(){
  198. // this.loadTaskRank()
  199. // this.organizationDataLoaded = true;
  200. // this.checkLoadDataCompleted();
  201. // }.bind(this));
  202. //},
  203. //loadOverviewData: function(callback){
  204. // this.actions.summary(function(json){
  205. // this.summaryData = json.data;
  206. // if (callback) callback();
  207. // }.bind(this));
  208. //},
  209. //loadOverview: function(){
  210. //// this.actions.summary(function(json){
  211. //// this.summaryData = json.data;
  212. // MWF.xDesktop.requireApp("BAM", "summary.Overview", function(){
  213. // this.summaryChart = new MWF.xApplication.BAM.summary.Overview(this, this.overviewAreaNode, this.summaryData);
  214. // }.bind(this));
  215. //// }.bind(this));
  216. //},
  217. //loadTaskRank: function(){
  218. // MWF.xDesktop.requireApp("BAM", "summary.TaskRank", function(){
  219. // this.rankChart = new MWF.xApplication.BAM.summary.TaskRank(this, this.taskRankAreaNode);
  220. // }.bind(this));
  221. //},
  222. //loadTaskDashboard: function(){
  223. // MWF.xDesktop.requireApp("BAM", "summary.TaskDashboard", function(){
  224. // this.dashboardChart = new MWF.xApplication.BAM.summary.TaskDashboard(this, this.taskDashboardAreaNode);
  225. // }.bind(this));
  226. //},
  227. //
  228. //loadTaskContent: function(){
  229. // //MWF.xDesktop.requireApp("BAM", "summary.TaskContent", function(){
  230. // // this.taskChart = new MWF.xApplication.BAM.summary.TaskContent(this, this.taskContentAreaNode);
  231. // //}.bind(this));
  232. // MWF.xDesktop.requireApp("BAM", "summary.TaskContent", null, false);
  233. // this.taskChart = new MWF.xApplication.BAM.summary.TaskContent(this, this.taskContentAreaNode);
  234. //},
  235. //loadTaskCompletedContent: function(){
  236. // //MWF.xDesktop.requireApp("BAM", "summary.TaskCompletedContent", function(){
  237. // // this.taskCompletedChart = new MWF.xApplication.BAM.summary.TaskCompletedContent(this, this.taskCompletedContentAreaNode, this.scalingData);
  238. // //}.bind(this));
  239. // MWF.xDesktop.requireApp("BAM", "summary.TaskCompletedContent". null, false);
  240. // this.taskCompletedChart = new MWF.xApplication.BAM.summary.TaskCompletedContent(this, this.taskCompletedContentAreaNode, this.scalingData);
  241. //},
  242. //loadWorkContent: function(){
  243. // //MWF.xDesktop.requireApp("BAM", "summary.WorkContent", function(){
  244. // // this.workChart = new MWF.xApplication.BAM.summary.WorkContent(this, this.workContentAreaNode, this.scalingData);
  245. // //}.bind(this));
  246. // MWF.xDesktop.requireApp("BAM", "summary.WorkContent", null, false);
  247. // this.workChart = new MWF.xApplication.BAM.summary.WorkContent(this, this.workContentAreaNode, this.scalingData);
  248. //},
  249. //loadWorkCompletedContent: function(){
  250. // //MWF.xDesktop.requireApp("BAM", "summary.WorkCompletedContent", function(){
  251. // // this.workCompletedChart = new MWF.xApplication.BAM.summary.WorkCompletedContent(this, this.workCompletedContentAreaNode, this.scalingData);
  252. // //}.bind(this));
  253. // MWF.xDesktop.requireApp("BAM", "summary.WorkCompletedContent", null,false);
  254. // this.workCompletedChart = new MWF.xApplication.BAM.summary.WorkCompletedContent(this, this.workCompletedContentAreaNode, this.scalingData);
  255. //},
  256. //
  257. //loadRunningData: function(callback){
  258. // if (!this.runningData){
  259. // this.actions.loadRunning(function(json){
  260. // this.runningData = json.data;
  261. // if (callback) callback();
  262. // }.bind(this));
  263. // }else{
  264. // if (callback) callback();
  265. // }
  266. //},
  267. //loadOrganizationData: function(callback){
  268. // this.organizationData = {};
  269. // this.actions.loadOrganization(function(json){
  270. // this.organizationData = json.data;
  271. // if (callback) callback();
  272. // }.bind(this));
  273. //},
  274. //loadCategoryData: function(callback){
  275. // this.categoryData = {
  276. // "application": [],
  277. // "process": [],
  278. // "activity": []
  279. // };
  280. // this.actions.loadCategory(function(json){
  281. // this.categoryData = json.data;
  282. // if (callback) callback();
  283. // }.bind(this));
  284. //}
  285. });