Project.js 65 KB

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