Project.js 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240
  1. /*
  2. this.data //project的数据
  3. this.currentProjectGroupData //当前taskgroup的数据
  4. */
  5. MWF.xApplication.TeamWork = MWF.xApplication.TeamWork || {};
  6. MWF.xDesktop.requireApp("TeamWork", "Common", null, false);
  7. MWF.xApplication.TeamWork.Project = new Class({
  8. Extends: MWF.widget.Common,
  9. Implements: [Options, Events],
  10. options: {
  11. "style": "default"
  12. },
  13. initialize: function (container, app, data, options) {
  14. this.setOptions(options);
  15. this.container = container;
  16. this.app = app;
  17. this.lp = this.app.lp.project;
  18. this.actions = this.app.restActions;
  19. this.path = "/x_component_TeamWork/$Project/";
  20. this.cssPath = this.path+this.options.style+"/css.wcss";
  21. this._loadCss();
  22. this.data = data;
  23. },
  24. load: function () {
  25. this.container.setStyles({display:"flex"});
  26. this.container.empty();
  27. this.createTopBarLayout();
  28. this.createContentLayout();
  29. this.topBarTabItemTask.click();
  30. },
  31. createTopBarLayout:function(){
  32. var _self = this;
  33. this.topBarLayout = new Element("div.topBarLayout",{styles:this.css.topBarLayout}).inject(this.container);
  34. this.topBarBackContainer = new Element("div.topBarBackContainer",{styles:this.css.topBarBackContainer}).inject(this.topBarLayout);
  35. this.topBarBackHomeIcon = new Element("div.topBarBackHomeIcon",{styles:this.css.topBarBackHomeIcon}).inject(this.topBarBackContainer);
  36. this.topBarBackHomeIcon.addEvents({
  37. click:function(){
  38. var pl = new MWF.xApplication.TeamWork.ProjectList(this.container,this.app,this.actions,{});
  39. pl.load();
  40. }.bind(this),
  41. mouseover:function(){
  42. var opt={
  43. axis: "y" //箭头在x轴还是y轴上展现
  44. };
  45. this.app.showTips(this.topBarBackHomeIcon,{_html:"<div style='margin:2px 5px;'>"+this.lp.backProject+"</div>"},opt);
  46. }.bind(this)
  47. });
  48. this.topBarBackHomeNext = new Element("div.topBarBackHomeNext",{styles:this.css.topBarBackHomeNext}).inject(this.topBarBackContainer);
  49. this.topBarBackHomeTextContainer = new Element("div.topBarBackHomeTextContainer",{styles:this.css.topBarBackHomeTextContainer}).inject(this.topBarBackContainer);
  50. this.topBarBackHomeText = new Element("div.topBarBackHomeText",{styles:this.css.topBarBackHomeText,text:this.data.title}).inject(this.topBarBackHomeTextContainer);
  51. this.topBarBackHomeArrow = new Element("div.topBarBackHomeArrow",{styles:this.css.topBarBackHomeArrow}).inject(this.topBarBackHomeTextContainer);
  52. this.topBarBackHomeTextContainer.addEvents({
  53. click:function(){
  54. var plist = new MWF.xApplication.TeamWork.Project.ProjectList(this.container, this.topBarBackHomeTextContainer, this.app, this.data, {
  55. css:this.css,
  56. lp:this.lp,
  57. axis : "y",
  58. position : { //node 固定的位置
  59. x : "right", //x轴上left center right, auto 系统自动计算
  60. y : "auto" //y 轴上top middle bottom, auto 系统自动计算
  61. },
  62. priorityOfAuto :{
  63. x : [ "center", "right", "left" ], //当position x 为 auto 时候的优先级
  64. y : [ "middle", "bottom", "top" ] //当position y 为 auto 时候的优先级
  65. },
  66. nodeStyles : {
  67. "min-width":"300px",
  68. "padding":"2px",
  69. "border-radius":"5px",
  70. "z-index" : "101"
  71. }
  72. });
  73. plist.load();
  74. }.bind(this),
  75. mouseover:function(){this.getElements("div").setStyles({"color":"#4a90e2"})},
  76. mouseout:function () { this.getElements("div").setStyles({"color":"#333333"}) }
  77. });
  78. this.topBarTabsContainer = new Element("div.topBarTabsContainer",{styles:this.css.topBarTabsContainer}).inject(this.topBarLayout);
  79. this.topBarTabItemTask = new Element("div.topBarTabItemTask",{styles:this.css.topBarTabItemTask,text:this.lp.task}).inject(this.topBarTabsContainer);
  80. this.topBarTabItemTask.addEvents({
  81. click:function(){
  82. this.topBarTabItemTask.setStyles({"color":"#4A90E2","border-bottom":"2px solid #4A90E2"});
  83. this.topBarTabItemStat.setStyles({"color":"","border-bottom":"0px"});
  84. this.createTaskLayout();
  85. }.bind(this)
  86. });
  87. this.topBarTabItemStat = new Element("div.topBarTabItemStat",{styles:this.css.topBarTabItemStat,text:this.lp.stat}).inject(this.topBarTabsContainer);
  88. this.topBarTabItemStat.addEvents({
  89. click:function(){
  90. this.topBarTabItemTask.setStyles({"color":"","border-bottom":"0px"});
  91. this.topBarTabItemStat.setStyles({"color":"#4A90E2","border-bottom":"2px solid #4A90E2"});
  92. this.createStatLayout();
  93. }.bind(this)
  94. });
  95. this.topBarSettingContainer = new Element("div.topBarSettingContainer",{styles:this.css.topBarSettingContainer}).inject(this.topBarLayout);
  96. this.topBarSettingMenuContainer = new Element("div.topBarSettingMenuContainer",{styles:this.css.topBarSettingMenuContainer}).inject(this.topBarSettingContainer);
  97. this.topBarSettingMenuContainer.addEvents({
  98. click:function(){
  99. MWF.xDesktop.requireApp("TeamWork", "ProjectSetting", function(){
  100. var ps = new MWF.xApplication.TeamWork.ProjectSetting(this,this.data,
  101. {"width": "800","height": "80%",
  102. onPostOpen:function(){
  103. ps.formAreaNode.setStyles({"top":"10px"});
  104. var fx = new Fx.Tween(ps.formAreaNode,{duration:200});
  105. fx.start(["top"] ,"10px", "100px");
  106. },
  107. onPostClose:function(json){
  108. }
  109. },{
  110. container : this.container,
  111. lp : this.app.lp.projectSetting,
  112. css:_self.css
  113. }
  114. );
  115. ps.open();
  116. }.bind(this));
  117. }.bind(this),
  118. mouseover:function(){
  119. this.topBarSettingMenuContainer.getElements(".topBarSettingMenuIcon").setStyles({
  120. "background-image":"url(/x_component_TeamWork/$Project/default/icon/icon_caidan_click.png)"
  121. });
  122. this.topBarSettingMenuContainer.getElements(".topBarSettingMenuText").setStyles({
  123. "color":"#4A90E2"
  124. });
  125. }.bind(this),
  126. mouseout:function(){
  127. this.topBarSettingMenuContainer.getElements(".topBarSettingMenuIcon").setStyles({
  128. "background-image":"url(/x_component_TeamWork/$Project/default/icon/icon_caidan.png)"
  129. });
  130. this.topBarSettingMenuContainer.getElements(".topBarSettingMenuText").setStyles({
  131. "color":"#666666"
  132. });
  133. }.bind(this)
  134. });
  135. this.topBarSettingMenuIcon = new Element("div.topBarSettingMenuIcon",{styles:this.css.topBarSettingMenuIcon}).inject(this.topBarSettingMenuContainer);
  136. this.topBarSettingMenuText = new Element("div.topBarSettingMenuText",{styles:this.css.topBarSettingMenuText,text:this.lp.setting}).inject(this.topBarSettingMenuContainer);
  137. },
  138. createContentLayout:function(){
  139. this.contentLayout = new Element("div.contentLayout",{styles:this.css.contentLayout}).inject(this.container);
  140. },
  141. createTaskLayout:function(){
  142. if(this.contentLayout) this.contentLayout.empty();
  143. this.createNaviContent();
  144. this.createTaskContent();
  145. },
  146. createNaviContent:function(){
  147. if(this.naviLayout) this.naviLayout.destroy();
  148. this.naviLayout = new Element("div.naviLayout",{styles:this.css.naviLayout}).inject(this.contentLayout);
  149. this.app.setLoading(this.naviLayout);
  150. this.actions.projectNaviGet(this.data.id,function(json){
  151. this.projectGroupData = json.data;
  152. if(this.projectGroupData.groups && this.projectGroupData.groups.length>0){
  153. this.currentProjectGroupData = this.projectGroupData.groups[0]; //默认只有一个分组
  154. }
  155. this.naviLayout.empty();
  156. this.createNaviTask();
  157. this.createNaviView();
  158. this.naviTopMyTaskLayout.click();
  159. }.bind(this));
  160. },
  161. createNaviTask:function(){
  162. var _self = this;
  163. if(!this.currentProjectGroupData) return;
  164. if(this.naviTop) this.naviTop.destroy();
  165. this.naviTop = new Element("div.naviTop",{styles:this.css.naviTop}).inject(this.naviLayout);
  166. this.naviTopSearchContainer = new Element("div.naviTopSearchContainer",{styles:this.css.naviTopSearchContainer}).inject(this.naviTop);
  167. this.naviTopSearchIn = new Element("input.naviTopSearchIn",{styles:this.css.naviTopSearchIn,placeholder:this.lp.searchTask}).inject(this.naviTopSearchContainer);
  168. this.naviTopSearchIn.addEvents({
  169. keypress:function(e){
  170. this.searchLoading = true;
  171. var keycode = (e.event.keyCode ? e.event.keyCode : e.event.which);
  172. if (keycode == 13 || keycode == 10) {
  173. var key = this.naviTopSearchIn.get("value").trim();
  174. if(key=="") return;
  175. if(this.searchLoading) this.openSearch(key)
  176. }
  177. }.bind(this)
  178. });
  179. this.naviTopTaskContainer = new Element("div.naviTopTaskContainer",{styles:this.css.naviTopTaskContainer}).inject(this.naviTop);
  180. this.naviTopTaskText = new Element("div.naviTopTaskText",{styles:this.css.naviTopTaskText,text:this.lp.task}).inject(this.naviTopTaskContainer);
  181. this.naviTopTaskAdd = new Element("div.naviTopTaskAdd",{styles:this.css.naviTopTaskAdd}).inject(this.naviTopTaskContainer);
  182. this.naviTopTaskAdd.addEvents({
  183. click:function(){
  184. var data = {
  185. projectObj:this,
  186. taskGroupId:this.currentProjectGroupData.id,
  187. //projectId:this.data.id,
  188. taskListIds:[]
  189. };
  190. var opt = {
  191. onCreateTask:function(){
  192. this.createTaskGroup();
  193. }.bind(this)
  194. };
  195. var newTask = new MWF.xApplication.TeamWork.Project.NewTask(this,data,opt,{});
  196. newTask.open();
  197. }.bind(this),
  198. mouseover:function(){
  199. this.naviTopTaskAdd.setStyles({
  200. "background-image":"url(/x_component_TeamWork/$Project/default/icon/icon_zengjia_blue2_click.png)"
  201. });
  202. this.app.showTips(this.naviTopTaskAdd,{_html:"<div style='margin:2px 5px;'>"+this.lp.taskAdd+"</div>"});
  203. }.bind(this),
  204. mouseout:function(){
  205. this.naviTopTaskAdd.setStyles({
  206. "background-image":"url(/x_component_TeamWork/$Project/default/icon/icon_jia.png)"
  207. });
  208. }.bind(this)
  209. });
  210. this.naviTopMyTaskLayout = new Element("div.naviTopMyTaskLayout",{styles:this.css.naviTopMyTaskLayout}).inject(this.naviTop);
  211. this.naviTopMyTaskLayout.addEvents({
  212. click:function(){
  213. this.curNaviItem = "group";
  214. this.naviTopMyTaskLayout.setStyles({"background-color":"#F2F5F7"});
  215. this.naviViewContainer.getElements(".naviItemContainer").each(function(d){
  216. this.naviItemChange(d,"leave")
  217. }.bind(this))
  218. this.createTaskGroup();
  219. }.bind(this),
  220. mouseover:function(){ if(_self.curNaviItem!="group") this.setStyles({"background-color":"#F2F5F7"}) },
  221. mouseout:function(){ if(_self.curNaviItem!="group") this.setStyles({"background-color":""}) }
  222. });
  223. this.naviTopMyTaskContainer = new Element("div.naviTopMyTaskContainer",{styles:this.css.naviTopMyTaskContainer}).inject(this.naviTopMyTaskLayout);
  224. this.naviTopMyTaskText = new Element("div.naviTopMyTaskText",{styles:this.css.naviTopMyTaskText,text:this.lp.myTask}).inject(this.naviTopMyTaskContainer);
  225. this.naviTopMyTaskCount = new Element("div.naviTopMyTaskCount",{styles:this.css.naviTopMyTaskCount,text:"("+this.currentProjectGroupData.completedTotal+"/"+this.currentProjectGroupData.taskTotal+")"}).inject(this.naviTopMyTaskContainer);
  226. this.naviTopTaskLineContainer = new Element("div.naviTopTaskLineContainer",{styles:this.css.naviTopTaskLineContainer}).inject(this.naviTopMyTaskLayout);
  227. this.naviTopTaskLine = new Element("div.naviTopTaskLine",{styles:this.css.naviTopTaskLine}).inject(this.naviTopTaskLineContainer);
  228. this.loadTaskLine();
  229. //this.naviTopMyTaskLayout.click();
  230. },
  231. loadTaskLine:function(){
  232. this.completeLine = new Element("div.completeLine",{styles:this.css.completeLine}).inject(this.naviTopTaskLine);
  233. this.completeLine.addEvents({
  234. mouseover:function(){
  235. this.app.showTips(this.completeLine,{_html:"<div style='margin:2px 5px;'>"+this.lp.taskCompleteText+":"+this.currentProjectGroupData.completedTotal+"</div>"});
  236. }.bind(this)
  237. });
  238. this.overLine = new Element("div.overLine",{styles:this.css.overLine}).inject(this.naviTopTaskLine);
  239. this.overLine.addEvents({
  240. mouseover:function(){
  241. this.app.showTips(this.overLine,{_html:"<div style='margin:2px 5px;'>"+this.lp.taskCompleteText+":"+this.currentProjectGroupData.overtimeTotal+"</div>"});
  242. }.bind(this)
  243. });
  244. if(this.currentProjectGroupData){
  245. var taskTotal = this.currentProjectGroupData.taskTotal;
  246. var completedTotal = this.currentProjectGroupData.completedTotal;
  247. var overtimeTotal = this.currentProjectGroupData.overtimeTotal;
  248. if(taskTotal){
  249. var _width = this.naviTopTaskLine.getWidth();
  250. var completePixel =_width * (completedTotal / taskTotal);
  251. var overPixel =_width * (overtimeTotal / taskTotal);
  252. this.completeLine.setStyles({"width":completePixel+"px"});
  253. this.overLine.setStyles({"width":overPixel+"px"});
  254. }
  255. }
  256. },
  257. createNaviView:function(){
  258. if(this.naviView) this.naviView.destroy();
  259. this.naviView = new Element("div.naviView",{styles:this.css.naviView}).inject(this.naviLayout);
  260. this.naviViewTitleContainer = new Element("div.naviViewTitleContainer",{styles:this.css.naviViewTitleContainer}).inject(this.naviView);
  261. this.naviViewTitle = new Element("div.naviViewTitle",{styles:this.css.naviViewTitle,text:this.lp.viewTitle}).inject(this.naviViewTitleContainer);
  262. this.naviViewAdd = new Element("div.naviViewAdd",{styles:this.css.naviViewAdd}).inject(this.naviViewTitleContainer);
  263. this.naviViewAdd.addEvents({
  264. click:function(){
  265. }.bind(this),
  266. mouseover:function(){
  267. this.naviViewAdd.setStyles({
  268. "background-image":"url(/x_component_TeamWork/$Project/default/icon/icon_zengjia_blue2_click.png)"
  269. });
  270. this.app.showTips(this.naviViewAdd,{_html:"<div style='margin:2px 5px;'>"+this.lp.viewAdd+"</div>"});
  271. }.bind(this),
  272. mouseout:function(){
  273. this.naviViewAdd.setStyles({
  274. "background-image":"url(/x_component_TeamWork/$Project/default/icon/icon_jia.png)"
  275. });
  276. }.bind(this)
  277. });
  278. this.createNaviViewItem();
  279. },
  280. createNaviViewItem:function(){
  281. var _self = this;
  282. if(this.naviViewContainer) this.naviViewContainer.destroy();
  283. this.naviViewContainer = new Element("div.naviViewContainer",{styles:this.css.naviViewContainer}).inject(this.naviView);
  284. this.viewData = this.viewData || this.projectGroupData.views;
  285. this.viewData.each(function(json){
  286. if(json.name==this.lp.viewItemAll){//所有任务
  287. this.naviItemAllContainer = new Element("div.naviItemContainer",{styles:this.css.naviItemContainer}).inject(this.naviViewContainer);
  288. this.naviItemAllIcon = new Element("div.naviItemAllIcon",{styles:this.css.naviItemAllIcon}).inject(this.naviItemAllContainer);
  289. this.naviItemAllText = new Element("div.naviItemText",{styles:this.css.naviItemText,text:this.lp.viewItemAll}).inject(this.naviItemAllContainer);
  290. this.naviItemAllContainer.addEvents({
  291. click:function(){
  292. this.curNaviItem = json.name;
  293. this.openView(this.naviItemAllContainer);
  294. }.bind(this),
  295. mouseenter:function(){ if(_self.curNaviItem != json.name) _self.naviItemChange(this,"enter")},
  296. mouseleave:function(){ if(_self.curNaviItem != json.name) _self.naviItemChange(this,"leave")}
  297. });
  298. }else if(json.name==this.lp.viewItemMy){
  299. //我的任务
  300. this.naviItemMyContainer = new Element("div.naviItemContainer",{styles:this.css.naviItemContainer}).inject(this.naviViewContainer);
  301. this.naviItemMyIcon = new Element("div.naviItemMyIcon",{styles:this.css.naviItemMyIcon}).inject(this.naviItemMyContainer);
  302. this.naviItemMyText = new Element("div.naviItemText",{styles:this.css.naviItemText,text:this.lp.viewItemMy}).inject(this.naviItemMyContainer);
  303. this.naviItemMyMore = new Element("div.naviItemMore",{styles:this.css.naviItemMore}).inject(this.naviItemMyContainer);
  304. this.naviItemMyMore.addEvent(
  305. "click",function(e){
  306. this.openNaviViewMore(this.naviItemMyMore);
  307. e.stopPropagation();
  308. }.bind(this)
  309. );
  310. this.naviItemMyContainer.addEvents({
  311. click:function(){
  312. this.curNaviItem = json.name;
  313. this.openView(this.naviItemMyContainer);
  314. }.bind(this),
  315. mouseenter:function(){ if(_self.curNaviItem != json.name) _self.naviItemChange(this,"enter")},
  316. mouseleave:function(){ if(_self.curNaviItem != json.name) _self.naviItemChange(this,"leave")}
  317. });
  318. }else if(json.name==this.lp.viewItemFlow){
  319. //未完成的任务
  320. this.naviItemFlowContainer = new Element("div.naviItemContainer",{styles:this.css.naviItemContainer}).inject(this.naviViewContainer);
  321. this.naviItemFlowIcon = new Element("div.naviItemFlowIcon",{styles:this.css.naviItemFlowIcon}).inject(this.naviItemFlowContainer);
  322. this.naviItemFlowText = new Element("div.naviItemText",{styles:this.css.naviItemText,text:this.lp.viewItemFlow}).inject(this.naviItemFlowContainer);
  323. this.naviItemFlowMore = new Element("div.naviItemMore",{styles:this.css.naviItemMore}).inject(this.naviItemFlowContainer);
  324. this.naviItemFlowMore.addEvent(
  325. "click",function(e){
  326. this.openNaviViewMore(this.naviItemFlowMore);
  327. e.stopPropagation();
  328. }.bind(this)
  329. );
  330. this.naviItemFlowContainer.addEvents({
  331. click:function(){
  332. alert("open")
  333. }.bind(this),
  334. mouseenter:function(){ _self.naviItemChange(this,"enter")},
  335. mouseleave:function(){_self.naviItemChange(this,"leave")}
  336. });
  337. }else if(json.name==this.lp.viewItemComplete){
  338. //已完成任务
  339. this.naviItemCompleteContainer = new Element("div.naviItemContainer",{styles:this.css.naviItemContainer}).inject(this.naviViewContainer);
  340. this.naviItemCompleteIcon = new Element("div.naviItemCompleteIcon",{styles:this.css.naviItemCompleteIcon}).inject(this.naviItemCompleteContainer);
  341. this.naviItemCompleteText = new Element("div.naviItemText",{styles:this.css.naviItemText,text:this.lp.viewItemComplete}).inject(this.naviItemCompleteContainer);
  342. this.naviItemCompleteMore = new Element("div.naviItemMore",{styles:this.css.naviItemMore}).inject(this.naviItemCompleteContainer);
  343. this.naviItemCompleteMore.addEvent(
  344. "click",function(e){
  345. this.openNaviViewMore(this.naviItemCompleteMore);
  346. e.stopPropagation();
  347. }.bind(this)
  348. );
  349. this.naviItemCompleteContainer.addEvents({
  350. click:function(){
  351. alert("open")
  352. }.bind(this),
  353. mouseenter:function(){ _self.naviItemChange(this,"enter")},
  354. mouseleave:function(){_self.naviItemChange(this,"leave")}
  355. });
  356. }else if(json.name==this.lp.viewItemOver){
  357. //已逾期任务
  358. this.naviItemOverContainer = new Element("div.naviItemContainer",{styles:this.css.naviItemContainer}).inject(this.naviViewContainer);
  359. this.naviItemOverIcon = new Element("div.naviItemOverIcon",{styles:this.css.naviItemOverIcon}).inject(this.naviItemOverContainer);
  360. this.naviItemOverText = new Element("div.naviItemText",{styles:this.css.naviItemText,text:this.lp.viewItemOver}).inject(this.naviItemOverContainer);
  361. this.naviItemOverMore = new Element("div.naviItemMore",{styles:this.css.naviItemMore}).inject(this.naviItemOverContainer);
  362. this.naviItemOverMore.addEvent(
  363. "click",function(e){
  364. this.openNaviViewMore(this.naviItemOverMore);
  365. e.stopPropagation();
  366. }.bind(this)
  367. );
  368. this.naviItemOverContainer.addEvents({
  369. click:function(){
  370. alert("open")
  371. }.bind(this),
  372. mouseenter:function(){ _self.naviItemChange(this,"enter")},
  373. mouseleave:function(){_self.naviItemChange(this,"leave")}
  374. });
  375. }else{
  376. //自定义视图
  377. }
  378. }.bind(this));
  379. },
  380. naviItemChange:function(node,action){
  381. if(action == "enter"){
  382. node.setStyles({"background-color":"#F2F5F7"});
  383. divs = node.getElements("div");
  384. divs[0].setStyles({"background-image":divs[0].getStyle("background-image").replace(".png","_click.png")});
  385. divs[1].setStyles({"color":"#4A90E2"});
  386. if(divs[2]){
  387. divs[2].setStyles({"background-image":divs[2].getStyle("background-image").replace(".png","_click.png")});
  388. }
  389. }else if(action == "leave"){
  390. node.setStyles({"background-color":""});
  391. divs = node.getElements("div");
  392. divs[0].setStyles({"background-image":divs[0].getStyle("background-image").replace("_click.png",".png")});
  393. divs[1].setStyles({"color":"#2A2A2A"});
  394. if(divs[2]){
  395. divs[2].setStyles({"background-image":divs[2].getStyle("background-image").replace("_click.png",".png")});
  396. }
  397. }
  398. },
  399. openNaviViewMore:function(node){
  400. var tooltip = new MWF.xApplication.TeamWork.Project.NaviViewTip(this.container, node, this.app, {}, {
  401. css:this.css,
  402. lp:this.lp,
  403. axis : "y",
  404. nodeStyles : {
  405. "min-width":"100px",
  406. "padding":"2px",
  407. "border-radius":"5px",
  408. "z-index" : "101"
  409. },
  410. onPostLoad:function(){
  411. tooltip.node.setStyles({"opacity":"0"});
  412. var fx = new Fx.Tween(tooltip.node,{duration:200});
  413. fx.start(["opacity"] ,"0", "1");
  414. },
  415. onClose:function(rd){
  416. // customGroupItemContainer.set("atIn","no");
  417. // if(rd)_self.reloadProjectGroup();
  418. }
  419. });
  420. tooltip.load();
  421. },
  422. createTaskContent:function(){
  423. this.taskContentLayout = new Element("div.taskContentLayout",{styles:this.css.taskContentLayout}).inject(this.contentLayout);
  424. },
  425. createTaskGroup:function(){ //右侧内容
  426. if(this.currentProjectGroupData && this.currentProjectGroupData.id){
  427. this.app.setLoading(this.taskContentLayout);
  428. this.actions.taskGroupList(this.currentProjectGroupData.id,function(json){
  429. this.taskContentLayout.empty();
  430. json.data.each(function(data,i){
  431. //if(i>0) return;
  432. var taskGroupLayout = new Element("div.taskGroupLayout",{styles:this.css.taskGroupLayout,id:data.id}).inject(this.taskContentLayout);
  433. taskGroupLayout.set("sortable",data.control.sortable); //控制是否能排序
  434. this.createTaskGroupItemLayout(taskGroupLayout,data);
  435. }.bind(this));
  436. //新建任务列表按钮
  437. this.newTaskGroupContainer = new Element("div.newTaskGroupContainer",{styles:this.css.newTaskGroupContainer}).inject(this.taskContentLayout);
  438. this.newTaskGroupContainer.addEvents({
  439. click:function(){
  440. var data = {
  441. isNew:true,
  442. taskGroupId:this.currentProjectGroupData.id,
  443. projectId:this.data.id
  444. };
  445. var opt = {
  446. onCreateTask:function(){
  447. this.createTaskGroup();
  448. }.bind(this)
  449. };
  450. var newTaskGroup = new MWF.xApplication.TeamWork.Project.NewTaskGroup(this,data,opt,{});
  451. newTaskGroup.open();
  452. }.bind(this),
  453. mouseover:function(){
  454. this.newTaskGroupIcon.setStyles({"background-image":"url(/x_component_TeamWork/$Project/default/icon/icon_jia_20_click.png)"});
  455. this.newTaskGroupText.setStyles({"color":"#4A90E2","font-size":"16px"});
  456. }.bind(this),
  457. mouseout:function(){
  458. this.newTaskGroupIcon.setStyles({"background-image":"url(/x_component_TeamWork/$Project/default/icon/icon_jia.png)"});
  459. this.newTaskGroupText.setStyles({"color":"#999999","font-size":"12px"});
  460. }.bind(this)
  461. });
  462. this.newTaskGroupIcon = new Element("div.newTaskGroupIcon",{styles:this.css.newTaskGroupIcon}).inject(this.newTaskGroupContainer);
  463. this.newTaskGroupText = new Element("div.newTaskGroupText",{styles:this.css.newTaskGroupText,text:this.lp.taskGroupAdd}).inject(this.newTaskGroupContainer);
  464. }.bind(this))
  465. }
  466. },
  467. createTaskGroupItemLayout:function(node,data){
  468. var _self = this;
  469. node.empty();
  470. var taskGroupItemTitleContainer = new Element("div.taskGroupItemTitleContainer",{styles:this.css.taskGroupItemTitleContainer}).inject(node);
  471. new Element("div.taskGroupItemTitleText",{styles:this.css.taskGroupItemTitleText,text:data.name}).inject(taskGroupItemTitleContainer);
  472. new Element("div.taskGroupItemTitleCount",{styles:this.css.taskGroupItemTitleCount,text:"("+data.taskCount+")"}).inject(taskGroupItemTitleContainer);
  473. if(data.control.sortable){
  474. var taskGroupItemTitleMore = new Element("div.taskGroupItemTitleMore",{styles:this.css.taskGroupItemTitleMore}).inject(taskGroupItemTitleContainer);
  475. taskGroupItemTitleMore.addEvents({
  476. click:function(){
  477. data.projectObj = this;
  478. data.node = node;
  479. var menu = new MWF.xApplication.TeamWork.Project.TaskGroupMenu(this.container, taskGroupItemTitleMore, this.app, data, {
  480. css:this.css,
  481. lp:this.lp,
  482. axis : "y",
  483. nodeStyles : {
  484. "min-width":"100px",
  485. "padding":"2px",
  486. "border-radius":"5px",
  487. "z-index" : "101"
  488. },
  489. onPostLoad:function(){
  490. menu.node.setStyles({"opacity":"0","top":(menu.node.getStyle("top").toInt()-10)+"px"});
  491. var fx = new Fx.Tween(menu.node,{duration:200});
  492. fx.start(["opacity"] ,"0", "1");
  493. },
  494. onClose:function(rd){
  495. if(!rd)return;
  496. _self.createTaskGroup()
  497. }
  498. });
  499. menu.load();
  500. }.bind(this),
  501. mouseover:function(){this.setStyles({"background-image":"url(/x_component_TeamWork/$Project/default/icon/icon_more_click.png)"})},
  502. mouseout:function(){this.setStyles({"background-image":"url(/x_component_TeamWork/$Project/default/icon/icon_more.png)"})}
  503. });
  504. }
  505. var taskGroupItemTitleAdd = new Element("div.taskGroupItemTitleAdd",{styles:this.css.taskGroupItemTitleAdd}).inject(taskGroupItemTitleContainer);
  506. if(!data.control.sortable) taskGroupItemTitleAdd.setStyle("margin-right","20px");
  507. taskGroupItemTitleAdd.addEvents({
  508. click:function(){
  509. var pdata = {
  510. projectObj:this,
  511. taskGroupId:this.currentProjectGroupData.id,
  512. //projectId:this.data.id,
  513. taskListIds:[data.id]
  514. };
  515. var opt = {
  516. onCreateTask:function(){
  517. this.createTaskGroup();
  518. }.bind(this)
  519. };
  520. var newTask = new MWF.xApplication.TeamWork.Project.NewTask(this,pdata,opt,{});
  521. newTask.open();
  522. }.bind(this),
  523. mouseover:function(){this.setStyles({"background-image":"url(/x_component_TeamWork/$Project/default/icon/icon_zengjia_blue2_click.png)"})},
  524. mouseout:function(){this.setStyles({"background-image":"url(/x_component_TeamWork/$Project/default/icon/icon_jia.png)"})}
  525. });
  526. var taskGroupItemContainer = new Element("div.taskGroupItemContainer",{styles:this.css.taskGroupItemContainer}).inject(node);
  527. var _h = node.getHeight().toInt()-taskGroupItemTitleContainer.getHeight().toInt() - 10 - 10;
  528. taskGroupItemContainer.setStyles({"height":_h+"px"});
  529. this.app.setScrollBar(taskGroupItemContainer);
  530. this.app.setLoading(taskGroupItemContainer);
  531. this.actions.taskListByListId(this.data.id,data.id,function(json){
  532. taskGroupItemContainer.empty();
  533. var taskListData = json.data;
  534. //alert(JSON.stringify(taskListData));
  535. taskListData.each(function(d){
  536. //var taskItemContainerDrag = new Element("div.taskItemContainerDrag.dragin",{styles:this.css.taskItemContainerDrag}).inject(taskGroupItemContainer);
  537. var taskItemContainer = new Element("div.taskItemContainer.dragin",{styles:this.css.taskItemContainer}).inject(taskGroupItemContainer);
  538. taskItemContainer.set("id",d.id);
  539. this.loadTaskNode(taskItemContainer,d);
  540. var int;
  541. var upTime = 0;
  542. var time = 200;
  543. taskItemContainer.addEvents({
  544. click:function(e){
  545. //解决click和mousedown事件冲突
  546. if(upTime>0){
  547. this.openTask(d.id,function(){ taskItemContainer.destroy() }.bind(this));
  548. upTime = 0
  549. }
  550. }.bind(this),
  551. mouseenter:function(){
  552. int = window.setInterval(function(){
  553. if(taskItemContainer.getElement(".taskItemHover").getWidth() == 10) return;
  554. taskItemContainer.getElement(".taskItemHover").setStyles({
  555. "width":(taskItemContainer.getElement(".taskItemHover").getWidth()+1)+"px"
  556. });
  557. }.bind(this),30)
  558. },
  559. mouseleave:function(){
  560. window.clearInterval(int);
  561. taskItemContainer.getElement(".taskItemHover").setStyles({"width":"5px"});
  562. }.bind(this),
  563. mouseup:function(){
  564. upTime = new Date().getTime();
  565. },
  566. mousedown:function(e){
  567. var position = taskItemContainer.getPosition();
  568. var clone = taskItemContainer.clone(true,true);
  569. clone.removeClass("dragin");
  570. clone.setStyles({
  571. "top":position.y+"px",
  572. "left":position.x+"px",
  573. "z-index":"9999",
  574. "position":"absolute",
  575. "cursor":"move"
  576. });
  577. var _height = clone.getHeight().toInt() - 2;
  578. var myDrag = new Drag.Move(clone, {
  579. container: this.taskContentLayout,
  580. //handle: taskItemHover,
  581. droppables: $$('.dragin'),
  582. onStart:function(el){
  583. if(upTime>0){
  584. myDrag.stop();
  585. }else{
  586. el.inject($(document.body));
  587. taskItemContainer.setStyles({"border":"1px dotted #000000","opacity":"0.3"});
  588. }
  589. },
  590. onLeave:function(el,dr){
  591. var pre = dr.getPrevious();
  592. if(pre && pre.get("class")=="taskItemInsertLine") {
  593. pre.destroy();
  594. }
  595. },
  596. onEnter:function(el,dr){
  597. var pre = dr.getPrevious();
  598. if(!pre || (pre && pre.get("class")!="taskItemInsertLine")){
  599. if(el.get("id")!=dr.get("id")){
  600. new Element("div.taskItemInsertLine",{styles:_self.css.taskItemInsertLine}).inject(dr,"before");
  601. }
  602. }
  603. },
  604. onDrop:function(el, dr, e){
  605. var taskId = el.get("id");
  606. var taskInId = null;
  607. var taskGroupInId = null;
  608. var taskGroupFromId = null;
  609. var taskGroupFromSortable = null;
  610. var taskGroupInSortable = null;
  611. el.setStyles({"cursor":""});
  612. if(!dr){
  613. //没有移入,还原
  614. var fx = new Fx.Tween(el,{duration:time});
  615. fx.start(["top"] ,el.getPosition().y+"px", taskItemContainer.getPosition().y+"px");
  616. var fx2 = new Fx.Tween(el,{duration:time});
  617. fx2.start(["left"] ,el.getPosition().x+"px", taskItemContainer.getPosition().x+"px");
  618. window.setTimeout(function(){
  619. taskItemContainer.setStyles({"border":"1px solid #e6e6e6","opacity":"1"});
  620. el.destroy()
  621. },time)
  622. }else{
  623. if(el.get("id")==dr.get("id")){ //如果移动的是本身的拷贝,恢复
  624. taskItemContainer.setStyles({"border":"1px solid #e6e6e6","opacity":"1"});
  625. el.destroy();
  626. }else{
  627. taskInId = dr.get("id");
  628. taskGroupFromId = taskItemContainer.getParent().getParent().get("id");
  629. taskGroupInId = dr.getParent().getParent().get("id");
  630. taskGroupFromSortable = taskItemContainer.getParent().getParent().get("sortable");
  631. taskGroupInSortable = dr.getParent().getParent().get("sortable");
  632. var pre = dr.getPrevious();
  633. if(pre && pre.get("class")=="taskItemInsertLine") {
  634. //alert("taskid="+taskId+",taskInId="+taskInId+",taskgroupFromid="+taskGroupFromId+",taskGroupInId="+taskGroupInId);
  635. if(taskGroupInSortable == "false"){
  636. //未分类视图不允许移入,还原并删除el对象
  637. _self.app.notice("未分类列表不允许移入","error");
  638. taskItemContainer.setStyles({"border":"1px solid #e6e6e6","opacity":"1"});
  639. if(pre && pre.get("class")=="taskItemInsertLine"){
  640. pre.destroy();
  641. el.destroy();
  642. }
  643. return ;
  644. }
  645. var data = {
  646. taskId:taskId,
  647. behindTaskId:taskInId
  648. };
  649. _self.actions.taskChangeGroup(taskGroupInId,data,function(json){
  650. if(json.type == "success"){ //返回成功后再换位置
  651. //fx fx2 动画clone到移入位置
  652. var fx = new Fx.Tween(el,{duration:time});
  653. fx.start(["top"] ,el.getPosition().y+"px", pre.getPosition().y+"px");
  654. var fx2 = new Fx.Tween(el,{duration:time});
  655. fx2.start(["left"] ,el.getPosition().x+"px", pre.getPosition().x+"px");
  656. //利用pre撑大高度
  657. pre.setStyles({"border":"0px","background-color":"#ffffff","height":(el.getHeight().toInt())+"px"});
  658. //var fx3 = new Fx.Tween(pre,{duration:time});
  659. //fx3.start(["height"] ,"0px", _height+"px");
  660. //新建一个占用原来位置
  661. var tmpdiv = taskItemContainer.clone();
  662. tmpdiv.setStyles({"border":"0px"});
  663. tmpdiv.empty();
  664. tmpdiv.inject(taskItemContainer,"before");
  665. //设置原有位置none
  666. taskItemContainer.setStyles({"display":"none"});
  667. //动画完成后插入真正的对象,恢复原位,并删除pre和clone
  668. window.setTimeout(function(){
  669. pre.destroy();
  670. taskItemContainer.setStyles({"border":"1px solid #e6e6e6","height":_height+"px","display":"block","opacity":"1"});
  671. taskItemContainer.inject(dr,"before");
  672. //fx4把临时占用的位置删除
  673. var fx4 = new Fx.Tween(tmpdiv,{duration:time});
  674. fx4.start(["height"] ,_height+"px", "0px");
  675. window.setTimeout(function(){
  676. if(tmpdiv) tmpdiv.destroy()
  677. },time);
  678. //删除clone即el对象
  679. el.destroy();
  680. },time);
  681. //刷新其他需要加载的位置,比如数量
  682. var taskGroupFrom = taskItemContainer.getParent().getParent();
  683. var taskGroupIn = dr.getParent().getParent();
  684. _self.actions.taskGroupGet(_self.currentProjectGroupData.id,taskGroupFromId,function(json){
  685. taskGroupFrom.getElement(".taskGroupItemTitleCount").set("text","("+json.data.taskCount +")")
  686. })
  687. _self.actions.taskGroupGet(_self.currentProjectGroupData.id,taskGroupInId,function(json){
  688. taskGroupIn.getElement(".taskGroupItemTitleCount").set("text","("+json.data.taskCount +")")
  689. })
  690. }else{
  691. //返回失败,还原并删除el对象
  692. taskItemContainer.setStyles({"border":"1px solid #e6e6e6","opacity":"1"});
  693. if(pre && pre.get("class")=="taskItemInsertLine"){
  694. pre.destroy();
  695. el.destroy();
  696. }
  697. }
  698. },function(xhr,text,error){
  699. _self.app.showErrorMessage(xhr,text,error);
  700. taskItemContainer.setStyles({"border":"1px solid #e6e6e6","opacity":"1"});
  701. if(pre && pre.get("class")=="taskItemInsertLine"){
  702. pre.destroy();
  703. el.destroy();
  704. }
  705. });
  706. }
  707. }
  708. }
  709. }
  710. });
  711. //传递鼠标事件e
  712. myDrag.start(e)
  713. }.bind(this)
  714. });
  715. }.bind(this));
  716. //最后加一行占位
  717. var emptyDrag = new Element("div.empty.dragin",{name:"item",styles:{
  718. "width":"100%",
  719. "height":"50px"
  720. }}).inject(taskGroupItemContainer);
  721. }.bind(this));
  722. },
  723. loadTaskNode:function(taskItemContainer,d){
  724. taskItemContainer.empty();
  725. var taskItemHover = new Element("div.taskItemHover",{styles:this.css.taskItemHover}).inject(taskItemContainer);
  726. if(d.priority == this.lp.urgency)taskItemHover.setStyle("background-color","#ffaf38");
  727. else if(d.priority == this.lp.emergency)taskItemHover.setStyle("background-color","#ff0000");
  728. var taskItemContent = new Element("div.taskItemContent",{styles:this.css.taskItemContent}).inject(taskItemContainer);
  729. var taskItemTitle = new Element("div.taskItemTitle",{styles:this.css.taskItemTitle,text:d.name}).inject(taskItemContent);
  730. taskItemHover.setStyles({"height":taskItemContainer.getHeight()});
  731. },
  732. openTask:function(id,callback){
  733. var data = {
  734. taskId:id
  735. };
  736. var opt = {
  737. "onPostClose":function(dd){
  738. if(!dd) return;
  739. if(dd.act == "remove"){
  740. if(callback){
  741. callback()
  742. }
  743. //this.createTaskGroup();
  744. }
  745. }.bind(this)
  746. };
  747. MWF.xDesktop.requireApp("TeamWork", "Task", function(){
  748. var task = new MWF.xApplication.TeamWork.Task(this,data,opt);
  749. task.open();
  750. }.bind(this));
  751. },
  752. openView:function(obj){
  753. this.naviTopMyTaskLayout.setStyles({"background-color":""});
  754. var _self = this;
  755. this.naviViewContainer.getElements(".naviItemContainer").each(function(d){
  756. this.naviItemChange(d,"leave")
  757. }.bind(this))
  758. this.naviItemChange(obj,"enter");
  759. if(this.viewContainer) delete this.viewContainer;
  760. if(this.viewListContainer) delete this.viewListContainer;
  761. this.taskContentLayout.empty();
  762. var viewContainer = this.viewContainer = new Element("div.viewContainer",{styles:this.css.viewContainer}).inject(this.taskContentLayout);
  763. viewContainer.addEvents({
  764. scroll:function(){
  765. var sTop = this.getScrollTop();
  766. var sHeight = this.getScrollHeight();
  767. var cHeight = viewContainer.getHeight();
  768. if(sHeight - sTop < cHeight+10){ //偏移量
  769. if(_self.viewLoading){
  770. _self.loadView(_self.curViewTaskId)
  771. }
  772. }
  773. }
  774. });
  775. var viewListContainer = this.viewListContainer = new Element("div.viewListContainer",{styles:this.css.viewListContainer}).inject(viewContainer);
  776. this.loadView()
  777. },
  778. openSearch:function(key){
  779. var _self = this;
  780. if(this.viewListContainer) delete this.viewListContainer;
  781. this.taskContentLayout.empty();
  782. var viewContainer = new Element("div.viewContainer",{styles:this.css.viewContainer}).inject(this.taskContentLayout);
  783. var viewListContainer = this.viewListContainer = new Element("div.viewListContainer",{styles:this.css.viewListContainer}).inject(viewContainer);
  784. //this.loadView()
  785. var data = {
  786. project:this.data.id,
  787. title:key
  788. };
  789. var tmpLoading = new Element("div.tmpLoading",{styles:{"background-color":"#ffffff"}}).inject(viewListContainer);
  790. this.app.setLoading(tmpLoading);
  791. this.searchLoading = false;
  792. this.actions.taskListNext("(0)",100,data,function(json){
  793. viewListContainer.empty();
  794. json.data.each(function(data){
  795. this.loadViewItem(data)
  796. }.bind(this));
  797. if(json.count==0){
  798. new Element("div.none",{styles:{
  799. "height":"100px",
  800. "line-height":"100px",
  801. "width":"100%",
  802. "text-align":"center",
  803. "background-color":"#ffffff",
  804. "font-size":"16px"
  805. },text:"未查找到数据"}).inject(this.viewListContainer);
  806. }
  807. this.searchLoading = true;
  808. }.bind(this))
  809. },
  810. loadView:function(id){
  811. this.viewListContainer.getElements(".viewNext").destroy();
  812. var data = {
  813. project:this.data.id
  814. };
  815. var tmpLoading = new Element("div.tmpLoading",{styles:{"background-color":"#ffffff"}}).inject(this.viewListContainer);
  816. this.app.setLoading(tmpLoading);
  817. this.viewLoading = false;
  818. this.actions.taskListNext(id||"(0)",10,data,function(json){
  819. this.viewListContainer.getElements(".tmpLoading").destroy();
  820. json.data.each(function(data){
  821. this.loadViewItem(data);
  822. this.curViewTaskId = data.id;
  823. }.bind(this));
  824. this.viewLoading = true;
  825. var sHeight = this.viewListContainer.getHeight();
  826. var cHeight = this.viewContainer.getHeight();
  827. if(sHeight<cHeight){
  828. var viewNext = new Element("div.viewNext",{styles:this.css.viewNext,text:"下一页"}).inject(this.viewListContainer);
  829. viewNext.addEvents({
  830. click:function(){
  831. this.loadView(this.curViewTaskId)
  832. }.bind(this)
  833. })
  834. }
  835. // if(sHeight - sTop < cHeight+10){ //偏移量
  836. // if(_self.viewLoading){
  837. // _self.loadView(_self.curViewTaskId)
  838. // }
  839. // }
  840. }.bind(this))
  841. },
  842. loadViewItem:function(data){
  843. var viewItem = new Element("div.viewItem",{styles:this.css.viewItem}).inject(this.viewListContainer);
  844. var viewName = new Element("div.viewName",{styles:this.css.viewName,text:data.name}).inject(viewItem);
  845. var viewStatus = new Element("div.viewStatus",{styles:this.css.viewStatus,text:data.priority}).inject(viewItem);
  846. var viewDuty = new Element("div.viewDuty",{styles:this.css.viewDuty}).inject(viewItem);
  847. var viewDutyIcon = new Element("div.viewDutyIcon",{styles:this.css.viewDutyIcon}).inject(viewDuty);
  848. if(data.executor && data.executor!=""){
  849. viewDutyIcon.set("text",data.executor.split("@")[0].substr(0,1));
  850. viewDutyIcon.set("title",data.executor.split("@")[0])
  851. }
  852. viewItem.addEvents({
  853. mouseover:function(){ this.setStyles({"background-color":"#F2F5F7"}) },
  854. mouseout:function(){ this.setStyles({"background-color":"#ffffff"}) },
  855. click:function(){
  856. this.openTask(data.id,function(){ viewItem.destroy() }.bind(this))
  857. }.bind(this)
  858. })
  859. },
  860. createStatLayout:function(){
  861. MWF.xDesktop.requireApp("TeamWork", "Stat", function(){
  862. var stat = new MWF.xApplication.TeamWork.Stat(this.contentLayout,this.app,this.data,{
  863. }
  864. );
  865. stat.load();
  866. }.bind(this));
  867. },
  868. test:function(){
  869. }
  870. });
  871. MWF.xApplication.TeamWork.Project.NewTask = new Class({
  872. Extends: MPopupForm,
  873. options : {
  874. "style": "default",
  875. "width": 400,
  876. "height": 250,
  877. "top": null,
  878. "left": null,
  879. "bottom" : null,
  880. "right" : null,
  881. "minWidth" : 300,
  882. "minHeight" : 220,
  883. "closeByClickMask" : true,
  884. "hasTopContent" : true,
  885. "hasTop":true,
  886. "hasBottom": false,
  887. "hasIcon": false,
  888. "title":""
  889. },
  890. _createTableContent:function(){
  891. if(this.formTopTextNode) this.formTopTextNode.set("text",this.lp.newTaskTitle);
  892. //this.formTableArea
  893. this.titleContainer = new Element("div.titleContainer",{styles:this.css.titleContainer}).inject(this.formTableArea);
  894. this.titleValue = new Element("input.titleValue",{styles:this.css.titleValue,placeholder:this.lp.newTaskPlaceholder}).inject(this.titleContainer);
  895. this.actionContainer = new Element("div.actionContainer",{styles:this.css.actionContainer}).inject(this.formTableArea);
  896. this.okAction = new Element("div.okAction",{styles:this.css.okAction,text:this.lp.newTaskOk}).inject(this.actionContainer);
  897. this.okAction.addEvents({
  898. click:function(){
  899. if(this.titleValue.get("value").trim()=="") return;
  900. var data={
  901. taskGroupId:this.data.taskGroupId,
  902. taskListIds:this.data.taskListIds || [],
  903. name: this.titleValue.get("value").trim()
  904. };
  905. this.actions.taskSave(data,function(json){
  906. if(json.data.id){
  907. var data = {
  908. projectObj:this.data.projectObj || null,
  909. taskId:json.data.id
  910. };
  911. var opt = {
  912. };
  913. MWF.xDesktop.requireApp("TeamWork", "Task", function(){
  914. var task = new MWF.xApplication.TeamWork.Task(this,data,opt);
  915. task.open();
  916. }.bind(this));
  917. this.fireEvent("createTask");
  918. this.close();
  919. }
  920. }.bind(this))
  921. }.bind(this)
  922. });
  923. this.closeAction = new Element("div.closeAction",{styles:this.css.closeAction,text:this.lp.newTaskClose}).inject(this.actionContainer);
  924. this.closeAction.addEvents({
  925. click:function(){
  926. this.close();
  927. }.bind(this)
  928. });
  929. }
  930. });
  931. MWF.xApplication.TeamWork.Project.NewTaskGroup = new Class({
  932. Extends: MPopupForm,
  933. options : {
  934. "style": "default",
  935. "width": 400,
  936. "height": 250,
  937. "top": null,
  938. "left": null,
  939. "bottom" : null,
  940. "right" : null,
  941. "minWidth" : 300,
  942. "minHeight" : 220,
  943. "closeByClickMask" : true,
  944. "hasTopContent" : true,
  945. "hasTop":true,
  946. "hasBottom": false,
  947. "hasIcon": false,
  948. "title":""
  949. },
  950. _createTableContent:function(){
  951. this.explorer = this.data.projectObj;
  952. if(this.formTopTextNode) this.formTopTextNode.set("text",this.data.isNew?this.lp.taskGroupAdd:this.lp.taskGroupEdit);
  953. //this.formTableArea
  954. this.titleContainer = new Element("div.titleContainer",{styles:this.css.titleContainer}).inject(this.formTableArea);
  955. this.titleValue = new Element("input.titleValue",{styles:this.css.titleValue,placeholder:this.lp.newTaskPlaceholder}).inject(this.titleContainer);
  956. var val = this.data.isNew?"":this.data.name;
  957. this.titleValue.set("value",val);
  958. this.actionContainer = new Element("div.actionContainer",{styles:this.css.actionContainer}).inject(this.formTableArea);
  959. this.okAction = new Element("div.okAction",{styles:this.css.okAction,text:this.lp.newTaskOk}).inject(this.actionContainer);
  960. this.okAction.addEvents({
  961. click:function(){
  962. if(this.titleValue.get("value").trim()=="") return;
  963. var data={
  964. id:this.data.id || "",
  965. taskGroup:this.data.taskGroupId,
  966. project:this.data.projectId,
  967. name: this.titleValue.get("value").trim()
  968. };
  969. this.actions.taskGroupSave(data,function(json){
  970. this.fireEvent("createTask");
  971. this.close(json);
  972. if(this.explorer){
  973. if(this.data.node){
  974. if(json.data.id){
  975. this.actions.taskGroupGet(this.explorer.currentProjectGroupData.id,json.data.id,function(json){
  976. this.explorer.createTaskGroupItemLayout(this.data.node,json.data)
  977. }.bind(this));
  978. }else{
  979. this.explorer.createTaskGroup()
  980. }
  981. }else{
  982. this.explorer.createTaskGroup()
  983. }
  984. }
  985. }.bind(this))
  986. }.bind(this)
  987. });
  988. this.closeAction = new Element("div.closeAction",{styles:this.css.closeAction,text:this.lp.newTaskClose}).inject(this.actionContainer);
  989. this.closeAction.addEvents({
  990. click:function(){
  991. this.close();
  992. }.bind(this)
  993. });
  994. }
  995. });
  996. MWF.xApplication.TeamWork.Project.TaskGroupMenu = new Class({
  997. Extends: MWF.xApplication.TeamWork.Common.ToolTips,
  998. options : {
  999. // displayDelay : 300,
  1000. hasArrow:false,
  1001. event:"click"
  1002. },
  1003. _loadCustom : function( callback ){
  1004. var _self = this;
  1005. this.css = this.options.css;
  1006. this.lp = this.options.lp;
  1007. //this.data
  1008. this.menuTipLayout = new Element("div.menuTipLayout",{styles:this.css.menuTipLayout}).inject(this.contentNode);
  1009. this.menuTipTitle = new Element("div.menuTipTitle",{styles:this.css.menuTipTitle,text:this.lp.taskGroup}).inject(this.menuTipLayout);
  1010. this.menuTipEditContainer = new Element("div.menuTipContainer",{styles:this.css.menuTipContainer}).inject(this.menuTipLayout);
  1011. this.menuTipEditIcon = new Element("div.menuTipEditIcon",{styles:this.css.menuTipEditIcon}).inject(this.menuTipEditContainer);
  1012. this.menuTipEditText = new Element("div.menuTipEditText",{styles:this.css.menuTipText,text:this.lp.taskGroupEdit}).inject(this.menuTipEditContainer);
  1013. this.menuTipEditContainer.addEvents({
  1014. click:function(){
  1015. var data = this.data;
  1016. data.isNew = false;
  1017. var opt = {
  1018. };
  1019. var newTaskGroup = new MWF.xApplication.TeamWork.Project.NewTaskGroup(this,data,opt,{});
  1020. newTaskGroup.open();
  1021. this.close();
  1022. }.bind(this),
  1023. mouseover:function(){this.setStyles({"background-color":"#F7F7F7"})},
  1024. mouseout:function(){this.setStyles({"background-color":""})}
  1025. });
  1026. this.menuTipRemoveContainer = new Element("div.menuTipContainer",{styles:this.css.menuTipContainer}).inject(this.menuTipLayout);
  1027. this.menuTipRemoveIcon = new Element("div.menuTipRemoveIcon",{styles:this.css.menuTipRemoveIcon}).inject(this.menuTipRemoveContainer);
  1028. this.menuTipRemoveText = new Element("div.menuTipRemoveText",{styles:this.css.menuTipText,text:this.lp.taskGroupRemove}).inject(this.menuTipRemoveContainer);
  1029. this.menuTipRemoveContainer.addEvents({
  1030. click:function(e){
  1031. _self.app.confirm("warn",e,_self.app.lp.common.confirm.removeTitle,_self.app.lp.common.confirm.removeContent,300,120,function(){
  1032. if(_self.data.id){
  1033. _self.actions.taskGroupDelete(_self.data.id,function(json){
  1034. this.close();
  1035. _self.close(json)
  1036. }.bind(this))
  1037. }
  1038. },function(){
  1039. this.close();
  1040. });
  1041. }.bind(this),
  1042. mouseover:function(){this.setStyles({"background-color":"#F7F7F7"})},
  1043. mouseout:function(){this.setStyles({"background-color":""})}
  1044. });
  1045. if(callback)callback();
  1046. }
  1047. });
  1048. MWF.xApplication.TeamWork.Project.NaviViewTip = new Class({
  1049. Extends: MWF.xApplication.TeamWork.Common.ToolTips,
  1050. options : {
  1051. // displayDelay : 300,
  1052. hasArrow:false,
  1053. event:"click"
  1054. },
  1055. _loadCustom : function( callback ){
  1056. var _self = this;
  1057. this.css = this.options.css;
  1058. this.lp = this.options.lp;
  1059. //this.data
  1060. this.menuTipLayout = new Element("div.menuTipLayout",{styles:this.css.menuTipLayout}).inject(this.contentNode);
  1061. this.menuTipTitle = new Element("div.menuTipTitle",{styles:this.css.menuTipTitle,text:this.lp.view}).inject(this.menuTipLayout);
  1062. this.menuTipEditContainer = new Element("div.menuTipContainer",{styles:this.css.menuTipContainer}).inject(this.menuTipLayout);
  1063. this.menuTipEditIcon = new Element("div.menuTipEditIcon",{styles:this.css.menuTipEditIcon}).inject(this.menuTipEditContainer);
  1064. this.menuTipEditText = new Element("div.menuTipEditText",{styles:this.css.menuTipText,text:this.lp.viewEdit}).inject(this.menuTipEditContainer);
  1065. this.menuTipEditContainer.addEvents({
  1066. click:function(){
  1067. }.bind(this),
  1068. mouseover:function(){this.setStyles({"background-color":"#F7F7F7"})},
  1069. mouseout:function(){this.setStyles({"background-color":""})}
  1070. });
  1071. this.menuTipRemoveContainer = new Element("div.menuTipContainer",{styles:this.css.menuTipContainer}).inject(this.menuTipLayout);
  1072. this.menuTipRemoveIcon = new Element("div.menuTipRemoveIcon",{styles:this.css.menuTipRemoveIcon}).inject(this.menuTipRemoveContainer);
  1073. this.menuTipRemoveText = new Element("div.menuTipRemoveText",{styles:this.css.menuTipText,text:this.lp.viewRemove}).inject(this.menuTipRemoveContainer);
  1074. this.menuTipRemoveContainer.addEvents({
  1075. click:function(e){
  1076. _self.app.confirm("warn",e,_self.app.lp.common.confirm.removeTitle,_self.app.lp.common.confirm.removeContent,300,120,function(){
  1077. },function(){
  1078. this.close();
  1079. });
  1080. }.bind(this),
  1081. mouseover:function(){this.setStyles({"background-color":"#F7F7F7"})},
  1082. mouseout:function(){this.setStyles({"background-color":""})}
  1083. });
  1084. if(callback)callback();
  1085. }
  1086. });
  1087. MWF.xApplication.TeamWork.Project.ProjectList = new Class({
  1088. Extends: MWF.xApplication.TeamWork.Common.ToolTips,
  1089. options : {
  1090. // displayDelay : 300,
  1091. hasArrow:false,
  1092. event:"click"
  1093. },
  1094. _loadCustom : function(callback){
  1095. var _self = this;
  1096. this.css = this.options.css;
  1097. this.lp = this.options.lp;
  1098. //this.data
  1099. //this.contentNode
  1100. this.itemLayout = new Element("div.itemLayout",{styles:this.css.itemLayout}).inject(this.contentNode);
  1101. this.app.setLoading(this.itemLayout);
  1102. this.actions.projectStarListNext("(0)",100,{},function(json){
  1103. this.app.setScrollBar(this.itemLayout);
  1104. this.itemLayout.empty();
  1105. if(json.data && json.data.length>0){
  1106. this.starText = new Element("div.starText",{styles:this.css.itemText,text:this.lp.starItem}).inject(this.itemLayout);
  1107. json.data.each(function(data){
  1108. var projectListContainer = new Element("div.projectListContainer",{styles:this.css.projectListContainer}).inject(this.itemLayout);
  1109. var projectListIcon = new Element("div.projectListIcon",{styles:this.css.projectListIcon}).inject(projectListContainer);
  1110. if(data.icon && data.icon!=""){
  1111. projectListIcon.setStyles({"background-image":"url('"+MWF.xDesktop.getImageSrc( data.icon )+"')"});
  1112. }
  1113. new Element("div.projectListText",{styles:this.css.projectListText,text:data.title}).inject(projectListContainer);
  1114. if(this.data.id == data.id){
  1115. new Element("div.projectListSelect",{styles:this.css.projectListSelect}).inject(projectListContainer);
  1116. }
  1117. projectListContainer.addEvents({
  1118. click:function(){
  1119. MWF.xDesktop.requireApp("TeamWork", "Project", function(){
  1120. var p = new MWF.xApplication.TeamWork.Project(this.container,this.app,data,{});
  1121. p.load();
  1122. }.bind(this));
  1123. }.bind(this),
  1124. mouseover:function () { this.setStyles({"background-color":"#F2F5F7"})},
  1125. mouseout:function () { this.setStyles({"background-color":""})}
  1126. });
  1127. }.bind(this))
  1128. }
  1129. var tmpContainer = new Element("div.tmpContainer").inject(this.itemLayout);
  1130. this.app.setLoading(tmpContainer);
  1131. this.actions.projectListNext("(0)",100,{},function(json){
  1132. tmpContainer.destroy();
  1133. this.allItemText = new Element("div.allItemText",{styles:this.css.itemText,text:this.lp.allItem}).inject(this.itemLayout);
  1134. json.data.each(function(data){
  1135. var projectListContainer = new Element("div.projectListContainer",{styles:this.css.projectListContainer}).inject(this.itemLayout);
  1136. var projectListIcon = new Element("div.projectListIcon",{styles:this.css.projectListIcon}).inject(projectListContainer);
  1137. if(data.icon && data.icon!=""){
  1138. projectListIcon.setStyles({"background-image":"url('"+MWF.xDesktop.getImageSrc( data.icon )+"')"});
  1139. }
  1140. new Element("div.projectListText",{styles:this.css.projectListText,text:data.title}).inject(projectListContainer);
  1141. if(this.data.id == data.id){
  1142. new Element("div.projectListSelect",{styles:this.css.projectListSelect}).inject(projectListContainer);
  1143. }
  1144. projectListContainer.addEvents({
  1145. click:function(){
  1146. MWF.xDesktop.requireApp("TeamWork", "Project", function(){
  1147. var p = new MWF.xApplication.TeamWork.Project(this.container,this.app,data,{});
  1148. p.load();
  1149. }.bind(this));
  1150. }.bind(this),
  1151. mouseover:function () { this.setStyles({"background-color":"#F2F5F7"})},
  1152. mouseout:function () { this.setStyles({"background-color":""})}
  1153. });
  1154. }.bind(this));
  1155. }.bind(this))
  1156. }.bind(this));
  1157. if(callback)callback();
  1158. }
  1159. });