Monthly.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. var currentDiv = cell.getFirst("div");
  128. var currentIcon = currentDiv.retrieve("icon");
  129. currentDiv.setStyles(this.css.monthTabItemNode_current);
  130. currentDiv.getFirst("div").setStyle("background-image", "url(../x_component_BAM/$Main/"+this.app.options.style+"/monthly/"+currentIcon+"_current.png)");
  131. }else{
  132. var div = cell.getFirst("div");
  133. var icon = div.retrieve("icon");
  134. div.setStyles(this.css.monthTabItemNode);
  135. div.getFirst("div").setStyle("background-image", "url(../x_component_BAM/$Main/"+this.app.options.style+"/monthly/"+icon+".png)");
  136. }
  137. }.bind(this));
  138. },
  139. loadContent: function(name){
  140. var className = "Monthly"+name.capitalize()+"Content";
  141. if (this[name+"Content"]){
  142. this[name+"Content"].show();
  143. }else{
  144. MWF.xDesktop.requireApp("BAM", "monthly.MonthlyContent", function(){
  145. this[name+"Content"] = new MWF.xApplication.BAM.monthly[className](this, this.contentAreaNode, {
  146. "onLoaded": function(){
  147. this.fireEvent("loaded");
  148. }.bind(this)
  149. });
  150. }.bind(this));
  151. }
  152. },
  153. destroy: function(){
  154. //this.summaryChart.destroy();
  155. //this.rankChart.destroy();
  156. //this.dashboardChart.destroy();
  157. //this.taskChart.destroy();
  158. //this.taskCompletedChart.destroy();
  159. //this.workChart.destroy();
  160. //this.workCompletedChart.destroy();
  161. //if (this.taskContent) this.taskContent.destroy();
  162. //if (this.workContent) this.workContent.destroy();
  163. //if (this.workCompletedContent) this.workCompletedContent.destroy();
  164. //if (this.taskExpiredContent) this.taskExpiredContent.destroy();
  165. //if (this.workExpiredContent) this.workExpiredContent.destroy();
  166. this.container.empty();
  167. MWF.release(this);
  168. }
  169. //
  170. //
  171. //
  172. //
  173. //
  174. //
  175. //checkLoadDataCompleted: function(){
  176. // if (this.overviewDataLoaded && this.categoryDataLoaded && this.organizationDataLoaded){
  177. // this.fireEvent("loaded");
  178. // }
  179. //},
  180. //loadSummary: function(){
  181. // this.loadOverviewData(function(){
  182. // this.loadOverview();
  183. // this.overviewDataLoaded = true;
  184. // this.checkLoadDataCompleted();
  185. // }.bind(this));
  186. // this.loadCategoryData(function(){
  187. // this.loadTaskDashboard();
  188. // this.loadTaskContent();
  189. // this.loadTaskCompletedContent();
  190. // this.loadWorkContent();
  191. // this.loadWorkCompletedContent();
  192. // this.categoryDataLoaded = true;
  193. // this.checkLoadDataCompleted();
  194. // }.bind(this));
  195. // this.loadOrganizationData(function(){
  196. // this.loadTaskRank()
  197. // this.organizationDataLoaded = true;
  198. // this.checkLoadDataCompleted();
  199. // }.bind(this));
  200. //},
  201. //loadOverviewData: function(callback){
  202. // this.actions.summary(function(json){
  203. // this.summaryData = json.data;
  204. // if (callback) callback();
  205. // }.bind(this));
  206. //},
  207. //loadOverview: function(){
  208. //// this.actions.summary(function(json){
  209. //// this.summaryData = json.data;
  210. // MWF.xDesktop.requireApp("BAM", "summary.Overview", function(){
  211. // this.summaryChart = new MWF.xApplication.BAM.summary.Overview(this, this.overviewAreaNode, this.summaryData);
  212. // }.bind(this));
  213. //// }.bind(this));
  214. //},
  215. //loadTaskRank: function(){
  216. // MWF.xDesktop.requireApp("BAM", "summary.TaskRank", function(){
  217. // this.rankChart = new MWF.xApplication.BAM.summary.TaskRank(this, this.taskRankAreaNode);
  218. // }.bind(this));
  219. //},
  220. //loadTaskDashboard: function(){
  221. // MWF.xDesktop.requireApp("BAM", "summary.TaskDashboard", function(){
  222. // this.dashboardChart = new MWF.xApplication.BAM.summary.TaskDashboard(this, this.taskDashboardAreaNode);
  223. // }.bind(this));
  224. //},
  225. //
  226. //loadTaskContent: function(){
  227. // //MWF.xDesktop.requireApp("BAM", "summary.TaskContent", function(){
  228. // // this.taskChart = new MWF.xApplication.BAM.summary.TaskContent(this, this.taskContentAreaNode);
  229. // //}.bind(this));
  230. // MWF.xDesktop.requireApp("BAM", "summary.TaskContent", null, false);
  231. // this.taskChart = new MWF.xApplication.BAM.summary.TaskContent(this, this.taskContentAreaNode);
  232. //},
  233. //loadTaskCompletedContent: function(){
  234. // //MWF.xDesktop.requireApp("BAM", "summary.TaskCompletedContent", function(){
  235. // // this.taskCompletedChart = new MWF.xApplication.BAM.summary.TaskCompletedContent(this, this.taskCompletedContentAreaNode, this.scalingData);
  236. // //}.bind(this));
  237. // MWF.xDesktop.requireApp("BAM", "summary.TaskCompletedContent". null, false);
  238. // this.taskCompletedChart = new MWF.xApplication.BAM.summary.TaskCompletedContent(this, this.taskCompletedContentAreaNode, this.scalingData);
  239. //},
  240. //loadWorkContent: function(){
  241. // //MWF.xDesktop.requireApp("BAM", "summary.WorkContent", function(){
  242. // // this.workChart = new MWF.xApplication.BAM.summary.WorkContent(this, this.workContentAreaNode, this.scalingData);
  243. // //}.bind(this));
  244. // MWF.xDesktop.requireApp("BAM", "summary.WorkContent", null, false);
  245. // this.workChart = new MWF.xApplication.BAM.summary.WorkContent(this, this.workContentAreaNode, this.scalingData);
  246. //},
  247. //loadWorkCompletedContent: function(){
  248. // //MWF.xDesktop.requireApp("BAM", "summary.WorkCompletedContent", function(){
  249. // // this.workCompletedChart = new MWF.xApplication.BAM.summary.WorkCompletedContent(this, this.workCompletedContentAreaNode, this.scalingData);
  250. // //}.bind(this));
  251. // MWF.xDesktop.requireApp("BAM", "summary.WorkCompletedContent", null,false);
  252. // this.workCompletedChart = new MWF.xApplication.BAM.summary.WorkCompletedContent(this, this.workCompletedContentAreaNode, this.scalingData);
  253. //},
  254. //
  255. //loadRunningData: function(callback){
  256. // if (!this.runningData){
  257. // this.actions.loadRunning(function(json){
  258. // this.runningData = json.data;
  259. // if (callback) callback();
  260. // }.bind(this));
  261. // }else{
  262. // if (callback) callback();
  263. // }
  264. //},
  265. //loadOrganizationData: function(callback){
  266. // this.organizationData = {};
  267. // this.actions.loadOrganization(function(json){
  268. // this.organizationData = json.data;
  269. // if (callback) callback();
  270. // }.bind(this));
  271. //},
  272. //loadCategoryData: function(callback){
  273. // this.categoryData = {
  274. // "application": [],
  275. // "process": [],
  276. // "activity": []
  277. // };
  278. // this.actions.loadCategory(function(json){
  279. // this.categoryData = json.data;
  280. // if (callback) callback();
  281. // }.bind(this));
  282. //}
  283. });