MonthlyContent.js 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  1. MWF.xApplication.BAM.monthly = MWF.xApplication.BAM.monthly || {};
  2. MWF.xApplication.BAM.monthly.MonthlyContent = new Class({
  3. Extends: MWF.widget.Common,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default"
  7. },
  8. initialize: function(monthly, node, options){
  9. this.setOptions(options);
  10. this.path = "../x_component_BAM/monthly/$MonthlyContent/";
  11. this.cssPath = "../x_component_BAM/monthly/$MonthlyContent/"+this.options.style+"/css.wcss";
  12. this._loadCss();
  13. this.monthly = monthly;
  14. this.app = this.monthly.app;
  15. this.actions = this.app.actions;
  16. this.container = $(node);
  17. this.initData();
  18. this.load();
  19. },
  20. initData: function(){
  21. this.sort = {
  22. "type": "application",
  23. "range": {}
  24. };
  25. this.filter = {
  26. "company": "",
  27. "department": "",
  28. "person": "",
  29. "application": "",
  30. "applicationName": "",
  31. "process":"",
  32. "processName":"",
  33. "activity": "",
  34. "activityName": ""
  35. };
  36. },
  37. clearFilter: function(){
  38. this.filter = {
  39. "unit": "",
  40. "topUnit": "",
  41. // "company": "",
  42. // "department": "",
  43. "person": "",
  44. "application": "",
  45. "applicationName": "",
  46. "process":"",
  47. "processName":"",
  48. "activity": "",
  49. "activityName": ""
  50. };
  51. },
  52. reload: function(){
  53. this.sortActionTextNode.set("html", this.getSortHtml());
  54. this.filterActionTextNode.set("html", this.getFilterHtml());
  55. this.table.destroy();
  56. this.chart.destroy();
  57. this.app.mask();
  58. this.loadData(function(){
  59. this.loadTable();
  60. this.loadChart();
  61. this.fireEvent("loaded");
  62. }.bind(this));
  63. },
  64. load: function(){
  65. this.node = new Element("div", {"styles": this.css.monthNode}).inject(this.container);
  66. this.titleAreaNode = new Element("div", {"styles": this.css.monthTitleAreaNode}).inject(this.node);
  67. this.sortByAreaNode = new Element("div", {"styles": this.css.monthSortByAreaNode}).inject(this.titleAreaNode);
  68. this.filterAreaNode = new Element("div", {"styles": this.css.monthFilterAreaNode}).inject(this.titleAreaNode);
  69. this.chartAreaNode = new Element("div", {"styles": this.css.monthChartAreaNode}).inject(this.node);
  70. this.tableAreaNode = new Element("div", {"styles": this.css.monthTableAreaNode}).inject(this.node);
  71. this.createSortNode();
  72. this.createFilterNode();
  73. this.app.mask();
  74. this.loadData(function(){
  75. this.loadTable();
  76. this.loadChart();
  77. this.fireEvent("loaded");
  78. }.bind(this));
  79. },
  80. createSortNode: function(){
  81. this.sortActionNode = new Element("div", {"styles": this.css.sortActionNode}).inject(this.sortByAreaNode);
  82. this.sortActionTitleNode = new Element("div", {"styles": this.css.sortActionTitleNode}).inject(this.sortActionNode);
  83. this.sortActionTextNode = new Element("div", {"styles": this.css.sortActionTextNode}).inject(this.sortActionNode);
  84. this.sortActionTitleNode.set("text", this.app.lp.monthly.sort);
  85. this.sortActionTextNode.set("html", this.getSortHtml());
  86. this.selectSort();
  87. },
  88. selectSort: function(){
  89. if (!this.sortSelectMenu){
  90. this.sortSelectMenu = new MWF.xDesktop.Menu(this.sortActionTitleNode, {
  91. "event": "click",
  92. "style": "BAMStyle",
  93. "offsetX": -1,
  94. "offsetY": -1,
  95. "container": this.app.content,
  96. "onQueryShow": function(){
  97. for (var i=0; i<5; i++){
  98. //this.sortSelectMenu.items[i].setDisable(false);
  99. this.sortSelectMenu.items[i].item.getFirst().empty();
  100. }
  101. var arr = ["company", "department", "application", "process", "activity"];
  102. var idx = arr.indexOf(this.sort.type);
  103. if (idx!=-1){
  104. //this.sortSelectMenu.items[idx].setDisable(true);
  105. //this.sortSelectMenu.items[idx].
  106. src = "../x_component_BAM/monthly/$MonthlyContent/"+this.options.style+"/icon/selected.png";
  107. var img = new Element("img", {"styles": this.sortSelectMenu.css.menuItemImg, "src": src}).inject(this.sortSelectMenu.items[idx].item.getFirst());
  108. }
  109. }.bind(this),
  110. "onPostShow": function(){
  111. var szie = this.sortActionNode.getSize();
  112. var menuSzie = this.sortSelectMenu.borderNode.getSize();
  113. if (szie.x>menuSzie.x){
  114. this.sortSelectMenu.node.setStyle("width", ""+szie.x+"px");
  115. }
  116. }.bind(this),
  117. "onPostHide": function(){
  118. this.sortSelectMenu.node.setStyle("width", "auto");
  119. this.sortActionNode.setStyles(this.css.sortActionNode);
  120. this.sortMenu = false;
  121. this.sortActionTitleNode.setStyles(this.css.sortActionTitleNode);
  122. }.bind(this)
  123. });
  124. this.sortSelectMenu.load();
  125. this.sortSelectMenu.addMenuItem(this.app.lp.monthly.sortItems.topUnit, "click", function(){this.sortSelected("topUnit");}.bind(this));
  126. this.sortSelectMenu.addMenuItem(this.app.lp.monthly.sortItems.unit, "click", function(){this.sortSelected("unit");}.bind(this));
  127. //this.sortSelectMenu.addMenuItem(this.app.lp.monthly.sortItems.company, "click", function(){this.sortSelected("company");}.bind(this));
  128. //this.sortSelectMenu.addMenuItem(this.app.lp.monthly.sortItems.department, "click", function(){this.sortSelected("department");}.bind(this));
  129. this.sortSelectMenu.addMenuItem(this.app.lp.monthly.sortItems.application, "click", function(){this.sortSelected("application");}.bind(this));
  130. this.sortSelectMenu.addMenuItem(this.app.lp.monthly.sortItems.process, "click", function(){this.sortSelected("process");}.bind(this));
  131. this.sortSelectMenu.addMenuItem(this.app.lp.monthly.sortItems.activity, "click", function(){this.sortSelected("activity");}.bind(this));
  132. }
  133. this.sortActionTitleNode.addEvents({
  134. "click": function(){
  135. var position = this.sortByAreaNode.getPosition(this.sortByAreaNode.getOffsetParent());
  136. this.sortActionNode.setStyles(this.css.sortActionNode_menu);
  137. var i = MWF.xDesktop.zIndexPool.zIndex+1;
  138. this.sortActionNode.setStyle("border-bottom", "0px solid #999");
  139. this.sortActionNode.setStyles({
  140. "left": position.x+"px",
  141. "z-index": i,
  142. "top": position.y+"px"
  143. });
  144. this.sortActionTitleNode.setStyles(this.css.sortActionTitleNode_menu);
  145. this.sortMenu = true;
  146. }.bind(this),
  147. "mouseover": function(){
  148. if (!this.sortMenu) this.sortActionTitleNode.setStyles(this.css.sortActionTitleNode_over);
  149. }.bind(this),
  150. "mouseout": function(){
  151. if (!this.sortMenu) this.sortActionTitleNode.setStyles(this.css.sortActionTitleNode);
  152. }.bind(this)
  153. });
  154. },
  155. sortSelected: function(type){
  156. switch (type){
  157. case "topUnit":
  158. this.sort = {"type": "topUnit","range": {}};
  159. this.filter.company = "";
  160. this.filter.department = "";
  161. this.filter.person = "";
  162. this.reload();
  163. break;
  164. case "unit":
  165. this.selectedSortUnit(type);
  166. break;
  167. // case "company":
  168. // this.sort = {"type": "company","range": {}};
  169. // this.filter.company = "";
  170. // this.filter.department = "";
  171. // this.filter.person = "";
  172. // this.reload();
  173. // break;
  174. // case "department":
  175. // this.selectedSortCompany(type);
  176. // break;
  177. case "application":
  178. this.sort = {"type": "application","range": {}};
  179. this.filter.application = "";
  180. this.filter.process = "";
  181. this.filter.activity = "";
  182. this.reload();
  183. break;
  184. case "process":
  185. this.selectedSortApplication(type);
  186. break;
  187. case "activity":
  188. this.selectedSortProcess(type);
  189. break;
  190. }
  191. },
  192. selectedSortUnit: function(type){
  193. MWF.xDesktop.requireApp("Selector", "package", function(){
  194. var options = {
  195. "type": "unit",
  196. "count": 1,
  197. "title": this.app.lp.monthly.selectSortCompany,
  198. "onComplete": function(items){
  199. this.sort = {"type": type,"range": {
  200. "unitName": items[0].data.id,
  201. "company": items[0].data.id
  202. }};
  203. this.filter.unit = "";
  204. this.filter.person = "";
  205. this.reload();
  206. }.bind(this)
  207. };
  208. var selector = new MWF.O2Selector(this.app.content, options);
  209. }.bind(this));
  210. },
  211. // selectedSortCompany: function(type){
  212. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  213. // var options = {
  214. // "type": "company",
  215. // "count": 1,
  216. // "title": this.app.lp.monthly.selectSortCompany,
  217. // "onComplete": function(items){
  218. // this.sort = {"type": type,"range": {
  219. // "companyName": items[0].data.name,
  220. // "company": items[0].data.id
  221. // }};
  222. // this.filter.company = "";
  223. // this.filter.department = "";
  224. // this.filter.person = "";
  225. // this.reload();
  226. // }.bind(this)
  227. // };
  228. // var selector = new MWF.OrgSelector(this.app.content, options);
  229. // }.bind(this));
  230. // },
  231. selectedSortApplication: function(type){
  232. MWF.xDesktop.requireApp("Selector", "package", function(){
  233. var options = {
  234. "type": "application",
  235. "count": 1,
  236. "title": this.app.lp.monthly.selectSortApplication,
  237. "onComplete": function(items){
  238. this.sort = {"type": type,"range": {
  239. "applicationName": items[0].data.name,
  240. "application": items[0].data.id
  241. }};
  242. this.filter.application = "";
  243. this.filter.process = "";
  244. this.filter.activity = "";
  245. this.reload();
  246. }.bind(this)
  247. };
  248. var selector = new MWF.O2Selector(this.app.content, options);
  249. }.bind(this));
  250. },
  251. selectedSortProcess: function(type){
  252. MWF.xDesktop.requireApp("Selector", "package", function(){
  253. var options = {
  254. "type": "process",
  255. "count": 1,
  256. "title": this.app.lp.monthly.selectSortProcess,
  257. "onComplete": function(items){
  258. this.sort = {"type": type,"range": {
  259. "applicationName": items[0].data.applicationName,
  260. "application": items[0].data.application,
  261. "processName": items[0].data.name,
  262. "process": items[0].data.id
  263. }};
  264. this.filter.application = "";
  265. this.filter.process = "";
  266. this.filter.activity = "";
  267. this.reload();
  268. }.bind(this)
  269. };
  270. var selector = new MWF.O2Selector(this.app.content, options);
  271. }.bind(this));
  272. },
  273. getSortHtml: function(){
  274. var typeText = this.app.lp.monthly.sortInfor[this.sort.type];
  275. if (this.sort.type==="process"){
  276. typeText = typeText.replace(/{app}/g, "<span style='color: #ff0000'>"+this.sort.range.applicationName+"</span>");
  277. }
  278. if (this.sort.type==="activity"){
  279. typeText = typeText.replace(/{app}/g, "<span style='color: #ff0000'>"+this.sort.range.applicationName+"</span>");
  280. typeText = typeText.replace(/{pro}/g, "<span style='color: #ff0000'>"+this.sort.range.processName+"</span>");
  281. }
  282. // if (this.sort.type=="department"){
  283. // typeText = typeText.replace(/{com}/g, "<span style='color: #ff0000'>"+this.sort.range.companyName+"</span>");
  284. // }
  285. if (this.sort.type==="unit"){
  286. typeText = typeText.replace(/{unit}/g, "<span style='color: #ff0000'>"+this.sort.range.unitName+"</span>");
  287. }
  288. return typeText;
  289. },
  290. selectFilter: function(){
  291. if (!this.filterSelectMenu){
  292. this.filterSelectMenu = new MWF.xDesktop.Menu(this.filterActionTitleNode, {
  293. "event": "click",
  294. "style": "BAMStyle",
  295. "offsetX": -1,
  296. "offsetY": -1,
  297. "container": this.app.content,
  298. "onQueryShow": function(){
  299. this.filterSelectMenu.clearItems();
  300. if (this.sort.type=="activity" || this.sort.type=="application" || this.sort.type=="process"){
  301. this.filterSelectMenu.addMenuItem(this.app.lp.monthly.filterItems.unit, "click", function(){this.filterSelected("unit");}.bind(this));
  302. // this.filterSelectMenu.addMenuItem(this.app.lp.monthly.filterItems.company, "click", function(){this.filterSelected("company");}.bind(this));
  303. // this.filterSelectMenu.addMenuItem(this.app.lp.monthly.filterItems.department, "click", function(){this.filterSelected("department");}.bind(this));
  304. }else{
  305. this.filterSelectMenu.addMenuItem(this.app.lp.monthly.filterItems.application, "click", function(){this.filterSelected("application");}.bind(this));
  306. this.filterSelectMenu.addMenuItem(this.app.lp.monthly.filterItems.process, "click", function(){this.filterSelected("process");}.bind(this));
  307. }
  308. }.bind(this),
  309. "onPostShow": function(){
  310. var size = this.filterActionNode.getSize();
  311. var titleSize = this.filterActionTitleNode.getSize();
  312. var menuSize = this.filterSelectMenu.borderNode.getSize();
  313. if (size.x>menuSize.x){
  314. this.filterSelectMenu.node.setStyle("width", ""+size.x+"px");
  315. }
  316. menuSize = this.filterSelectMenu.borderNode.getSize();
  317. var x = 0-(menuSize.x - titleSize.x);
  318. this.filterSelectMenu.setOptions({
  319. "offsetX": x
  320. });
  321. this.filterSelectMenu.setPosition();
  322. }.bind(this),
  323. "onPostHide": function(){
  324. this.filterSelectMenu.node.setStyle("width", "auto");
  325. this.filterActionNode.setStyles(this.css.filterActionNode);
  326. this.filterMenu = false;
  327. this.filterActionTitleNode.setStyles(this.css.filterActionTitleNode);
  328. }.bind(this)
  329. });
  330. this.filterSelectMenu.load();
  331. }
  332. this.filterActionTitleNode.addEvents({
  333. "click": function(){
  334. var position = this.filterActionNode.getPosition(this.filterActionNode.getOffsetParent());
  335. this.filterActionNode.setStyles(this.css.filterActionNode_menu);
  336. var i = MWF.xDesktop.zIndexPool.zIndex+1;
  337. this.filterActionNode.setStyle("border-bottom", "0px solid #999");
  338. this.filterActionNode.setStyles({
  339. "left": position.x+"px",
  340. "z-index": i,
  341. "top": position.y+"px"
  342. });
  343. this.filterActionTitleNode.setStyles(this.css.filterActionTitleNode_menu);
  344. this.filterMenu = true;
  345. }.bind(this),
  346. "mouseover": function(){
  347. if (!this.filterMenu) this.filterActionTitleNode.setStyles(this.css.filterActionTitleNode_over);
  348. }.bind(this),
  349. "mouseout": function(){
  350. if (!this.filterMenu) this.filterActionTitleNode.setStyles(this.css.filterActionTitleNode);
  351. }.bind(this)
  352. });
  353. },
  354. filterSelected: function(type){
  355. switch (type){
  356. case "unit":
  357. this.selectedFilterUnit(type);
  358. break;
  359. // case "company":
  360. // this.selectedFilterCompany(type);
  361. // break;
  362. // case "department":
  363. // this.selectedFilterDepartemnt(type);
  364. // break;
  365. case "application":
  366. this.selectedFilterApplication(type);
  367. break;
  368. case "process":
  369. this.selectedFilterProcess(type);
  370. break;
  371. }
  372. },
  373. selectedFilterUnit: function(){
  374. MWF.xDesktop.requireApp("Selector", "package", function(){
  375. var options = {
  376. "type": "unit",
  377. "count": 1,
  378. "title": this.app.lp.monthly.selectSortUnit,
  379. "onComplete": function(items){
  380. this.clearFilter();
  381. //this.filter.company = items[0].data.id;
  382. this.filter.unit = items[0].data.distinguishedName;
  383. this.reload();
  384. }.bind(this)
  385. };
  386. var selector = new MWF.O2Selector(this.app.content, options);
  387. }.bind(this));
  388. },
  389. // selectedFilterCompany: function(type){
  390. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  391. // var options = {
  392. // "type": "company",
  393. // "count": 1,
  394. // "title": this.app.lp.monthly.selectSortCompany,
  395. // "onComplete": function(items){
  396. // this.clearFilter();
  397. // //this.filter.company = items[0].data.id;
  398. // this.filter.company = items[0].data.name;
  399. // this.reload();
  400. // }.bind(this)
  401. // };
  402. // var selector = new MWF.OrgSelector(this.app.content, options);
  403. // }.bind(this));
  404. // },
  405. // selectedFilterDepartemnt: function(type){
  406. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  407. // var options = {
  408. // "type": "department",
  409. // "count": 1,
  410. // "title": this.app.lp.monthly.selectSortCompany,
  411. // "onComplete": function(items){
  412. // this.clearFilter();
  413. // //this.filter.department = items[0].data.id;
  414. // this.filter.department = items[0].data.name;
  415. // this.reload();
  416. // }.bind(this)
  417. // };
  418. // var selector = new MWF.OrgSelector(this.app.content, options);
  419. // }.bind(this));
  420. // },
  421. selectedFilterApplication: function(type){
  422. MWF.xDesktop.requireApp("Selector", "package", function(){
  423. var options = {
  424. "type": "application",
  425. "count": 1,
  426. "title": this.app.lp.monthly.selectSortApplication,
  427. "onComplete": function(items){
  428. this.clearFilter();
  429. this.filter.application = items[0].data.id;
  430. this.filter.applicationName = items[0].data.name;
  431. this.reload();
  432. }.bind(this)
  433. };
  434. var selector = new MWF.O2Selector(this.app.content, options);
  435. }.bind(this));
  436. },
  437. selectedFilterProcess: function(type){
  438. MWF.xDesktop.requireApp("Selector", "package", function(){
  439. var options = {
  440. "type": "process",
  441. "count": 1,
  442. "title": this.app.lp.monthly.selectSortProcess,
  443. "onComplete": function(items){
  444. this.clearFilter();
  445. this.filter.process = items[0].data.id;
  446. this.filter.processName = items[0].data.name;
  447. this.reload();
  448. }.bind(this)
  449. };
  450. var selector = new MWF.O2Selector(this.app.content, options);
  451. }.bind(this));
  452. },
  453. createFilterNode: function(){
  454. this.filterActionNode = new Element("div", {"styles": this.css.filterActionNode}).inject(this.filterAreaNode);
  455. this.filterActionTitleNode = new Element("div", {"styles": this.css.filterActionTitleNode}).inject(this.filterActionNode);
  456. this.filterActionTextNode = new Element("div", {"styles": this.css.filterActionTextNode}).inject(this.filterActionNode);
  457. this.filterActionTitleNode.set("text", this.app.lp.monthly.filter);
  458. this.filterActionTextNode.set("html", this.getFilterHtml());
  459. this.selectFilter();
  460. },
  461. getFilterHtml: function(){
  462. var textList = [];
  463. if (this.filter.unit) textList.push(this.app.lp.monthly.filterInfor.unit.replace(/{name}/g, "<span style='color: #ff0000'>"+MWF.name.cn(this.filter.unit)+"</span>"));
  464. // if (this.filter.company) textList.push(this.app.lp.monthly.filterInfor.company.replace(/{name}/g, "<span style='color: #ff0000'>"+this.filter.company+"</span>"));
  465. // if (this.filter.department) textList.push(this.app.lp.monthly.filterInfor.department.replace(/{name}/g, "<span style='color: #ff0000'>"+this.filter.department+"</span>"));
  466. if (this.filter.personName) textList.push(this.app.lp.monthly.filterInfor.person.replace(/{name}/g, "<span style='color: #ff0000'>"+this.filter.person+"</span>"));
  467. if (this.filter.applicationName) textList.push(this.app.lp.monthly.filterInfor.application.replace(/{name}/g, "<span style='color: #ff0000'>"+this.filter.applicationName+"</span>"));
  468. if (this.filter.processName) textList.push(this.app.lp.monthly.filterInfor.process.replace(/{name}/g, "<span style='color: #ff0000'>"+this.filter.processName+"</span>"));
  469. if (this.filter.activityName) textList.push(this.app.lp.monthly.filterInfor.activity.replace(/{name}/g, "<span style='color: #ff0000'>"+this.filter.activityName+"</span>"));
  470. if (textList.length) return textList.join(", ");
  471. return this.app.lp.monthly.filterInfor.all;
  472. },
  473. loadData: function(callback){
  474. this.actions.loadMonthly("task" ,this.sort, this.filter, function(json){
  475. this.data = json.data;
  476. if (callback) callback();
  477. }.bind(this));
  478. //this.actions.loadMonthlyByApplication("task" ,this.filter.company, this.filter.department, this.filter.person, function(json){
  479. // this.data = json.data;
  480. // if (callback) callback();
  481. //}.bind(this));
  482. },
  483. loadTable: function(){
  484. this.createTable();
  485. },
  486. createTable: function(){
  487. this.table = new MWF.xApplication.BAM.monthly.MonthlyContent.Table(this, this.tableAreaNode, this.data);
  488. },
  489. getSelectedData: function(){
  490. if (this.table.selectedData.length) return this.table.selectedData;
  491. var data = [];
  492. Object.each(this.data, function(v, k){
  493. var count = 0;
  494. v.each(function(o){count+=o.count;}.bind(this));
  495. var o = {
  496. "column": k,
  497. "data":[{"name": "all", "count": count}]
  498. };
  499. data.push(o);
  500. }.bind(this));
  501. return data;
  502. },
  503. loadChart: function(){
  504. this.chart = new MWF.xApplication.BAM.monthly.MonthlyContent.Chart(this, this.chartAreaNode, this.getSelectedData());
  505. },
  506. reloadChart: function(){
  507. if (this.chart) this.chart.destroy();
  508. this.chartAreaNode.empty();
  509. this.chart = new MWF.xApplication.BAM.monthly.MonthlyContent.Chart(this, this.chartAreaNode, this.getSelectedData());
  510. },
  511. show: function(){
  512. this.node.setStyle("display", "block");
  513. },
  514. hide: function(){
  515. this.node.setStyle("display", "none");
  516. },
  517. destroy: function(){
  518. this.node.destroy();
  519. MWF.release(this);
  520. }
  521. });
  522. MWF.xApplication.BAM.monthly.MonthlyContent.Table = new Class({
  523. initialize: function(content, node, data){
  524. this.content = content;
  525. this.monthly = this.content.monthly;
  526. this.app = this.monthly.app;
  527. this.actions = this.app.actions;
  528. this.css = this.content.css;
  529. this.container = $(node);
  530. this.data = data;
  531. this.rowSelectors = [];
  532. this.colSelectors = [];
  533. this.tableData = {
  534. "cols": [],
  535. "rows": [],
  536. "data": [],
  537. "cells": []
  538. };
  539. this.selectedRows = [];
  540. this.selectedCols = [];
  541. this.selectedData = [];
  542. this.load();
  543. },
  544. load: function(){
  545. this.table = new Element("table", {
  546. "styles": this.css.monthlyTable,
  547. "cellPadding": "0",
  548. "cellSpacing": "0",
  549. "border": "0"
  550. });
  551. this.getTableData();
  552. this.createColSelectRow();
  553. this.createTitleRow();
  554. this.createDataRow();
  555. this.table.inject(this.container);
  556. },
  557. getTableData: function(){
  558. var colData = [];
  559. var rowData = [];
  560. var data = [];
  561. var cells = [];
  562. var i=0;
  563. Object.each(this.data, function(v, k){
  564. colData.push(k);
  565. data.push([]);
  566. cells.push([]);
  567. v.each(function(o){
  568. if (!rowData.filter(function(x){return x.value==o.value;}).length){
  569. rowData.push(o);
  570. }
  571. data[i].push(o.count);
  572. cells[i].push(null);
  573. }.bind(this));
  574. i++
  575. }.bind(this));
  576. this.tableData = {
  577. "cols": colData,
  578. "rows": rowData,
  579. "data": data,
  580. "cells": cells
  581. };
  582. },
  583. createColSelectRow: function(){
  584. this.selectColTr = this.table.insertRow();
  585. var td = this.selectColTr.insertCell().setStyles(this.css.monthlyTableAllSelectTd).set("title", this.app.lp.monthly.selecteAll);
  586. new MWF.xApplication.BAM.monthly.MonthlyContent.Table.AllSelector(this, td);
  587. td = this.selectColTr.insertCell().setStyles(this.css.monthlyTableAllColSelectTd).set("title", this.app.lp.monthly.selecteAllCol);
  588. new MWF.xApplication.BAM.monthly.MonthlyContent.Table.AllColSelector(this, td);
  589. this.tableData.cols.each(function(n, i){
  590. td = this.selectColTr.insertCell().setStyles(this.css.monthlyTableColSelectTd);
  591. this.setColSelectTdEvent(td, i);
  592. }.bind(this));
  593. },
  594. createTitleRow: function(){
  595. var title = this.app.lp.monthly.columnTitle[this.content.sort.type];
  596. this.titleTr = this.table.insertRow();
  597. td = this.titleTr.insertCell().setStyles(this.css.monthlyTableAllRowSelectTd).set("title", this.app.lp.monthly.selecteAllRow);
  598. new MWF.xApplication.BAM.monthly.MonthlyContent.Table.AllRowSelector(this, td);
  599. td = this.titleTr.insertCell().setStyles(this.css.monthlyTableTitleTd);
  600. td.set("text", title);
  601. _self = this;
  602. this.tableData.cols.each(function(n, i){
  603. td = this.titleTr.insertCell().setStyles(this.css.monthlyTableTitleTd);
  604. td.set("text", n);
  605. td.store("idx", i);
  606. td.addEvent("click", function(){
  607. var idx = this.retrieve("idx");
  608. _self.colSelectors[idx].td.click();
  609. });
  610. }.bind(this));
  611. },
  612. createDataRow: function(){
  613. _self = this;
  614. this.tableData.rows.each(function(r, ri){
  615. var tr = this.table.insertRow();
  616. var td = tr.insertCell().setStyles(this.css.monthlyTableRowSelectTd);
  617. this.setRowSelectTdEvent(td, ri);
  618. td = tr.insertCell().setStyles(this.css.monthlyTableTitleTd).set("text", r.name);
  619. td.store("idx", ri);
  620. td.addEvent("click", function(){
  621. var idx = this.retrieve("idx");
  622. _self.rowSelectors[idx].td.click();
  623. });
  624. this.tableData.cols.each(function(c, ci){
  625. td = tr.insertCell().setStyles(this.css.monthlyTableTd);
  626. td.set("text", this.tableData.data[ci][ri]);
  627. this.tableData.cells[ci][ri] = td;
  628. new MWF.xApplication.BAM.monthly.MonthlyContent.Table.CellSelector(this, td);
  629. //this.setDrag(td);
  630. }.bind(this));
  631. }.bind(this));
  632. },
  633. setColSelectTdEvent: function(td, i){
  634. this.colSelectors.push(new MWF.xApplication.BAM.monthly.MonthlyContent.Table.ColSelector(this, td, i));
  635. },
  636. setRowSelectTdEvent: function(td, i){
  637. this.rowSelectors.push(new MWF.xApplication.BAM.monthly.MonthlyContent.Table.RowSelector(this, td, i));
  638. },
  639. destroy: function(){
  640. this.container.empty();
  641. MWF.release(this);
  642. }
  643. });
  644. MWF.xApplication.BAM.monthly.MonthlyContent.Table.ColSelector = new Class({
  645. initialize: function(table, td, i){
  646. this.table = table;
  647. this.td = td;
  648. this.idx = i;
  649. this.load();
  650. },
  651. load: function(){
  652. this.td.addEvents({
  653. "click": function(){
  654. if (this.table.selectedCols.indexOf(this.idx)!=-1){
  655. this.unselectedCol();
  656. }else{
  657. this.selectedCol();
  658. }
  659. }.bind(this)
  660. });
  661. },
  662. unselectedCol: function(){
  663. this.td.setStyles(this.table.css.monthlyTableSelectTd);
  664. this.table.selectedCols.erase(this.idx);
  665. this.checkSelectedCells();
  666. },
  667. selectedCol: function(){
  668. this.td.setStyles(this.table.css.monthlyTableSelectedTd);
  669. this.table.selectedCols.push(this.idx);
  670. this.checkSelectedCells();
  671. },
  672. checkIsSelected: function(ci, ri){
  673. if (!this.table.selectedCols.length && !this.table.selectedRows.length) return false;
  674. var colSelect = (!this.table.selectedCols.length) || this.table.selectedCols.indexOf(ci)!=-1;
  675. var rowSelect = (!this.table.selectedRows.length) || this.table.selectedRows.indexOf(ri)!=-1;
  676. return (colSelect && rowSelect);
  677. },
  678. checkSelectedCells: function(){
  679. this.table.selectedData =[];
  680. this.table.tableData.cells.each(function(cells, ci){
  681. var o = {
  682. "column": this.table.tableData.cols[ci],
  683. "data": []
  684. };
  685. cells.each(function(cell, ri){
  686. if (this.checkIsSelected(ci, ri)){
  687. cell.setStyles(this.table.css.monthlyTableTd_selected);
  688. o.data.push({
  689. "name": this.table.tableData.rows[ri].name,
  690. "value": this.table.tableData.rows[ri].value,
  691. "count": this.table.tableData.data[ci][ri]
  692. });
  693. }else{
  694. cell.setStyles(this.table.css.monthlyTableTd);
  695. }
  696. }.bind(this));
  697. if (o.data.length) this.table.selectedData.push(o);
  698. }.bind(this));
  699. this.table.content.reloadChart();
  700. }
  701. });
  702. MWF.xApplication.BAM.monthly.MonthlyContent.Table.RowSelector = new Class({
  703. Extends: MWF.xApplication.BAM.monthly.MonthlyContent.Table.ColSelector,
  704. load: function(){
  705. this.td.addEvents({
  706. "click": function(){
  707. if (this.table.selectedRows.indexOf(this.idx)!=-1){
  708. this.unselectedCol();
  709. }else{
  710. this.selectedCol();
  711. }
  712. }.bind(this)
  713. });
  714. },
  715. unselectedCol: function(){
  716. this.td.setStyles(this.table.css.monthlyTableSelectTd);
  717. this.table.selectedRows.erase(this.idx);
  718. this.checkSelectedCells();
  719. },
  720. selectedCol: function(){
  721. this.td.setStyles(this.table.css.monthlyTableSelectedTd);
  722. this.table.selectedRows.push(this.idx);
  723. this.checkSelectedCells();
  724. }
  725. });
  726. MWF.xApplication.BAM.monthly.MonthlyContent.Table.AllSelector = new Class({
  727. Extends: MWF.xApplication.BAM.monthly.MonthlyContent.Table.ColSelector,
  728. load: function(){
  729. this.td.addEvents({
  730. "click": function(){
  731. this.selectedAll();
  732. }.bind(this)
  733. });
  734. },
  735. selectedAll: function(){
  736. if (this.table.selectedRows.length || this.table.selectedCols.length){
  737. this.table.selectedRows = [];
  738. this.table.selectedCols = [];
  739. this.table.rowSelectors.each(function(sel){
  740. sel.td.setStyles(sel.table.css.monthlyTableSelectTd);
  741. });
  742. this.table.colSelectors.each(function(sel){
  743. sel.td.setStyles(sel.table.css.monthlyTableSelectTd);
  744. });
  745. }else{
  746. this.table.tableData.rows.each(function(r, i){
  747. if (i<20) this.table.selectedRows.push(i);
  748. }.bind(this));
  749. this.table.tableData.cols.each(function(c, i){
  750. if (i<20) this.table.selectedCols.push(i);
  751. }.bind(this));
  752. this.table.rowSelectors.each(function(sel){
  753. sel.td.setStyles(sel.table.css.monthlyTableSelectedTd);
  754. });
  755. this.table.colSelectors.each(function(sel){
  756. sel.td.setStyles(sel.table.css.monthlyTableSelectedTd);
  757. });
  758. }
  759. this.checkSelectedCells();
  760. }
  761. });
  762. MWF.xApplication.BAM.monthly.MonthlyContent.Table.AllColSelector = new Class({
  763. Extends: MWF.xApplication.BAM.monthly.MonthlyContent.Table.AllSelector,
  764. selectedAll: function(){
  765. if (this.table.selectedCols.length){
  766. this.table.selectedCols = [];
  767. this.table.colSelectors.each(function(sel){
  768. sel.td.setStyles(sel.table.css.monthlyTableSelectTd);
  769. });
  770. }else{
  771. this.table.tableData.cols.each(function(c, i){
  772. if (i<20) this.table.selectedCols.push(i);
  773. }.bind(this));
  774. this.table.colSelectors.each(function(sel){
  775. sel.td.setStyles(sel.table.css.monthlyTableSelectedTd);
  776. });
  777. }
  778. this.checkSelectedCells();
  779. }
  780. });
  781. MWF.xApplication.BAM.monthly.MonthlyContent.Table.AllRowSelector = new Class({
  782. Extends: MWF.xApplication.BAM.monthly.MonthlyContent.Table.AllSelector,
  783. selectedAll: function(){
  784. if (this.table.selectedRows.length){
  785. this.table.selectedRows = [];
  786. this.table.rowSelectors.each(function(sel){
  787. sel.td.setStyles(sel.table.css.monthlyTableSelectTd);
  788. });
  789. }else{
  790. this.table.tableData.rows.each(function(c, i){
  791. if (i<20) this.table.selectedRows.push(i);
  792. }.bind(this));
  793. this.table.rowSelectors.each(function(sel){
  794. sel.td.setStyles(sel.table.css.monthlyTableSelectedTd);
  795. });
  796. }
  797. this.checkSelectedCells();
  798. }
  799. });
  800. MWF.xApplication.BAM.monthly.MonthlyContent.Table.CellSelector = new Class({
  801. Extends: MWF.xApplication.BAM.monthly.MonthlyContent.Table.ColSelector,
  802. load: function(){
  803. new Drag(this.td, {
  804. "onStart": function(dragged, e){
  805. this.cellDragStart(dragged, e);
  806. }.bind(this),
  807. "onDrag": function(dragged, e){
  808. this.cellDrag(dragged, e);
  809. }.bind(this),
  810. "onComplete": function(dragged, e){
  811. this.completeDrag(dragged, e);
  812. }.bind(this)
  813. });
  814. this.td.addEvent("click", function(){
  815. var cellIndex = this.td.cellIndex-2;
  816. var rowIndex = this.td.getParent("tr").rowIndex-2;
  817. if (this.checkIsSelected(cellIndex, rowIndex)){
  818. }else{
  819. this.table.selectedCols.each(function(i){
  820. this.table.colSelectors[i].td.setStyles(this.table.css.monthlyTableSelectTd);
  821. }.bind(this));
  822. this.table.selectedRows.each(function(i){
  823. this.table.rowSelectors[i].td.setStyles(this.table.css.monthlyTableSelectTd);
  824. }.bind(this));
  825. this.table.selectedRows = [];
  826. this.table.selectedCols = [];
  827. this.checkSelectedCells();
  828. this.table.content.reloadChart();
  829. }
  830. }.bind(this));
  831. },
  832. cellDragStart: function(td, e){
  833. var p = this.td.getPosition();
  834. var size = this.td.getSize();
  835. this.td.store("start", {"x": p.x, "y": p.y});
  836. this.td.store("start2", {"x": p.x+size.x, "y": p.y+size.y});
  837. //this.td.store("eStart", {"x": e.page.x, "y": e.page.y});
  838. //this.boxNode = new Element("div", {"styles": this.table.css.selectBox}).inject(this.table.app.content);
  839. //var offp = this.table.app.content .getPosition();
  840. //x = e.page.x-offp.x;
  841. //y = e.page.y-offp.y;
  842. //this.boxNode.setStyles({
  843. // "top": ""+y+"px",
  844. // "left": ""+x+"px"
  845. //});
  846. },
  847. getSelectedCells: function(start, e){
  848. var ox = e.page.x-start.x;
  849. var oy = e.page.y-start.y;
  850. var tdSize = this.td.getSize();
  851. var cols = (ox/tdSize.x).toInt();
  852. var rows = (oy/tdSize.y).toInt();
  853. return {"cols": cols, "rows": rows};
  854. },
  855. cellDrag: function(td, e){
  856. this.table.selectedRows = [];
  857. this.table.selectedCols = [];
  858. this.table.selectedData = [];
  859. var start = this.td.retrieve("start");
  860. var start2 = this.td.retrieve("start2");
  861. var c1 = this.getSelectedCells(start, e);
  862. var c2 = this.getSelectedCells(start2, e);
  863. var cols = (Math.abs(c1.cols)>Math.abs(c2.cols)) ? c1.cols : c2.cols;
  864. var rows = (Math.abs(c1.rows)>Math.abs(c2.rows)) ? c1.rows : c2.rows;
  865. var cellIndex = this.td.cellIndex-2;
  866. var rowIndex = this.td.getParent("tr").rowIndex-2;
  867. if (!cellIndex || cellIndex<0) cellIndex = 0;
  868. if (!rowIndex || rowIndex<0) rowIndex = 0;
  869. var toCellIndex = cellIndex+cols;
  870. var toRowIndex = rowIndex+rows;
  871. if (toRowIndex>rowIndex){
  872. for (var i=rowIndex; i<=toRowIndex; i++) this.table.selectedRows.push(i);
  873. }else{
  874. for (var i=toRowIndex; i<=rowIndex; i++) this.table.selectedRows.push(i);
  875. }
  876. if (toCellIndex>cellIndex){
  877. for (var i=cellIndex; i<=toCellIndex; i++) this.table.selectedCols.push(i);
  878. }else{
  879. for (var i=toCellIndex; i<=cellIndex; i++) this.table.selectedCols.push(i);
  880. }
  881. //var eStart = this.td.retrieve("eStart");
  882. //this.boxNode.setStyles({
  883. // "width": ""+ox+"px",
  884. // "height": ""+oy+"px"
  885. //});
  886. this.checkSelectedCells();
  887. },
  888. completeDrag: function(td, e){
  889. this.table.selectedCols.each(function(i){
  890. this.table.colSelectors[i].td.setStyles(this.table.css.monthlyTableSelectedTd);
  891. }.bind(this));
  892. this.table.selectedRows.each(function(i){
  893. this.table.rowSelectors[i].td.setStyles(this.table.css.monthlyTableSelectedTd);
  894. }.bind(this));
  895. //this.boxNode.destroy();
  896. //this.boxNode = null;
  897. this.table.content.reloadChart();
  898. },
  899. checkSelectedCells: function(){
  900. this.table.selectedData =[];
  901. this.table.tableData.cells.each(function(cells, ci){
  902. var o = {
  903. "column": this.table.tableData.cols[ci],
  904. "data": []
  905. };
  906. cells.each(function(cell, ri){
  907. if (this.checkIsSelected(ci, ri)){
  908. cell.setStyles(this.table.css.monthlyTableTd_selected);
  909. o.data.push({
  910. "name": this.table.tableData.rows[ri].name,
  911. "value": this.table.tableData.rows[ri].value,
  912. "count": this.table.tableData.data[ci][ri]
  913. });
  914. }else{
  915. cell.setStyles(this.table.css.monthlyTableTd);
  916. }
  917. }.bind(this));
  918. if (o.data.length) this.table.selectedData.push(o);
  919. }.bind(this));
  920. //this.table.content.reloadChart();
  921. }
  922. });
  923. MWF.xApplication.BAM.monthly.MonthlyContent.Chart = new Class({
  924. initialize: function(content, node, data){
  925. this.content = content;
  926. this.monthly = this.content.monthly;
  927. this.app = this.monthly.app;
  928. this.css = this.content.css;
  929. this.container = $(node);
  930. this.data = data;
  931. this.load();
  932. },
  933. load: function(){
  934. this.chartFlagNode = new Element("div", {"styles": this.css.monthlyChartFlagAreaNode}).inject(this.container);
  935. this.chartNode = new Element("div", {"styles": this.css.monthlyChartNode}).inject(this.container);
  936. this.loadChart();
  937. },
  938. loadChart: function(){
  939. MWF.require("MWF.widget.chart.Bar", function(){
  940. this.flag = [];
  941. this.bar = new MWF.widget.chart.Bar(this.chartNode, this.data, "column", {"delay": 0, "style": "monthly"});
  942. this.data[0].data.each(function(d, i){
  943. this.flag.push({"name":d.name, "color": this.bar.colors[i]});
  944. this.bar.addBar(function(v){return v.data[i].count});
  945. }.bind(this));
  946. //bar.addBar("value");
  947. this.bar.addEvents({
  948. "mouseover": function(rects, texts, d, i){
  949. texts.filter(function(data, idx){return (idx==i);}).attr("display", "block");
  950. var rect = rects.filter(function(data, idx){return (idx==i);});
  951. var color = rect.attr("fill");
  952. rect.node().store("color", color);
  953. rect.attr("fill", "brown");
  954. }.bind(this),
  955. "mouseout": function(rects, texts, d, i){
  956. texts.filter(function(data, idx){return (idx==i);}).attr("display", "none");
  957. var rect = rects.filter(function(data, idx){return (idx==i);});
  958. var color = rect.node().retrieve("color");
  959. rect.attr("fill", color);
  960. }.bind(this)
  961. });
  962. this.bar.load();
  963. this.loadFlags();
  964. }.bind(this));
  965. },
  966. loadFlags: function(){
  967. this.flag.each(function(f, i){
  968. this.loadFlag(f, i);
  969. }.bind(this));
  970. },
  971. loadFlag: function(f, i){
  972. var flagNode = new Element("div", {"styles": this.css.monthlyChartFlagNode}).inject(this.chartFlagNode);
  973. var flagColorNode = new Element("div", {"styles": this.css.monthlyChartFlagColorNode}).inject(flagNode);
  974. flagColorNode.setStyle("background-color", f.color);
  975. var flagNameNode = new Element("div", {"styles": this.css.monthlyChartFlagNameNode}).inject(flagNode);
  976. flagNameNode.set("text", f.name);
  977. flagNameNode.set("title", f.name);
  978. flagNode.store("idx", i);
  979. flagNode.store("barColor", f.color);
  980. var _self = this;
  981. flagNode.addEvents({
  982. "mouseover": function(){
  983. this.getFirst().setStyles(_self.css.monthlyChartFlagColorNode_over);
  984. var idx = this.retrieve("idx");
  985. _self.highlightBar(idx);
  986. },
  987. "mouseout": function(){
  988. this.getFirst().setStyles(_self.css.monthlyChartFlagColorNode);
  989. var idx = this.retrieve("idx");
  990. var barColor = this.retrieve("barColor");
  991. _self.unHighlightBar(idx, barColor);
  992. }
  993. });
  994. },
  995. createHighlightDefs: function(id){
  996. //this.defssvg = this.bar.createDefs;
  997. var node = this.bar.svg.append("defs");
  998. var data = this.bar.css["rect_over_defs"];
  999. this.createDefs(node, data);
  1000. node.select(function(){ return this.getFirst(); }).attr("id", id);
  1001. node.attr("id", "defs_"+id);
  1002. },
  1003. createDefs: function(node, data){
  1004. var svgNode = node.append(data.tag);
  1005. Object.each(data.attrs, function(v,k){svgNode.attr(k,v);});
  1006. if (data.subs) {
  1007. data.subs.each(function(v){
  1008. this.createDefs(svgNode, v);
  1009. }.bind(this));
  1010. }
  1011. },
  1012. recreateBars: function(i){
  1013. var data = this.data.map(function(d, idx) {
  1014. return {"name": d["column"], "data": d.data[i].count};
  1015. }.bind(this));
  1016. this.bar.rectClass = Math.round(Math.random()*100);
  1017. var barWidth = this.bar.xScale.bandwidth()/this.bar.barsData.length;
  1018. var rects = this.bar.group.selectAll(".MWFBar_"+this.bar.rectClass+"_"+i)
  1019. .data(data)
  1020. .enter().append("rect")
  1021. .attr("class", ".MWFBar_"+this.bar.rectClass+"_"+i)
  1022. .attr("x", function(d) { return this.xScale(d.name)+(i*barWidth); }.bind(this.bar))
  1023. .attr("width", barWidth)
  1024. .attr("height", function(d) { return this.size.y - this.yScale(d.data); }.bind(this.bar))
  1025. .attr("y", function(d) { return this.yScale(d.data); }.bind(this.bar))
  1026. .attr("fill", this.bar.colors[i]);
  1027. this.bar.rectCluster[i] = rects;
  1028. this.bar.setEvents();
  1029. return rects;
  1030. },
  1031. highlightBar: function(i){
  1032. this.bar.rectCluster[i].remove();
  1033. var rects = this.recreateBars(i);
  1034. var id = "rect_over_defs"+i;
  1035. this.createHighlightDefs(id);
  1036. rects.attr(this.bar.css["rect_over_defs"].urlAttr, "url(#"+id+")");
  1037. var texts = this.bar.textCluster[i];
  1038. texts.attr("display", "block");
  1039. texts.attr("font-weight", "bold");
  1040. },
  1041. unHighlightBar: function(i, barColor){
  1042. var id = "rect_over_defs"+i;
  1043. var def = d3.select("#defs_"+id);
  1044. def.remove();
  1045. var rects = this.bar.rectCluster[i];
  1046. rects.attr(this.bar.css["rect_over_defs"].urlAttr, null);
  1047. var texts = this.bar.textCluster[i];
  1048. texts.attr("display", "none");
  1049. texts.attr("font-weight", "normal");
  1050. },
  1051. destroy: function(){
  1052. this.container.empty();
  1053. this.bar.destroy();
  1054. MWF.release(this);
  1055. }
  1056. });
  1057. MWF.xApplication.BAM.monthly.MonthlyContent.Filter = new Class({
  1058. Implements: [Options, Events],
  1059. initialize: function (content, node) {
  1060. this.content = content;
  1061. this.monthly = this.content.monthly;
  1062. this.app = this.monthly.app;
  1063. this.css = this.content.css;
  1064. this.sort = this.content.sort;
  1065. this.filter = this.content.filter;
  1066. this.node = $(node);
  1067. this.load();
  1068. },
  1069. load: function(){
  1070. this.node.addEvent("cilck", function(){
  1071. this.showFilterMenu();
  1072. }.bind(this));
  1073. },
  1074. showFilterMenu: function(){
  1075. this.node = new Element("div", {"styles": this.css.filterAreaNode});
  1076. this.conditionNode = new Element("div", {"styles": this.css.filterAreaConditionNode}).inject(this.node);
  1077. this.actionNode = new Element("div", {"styles": this.css.filterAreaActionNode}).inject(this.node);
  1078. this.createAction();
  1079. },
  1080. createAction: function(){
  1081. this.okAction = new Element("div", {"styles": this.css.filterAreaOkActionNode}).inject(this.actionNode);
  1082. this.cancelAction = new Element("div", {"styles": this.css.filterAreaCancelActionNode}).inject(this.actionNode);
  1083. }
  1084. });
  1085. MWF.xApplication.BAM.monthly.MonthlyTaskContent = new Class({
  1086. Extends: MWF.xApplication.BAM.monthly.MonthlyContent
  1087. });
  1088. MWF.xApplication.BAM.monthly.MonthlyTaskCompletedContent = new Class({
  1089. Extends: MWF.xApplication.BAM.monthly.MonthlyContent,
  1090. loadData: function(callback){
  1091. this.actions.loadMonthly("taskCompleted" ,this.sort, this.filter, function(json){
  1092. this.data = json.data;
  1093. if (callback) callback();
  1094. }.bind(this));
  1095. }
  1096. });
  1097. MWF.xApplication.BAM.monthly.MonthlyWorkContent = new Class({
  1098. Extends: MWF.xApplication.BAM.monthly.MonthlyContent,
  1099. loadData: function(callback){
  1100. this.actions.loadMonthly("work" ,this.sort, this.filter, function(json){
  1101. this.data = json.data;
  1102. if (callback) callback();
  1103. }.bind(this));
  1104. }
  1105. });
  1106. MWF.xApplication.BAM.monthly.MonthlyWorkCompletedContent = new Class({
  1107. Extends: MWF.xApplication.BAM.monthly.MonthlyContent,
  1108. loadData: function(callback){
  1109. this.actions.loadMonthly("workCompleted" ,this.sort, this.filter, function(json){
  1110. this.data = json.data;
  1111. if (callback) callback();
  1112. }.bind(this));
  1113. }
  1114. });
  1115. MWF.xApplication.BAM.monthly.MonthlyTaskExpiredContent = new Class({
  1116. Extends: MWF.xApplication.BAM.monthly.MonthlyContent,
  1117. loadData: function(callback){
  1118. this.actions.loadMonthly("taskExpired" ,this.sort, this.filter, function(json){
  1119. this.data = json.data;
  1120. if (callback) callback();
  1121. }.bind(this));
  1122. }
  1123. });
  1124. MWF.xApplication.BAM.monthly.MonthlyWorkExpiredContent = new Class({
  1125. Extends: MWF.xApplication.BAM.monthly.MonthlyContent,
  1126. loadData: function(callback){
  1127. this.actions.loadMonthly("workExpired" ,this.sort, this.filter, function(json){
  1128. this.data = json.data;
  1129. if (callback) callback();
  1130. }.bind(this));
  1131. }
  1132. });