TabMenu.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.gantt.TabMenu"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.gantt.TabMenu"] = true;
  8. dojo.provide("dojox.gantt.TabMenu");
  9. dojo.require("dijit.dijit");
  10. dojo.require("dijit.Menu");
  11. dojo.require("dijit.Dialog");
  12. dojo.require("dijit.form.NumberSpinner");
  13. dojo.require("dijit.form.Button");
  14. dojo.require("dijit.form.CheckBox");
  15. dojo.require("dijit.form.DateTextBox");
  16. dojo.require("dijit.form.TimeTextBox");
  17. dojo.require("dojo.date.locale");
  18. dojo.require("dijit.form.Form");
  19. dojo.require("dojo.parser");
  20. (function(){
  21. dojo.declare("dojox.gantt.TabMenu", null, {
  22. constructor: function(chart){
  23. this.ganttChart = chart;
  24. this.menuPanel = null;
  25. this.paneContentArea = null;
  26. this.paneActionBar = null;
  27. this.tabPanelDlg = null;
  28. this.tabPanelDlgId = null;
  29. this.arrTabs = [];
  30. this.isShow = false;
  31. this.buildContent();
  32. },
  33. buildContent: function(){
  34. this.createMenuPanel();
  35. this.createTabPanel();
  36. //tasks customization
  37. var taskSucAdd = this.createTab(11, "Add Successor Task", "t", true, this);
  38. taskSucAdd.addItem(1, "Id", "id", true);
  39. taskSucAdd.addItem(2, "Name", "name");
  40. taskSucAdd.addItem(3, "Start Time", "startTime");
  41. taskSucAdd.addItem(4, "Duration (hours)", "duration");
  42. taskSucAdd.addItem(5, "Percent Complete (%)", "percentage");
  43. taskSucAdd.addItem(6, "Task Assignee", "taskOwner");
  44. taskSucAdd.addAction("addSuccessorTaskAction");
  45. var taskChildAdd = this.createTab(10, "Add Child Task", "t", true, this);
  46. taskChildAdd.addItem(1, "Id", "id", true);
  47. taskChildAdd.addItem(2, "Name", "name");
  48. taskChildAdd.addItem(3, "Start Time", "startTime");
  49. taskChildAdd.addItem(4, "Duration (hours)", "duration");
  50. taskChildAdd.addItem(5, "Percent Complete (%)", "percentage");
  51. taskChildAdd.addItem(6, "Task Assignee", "taskOwner");
  52. taskChildAdd.addAction("addChildTaskAction");
  53. var taskDuration = this.createTab(4, "Set Duration(hours)", "t", true, this, true);
  54. taskDuration.addItem(1, "Duration (hours)", "duration", true);
  55. taskDuration.addAction("durationUpdateAction");
  56. var taskCP = this.createTab(5, "Set Complete Percentage (%)", "t", true, this, true);
  57. taskCP.addItem(1, "Percent Complete (%)", "percentage", true);
  58. taskCP.addAction("cpUpdateAction");
  59. var taskOwner = this.createTab(20, "Set Owner", "t", true, this, true);
  60. taskOwner.addItem(1, "Task Assignee", "taskOwner", true);
  61. taskOwner.addAction("ownerUpdateAction");
  62. var taskPrevious = this.createTab(13, "Set Previous Task", "t", true, this);
  63. taskPrevious.addItem(1, "Previous Task Id", "previousTaskId", true);
  64. taskPrevious.addAction("ptUpdateAction");
  65. var taskRename = this.createTab(1, "Rename Task", "t", true, this, true);
  66. taskRename.addItem(1, "New Name", "name", true);
  67. taskRename.addAction("renameTaskAction");
  68. var taskDelete = this.createTab(2, "Delete Task", "t", true, this);
  69. taskDelete.addAction("deleteAction");
  70. //projects customization
  71. var projectAdd = this.createTab(12, "Add New Project", "p", false, this);
  72. projectAdd.addItem(1, "Id", "id", true);
  73. projectAdd.addItem(2, "Name", "name", true);
  74. projectAdd.addItem(3, "Start Date", "startDate", true);
  75. projectAdd.addAction("addProjectAction");
  76. var projectCP = this.createTab(8, "Set Complete Percentage (%)", "p", true, this, true);
  77. projectCP.addItem(1, "Percent Complete (%)", "percentage", true);
  78. projectCP.addAction("cpProjectAction");
  79. var projectRename = this.createTab(6, "Rename Project", "p", true, this, true);
  80. projectRename.addItem(1, "New Name", "name", true);
  81. projectRename.addAction("renameProjectAction");
  82. var projectDelete = this.createTab(7, "Delete Project", "p", true, this);
  83. projectDelete.addAction("deleteProjectAction");
  84. //task relative
  85. var projectTaskAdd = this.createTab(9, "Add New Task", "p", true, this);
  86. projectTaskAdd.addItem(1, "Id", "id", true);
  87. projectTaskAdd.addItem(2, "Name", "name");
  88. projectTaskAdd.addItem(3, "Start Time", "startTime");
  89. projectTaskAdd.addItem(4, "Duration (hours)", "duration");
  90. projectTaskAdd.addItem(5, "Percent Complete (%)", "percentage");
  91. projectTaskAdd.addItem(6, "Task Assignee", "taskOwner");
  92. projectTaskAdd.addItem(7, "Parent Task Id", "parentTaskId");
  93. projectTaskAdd.addItem(8, "Previous Task Id", "previousTaskId");
  94. projectTaskAdd.addAction("addTaskAction");
  95. },
  96. createMenuPanel: function(){
  97. this.menuPanel = dojo.create("div", {
  98. innerHTML: "<table></table>",
  99. className: "ganttMenuPanel"
  100. }, this.ganttChart.content);
  101. dojo.addClass(this.menuPanel.firstChild, "ganttContextMenu");
  102. this.menuPanel.firstChild.cellPadding = 0;
  103. this.menuPanel.firstChild.cellSpacing = 0;
  104. },
  105. createTabPanel: function(){
  106. this.tabPanelDlg = dijit.byId(this.tabPanelDlgId) ||
  107. new dijit.Dialog({
  108. title: "Settings"
  109. });
  110. this.tabPanelDlgId = this.tabPanelDlg.id;
  111. this.tabPanelDlg.closeButtonNode.style.display = "none";
  112. var tabPanel = this.tabPanelDlg.containerNode;
  113. this.paneContentArea = dojo.create("div", {className: "dijitDialogPaneContentArea"}, tabPanel);
  114. this.paneActionBar = dojo.create("div", {className: "dijitDialogPaneActionBar"}, tabPanel);
  115. this.paneContentArea.innerHTML = "<table cellpadding=0 cellspacing=0><tr><th></th></tr><tr><td></td></tr></table>";
  116. var headerCell = this.paneContentArea.firstChild.rows[0].cells[0];
  117. headerCell.colSpan = 2;
  118. headerCell.innerHTML = "Description: ";
  119. dojo.addClass(headerCell, "ganttDialogContentHeader");
  120. var contentCell = this.paneContentArea.firstChild.rows[1].cells[0];
  121. contentCell.innerHTML = "<table></table>";
  122. dojo.addClass(contentCell.firstChild, "ganttDialogContentCell");
  123. contentCell.align = "center";
  124. this.ok = new dijit.form.Button({label: "OK"});
  125. this.cancel = new dijit.form.Button({label: "Cancel"});
  126. this.paneActionBar.appendChild(this.ok.domNode);
  127. this.paneActionBar.appendChild(this.cancel.domNode);
  128. },
  129. addItemMenuPanel: function(tab){
  130. var row = this.menuPanel.firstChild.insertRow(this.menuPanel.firstChild.rows.length);
  131. var cell = dojo.create("td", {
  132. className: "ganttContextMenuItem",
  133. innerHTML: tab.Description
  134. });
  135. dojo.attr(cell, "tabIndex", 0);
  136. this.ganttChart._events.push(
  137. dojo.connect(cell, "onclick", this, function(){
  138. try{
  139. this.hide();
  140. tab.show();
  141. }catch(e){
  142. console.log("dialog open exception: " + e.message);
  143. }
  144. })
  145. );
  146. this.ganttChart._events.push(
  147. dojo.connect(cell, "onkeydown", this, function(e){
  148. if(e.keyCode != dojo.keys.ENTER){return;}
  149. try{
  150. this.hide();
  151. tab.show();
  152. }catch(e){
  153. console.log("dialog open exception: " + e.message);
  154. }
  155. })
  156. );
  157. this.ganttChart._events.push(
  158. dojo.connect(cell, "onmouseover", this, function(){
  159. dojo.addClass(cell, "ganttContextMenuItemHover");
  160. })
  161. );
  162. this.ganttChart._events.push(
  163. dojo.connect(cell, "onmouseout", this, function(){
  164. dojo.removeClass(cell, "ganttContextMenuItemHover");
  165. })
  166. );
  167. row.appendChild(cell);
  168. },
  169. show: function(elem, object){
  170. if(object.constructor == dojox.gantt.GanttTaskControl){
  171. dojo.forEach(this.arrTabs, function(tab){
  172. if(tab.type == "t"){
  173. tab.object = object;
  174. this.addItemMenuPanel(tab);
  175. }
  176. }, this);
  177. }else if(object.constructor == dojox.gantt.GanttProjectControl){
  178. dojo.forEach(this.arrTabs, function(tab){
  179. if(tab.type == "p"){
  180. tab.object = object;
  181. this.addItemMenuPanel(tab);
  182. }
  183. }, this);
  184. }
  185. this.isShow = true;
  186. dojo.style(this.menuPanel, {
  187. zIndex: 15,
  188. visibility: "visible"
  189. });
  190. //make sure menu box inside gantt's bounding box
  191. var menuBox = dojo.position(this.menuPanel, true),
  192. bBox = dojo.position(this.ganttChart.content, true),
  193. pos = dojo.coords(elem, true);
  194. if((pos.y + menuBox.h) > (bBox.y + bBox.h + 50)){
  195. this.menuPanel.style.top = pos.y - menuBox.h + pos.h + "px";
  196. }else{
  197. this.menuPanel.style.top = pos.y + "px";
  198. }
  199. if(dojo._isBodyLtr()){
  200. this.menuPanel.style.left = pos.x + pos.w + 5 + "px";
  201. }else{
  202. this.menuPanel.style.left = pos.x - menuBox.w - 5 + "px";
  203. }
  204. },
  205. hide: function(){
  206. this.isShow = false;
  207. this.menuPanel.style.visibility = "hidden";
  208. },
  209. clear: function(){
  210. this.menuPanel.removeChild(this.menuPanel.firstChild);
  211. this.menuPanel.innerHTML = "<table></table>";
  212. dojo.addClass(this.menuPanel.firstChild, "ganttContextMenu");
  213. this.menuPanel.firstChild.cellPadding = 0;
  214. this.menuPanel.firstChild.cellSpacing = 0;
  215. },
  216. createTab: function(id, desc, type, showOInfo, menu, withDefaultValue){
  217. var tab = new dojox.gantt.contextMenuTab(id, desc, type, showOInfo, menu, withDefaultValue);
  218. this.arrTabs.push(tab);
  219. return tab;
  220. }
  221. });
  222. dojo.declare("dojox.gantt.contextMenuTab", null, {
  223. constructor: function(id, description, type, showOInfo, tabMenu, withDefaultValue){
  224. this.id = id;
  225. this.arrItems = [];
  226. this.TabItemContainer = null;
  227. this.Description = description;
  228. this.tabMenu = tabMenu;
  229. this.type = type;
  230. this.object = null;
  231. this.showObjectInfo = showOInfo;
  232. this.withDefaultValue = withDefaultValue;
  233. },
  234. preValueValidation: function(items){
  235. for(var i = 0; i < items.length; i++){
  236. var item = items[i];
  237. //TODO add more validation for Id, Name, .....
  238. if(item.required && !item.control.textbox.value){
  239. return false;
  240. }
  241. }
  242. return true;
  243. },
  244. encodeDate: function(date){
  245. return date.getFullYear() + "." + (date.getMonth() + 1) + "." + date.getDate();
  246. },
  247. decodeDate: function(dateStr){
  248. var arr = dateStr.split(".");
  249. return (arr.length < 3) ? "" : (new Date(arr[0], parseInt(arr[1]) - 1, arr[2]));
  250. },
  251. renameTaskAction: function(){
  252. var name = this.arrItems[0].control.textbox.value;
  253. if(dojo.trim(name).length <= 0){
  254. return;
  255. }
  256. if(!this.preValueValidation(this.arrItems)){
  257. return;
  258. }
  259. this.object.setName(name);
  260. this.hide();
  261. },
  262. deleteAction: function(){
  263. if(!this.preValueValidation(this.arrItems)){
  264. return;
  265. }
  266. this.object.project.deleteTask(this.object.taskItem.id);
  267. this.hide();
  268. this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
  269. },
  270. durationUpdateAction: function(){
  271. var d = this.arrItems[0].control.textbox.value;
  272. if(!this.preValueValidation(this.arrItems)){
  273. return;
  274. }
  275. if(this.object.setDuration(d)){
  276. this.hide();
  277. }else{
  278. alert("Duration out of Range");
  279. return;
  280. }
  281. this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.refresh();
  282. },
  283. cpUpdateAction: function(){
  284. var p = this.arrItems[0].control.textbox.value;
  285. if(!this.preValueValidation(this.arrItems)){
  286. return;
  287. }
  288. if(this.object.setPercentCompleted(p)){
  289. this.hide();
  290. }else{
  291. alert("Complete Percentage out of Range");
  292. return;
  293. }
  294. },
  295. ownerUpdateAction: function(){
  296. var to = this.arrItems[0].control.textbox.value;
  297. if(!this.preValueValidation(this.arrItems)){
  298. return;
  299. }
  300. if(this.object.setTaskOwner(to)){
  301. this.hide();
  302. }else{
  303. alert("Task owner not Valid");
  304. return;
  305. }
  306. this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
  307. },
  308. ptUpdateAction: function(){
  309. var p = this.arrItems[0].control.textbox.value;
  310. if(!this.preValueValidation(this.arrItems)){
  311. return;
  312. }
  313. if(this.object.setPreviousTask(p)){
  314. this.hide();
  315. }else{
  316. alert("Please verify the Previous Task (" + p + ") and adjust its Time Range");
  317. return;
  318. }
  319. },
  320. renameProjectAction: function(){
  321. var name = this.arrItems[0].control.textbox.value;
  322. if(dojo.trim(name).length <= 0){
  323. return;
  324. }
  325. if(!this.preValueValidation(this.arrItems)){
  326. return;
  327. }
  328. this.object.setName(name);
  329. this.hide();
  330. },
  331. deleteProjectAction: function(){
  332. if(!this.preValueValidation(this.arrItems)){
  333. return;
  334. }
  335. this.object.ganttChart.deleteProject(this.object.project.id);
  336. this.hide();
  337. this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
  338. },
  339. cpProjectAction: function(){
  340. var p = this.arrItems[0].control.textbox.value;
  341. if(!this.preValueValidation(this.arrItems)){
  342. return;
  343. }
  344. if(this.object.setPercentCompleted(p)){
  345. this.hide();
  346. }else{
  347. alert("Percentage not Acceptable");
  348. return;
  349. }
  350. },
  351. addTaskAction: function(){
  352. if(!this.preValueValidation(this.arrItems)){
  353. return;
  354. }
  355. var id = this.arrItems[0].control.textbox.value,
  356. name = this.arrItems[1].control.textbox.value,
  357. startTime = this.decodeDate(this.arrItems[2].control.textbox.value),
  358. duration = this.arrItems[3].control.textbox.value,
  359. pc = this.arrItems[4].control.textbox.value,
  360. owner = this.arrItems[5].control.textbox.value,
  361. parentTaskId = this.arrItems[6].control.textbox.value,
  362. predTaskId = this.arrItems[7].control.textbox.value;
  363. if(dojo.trim(id).length <= 0){
  364. return;
  365. }
  366. if(this.object.insertTask(id, name, startTime, duration, pc, predTaskId, owner, parentTaskId)){
  367. this.hide();
  368. }else{
  369. alert("Please adjust your Customization");
  370. return;
  371. }
  372. this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
  373. },
  374. addSuccessorTaskAction: function(){
  375. if(!this.preValueValidation(this.arrItems)){
  376. return;
  377. }
  378. var pr = this.object.project,
  379. id = this.arrItems[0].control.textbox.value,
  380. name = this.arrItems[1].control.textbox.value,
  381. startTime = this.decodeDate(this.arrItems[2].control.textbox.value),
  382. duration = this.arrItems[3].control.textbox.value,
  383. pc = this.arrItems[4].control.textbox.value,
  384. owner = this.arrItems[5].control.textbox.value;
  385. if(dojo.trim(id).length <= 0){
  386. return;
  387. }
  388. var parentTaskId = !this.object.parentTask ? "" : this.object.parentTask.taskItem.id;
  389. var predTaskId = this.object.taskItem.id;
  390. if(pr.insertTask(id, name, startTime, duration, pc, predTaskId, owner, parentTaskId)){
  391. this.hide();
  392. }else{
  393. alert("Please adjust your Customization");
  394. return;
  395. }
  396. this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
  397. },
  398. addChildTaskAction: function(){
  399. if(!this.preValueValidation(this.arrItems)){
  400. return;
  401. }
  402. var pr = this.object.project,
  403. id = this.arrItems[0].control.textbox.value,
  404. name = this.arrItems[1].control.textbox.value,
  405. startTime = this.decodeDate(this.arrItems[2].control.textbox.value),
  406. duration = this.arrItems[3].control.textbox.value,
  407. pc = this.arrItems[4].control.textbox.value,
  408. owner = this.arrItems[5].control.textbox.value,
  409. parentTaskId = this.object.taskItem.id,
  410. predTaskId = "";
  411. if(dojo.trim(id).length <= 0){
  412. return;
  413. }
  414. if(pr.insertTask(id, name, startTime, duration, pc, predTaskId, owner, parentTaskId)){
  415. this.hide();
  416. }else{
  417. alert("Please adjust your Customization");
  418. return;
  419. }
  420. this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
  421. },
  422. addProjectAction: function(){
  423. if(!this.preValueValidation(this.arrItems)){
  424. return;
  425. }
  426. var id = this.arrItems[0].control.textbox.value,
  427. namePr = this.arrItems[1].control.textbox.value,
  428. startDatePr = this.decodeDate(this.arrItems[2].control.textbox.value);
  429. if(dojo.trim(id).length <= 0 || dojo.trim(namePr).length <= 0){
  430. return;
  431. }
  432. if(this.tabMenu.ganttChart.insertProject(id, namePr, startDatePr)){
  433. this.hide();
  434. }else{
  435. alert("Please adjust your Customization");
  436. return;
  437. }
  438. this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
  439. },
  440. addAction: function(handler){
  441. this.actionFunc = this[handler];
  442. },
  443. addItem: function(id, name, key, required){
  444. var inputControl;
  445. if(key == "startTime" || key == "startDate"){
  446. inputControl = new dijit.form.DateTextBox({type:"text", constraints:{datePattern:"yyyy.M.d", strict:true}});
  447. }else if(key == "percentage"){
  448. inputControl = new dijit.form.NumberSpinner({ constraints:{ max:100, min:0 }});
  449. }else if(key == "duration"){
  450. inputControl = new dijit.form.NumberSpinner({ constraints:{ min:0 }});
  451. }else{
  452. inputControl = new dijit.form.TextBox();
  453. }
  454. this.arrItems.push({
  455. id: id,
  456. name: name,
  457. control: inputControl,
  458. tab: this,
  459. key: key,
  460. required: required
  461. });
  462. },
  463. show: function(){
  464. this.tabMenu.tabPanelDlg = this.tabMenu.tabPanelDlg || dijit.byId(this.tabMenu.tabPanelDlgId) ||
  465. new dijit.Dialog({
  466. title: "Settings"
  467. });
  468. try{
  469. this.tabMenu.tabPanelDlg.show();
  470. }catch(e){
  471. console.log("dialog show exception: " + e.message);
  472. return;
  473. }
  474. this.tabMenu.tabPanelDlg.titleNode.innerHTML = this.Description;
  475. var content = this.tabMenu.paneContentArea.firstChild.rows[1].cells[0].firstChild,
  476. action = this.tabMenu.paneActionBar;
  477. var cell, cellValue, row = null;
  478. if(this.showObjectInfo){
  479. if(this.object){
  480. if(this.object.constructor == dojox.gantt.GanttTaskControl){
  481. this.insertData(content, "Id", this.object.taskItem.id);
  482. this.insertData(content, "Name", this.object.taskItem.name);
  483. this.insertData(content, "Start Time", this.encodeDate(this.object.taskItem.startTime));
  484. this.insertData(content, "Duration (hours)", this.object.taskItem.duration + " hours");
  485. this.insertData(content, "Percent Complete (%)", this.object.taskItem.percentage + "%");
  486. this.insertData(content, "Task Assignee", this.object.taskItem.taskOwner);
  487. this.insertData(content, "Previous Task Id", this.object.taskItem.previousTaskId);
  488. }else{
  489. this.insertData(content, "Id", this.object.project.id);
  490. this.insertData(content, "Name", this.object.project.name);
  491. this.insertData(content, "Start date", this.encodeDate(this.object.project.startDate));
  492. }
  493. }
  494. }
  495. //separator
  496. row = content.insertRow(content.rows.length);
  497. cell = row.insertCell(row.cells.length);
  498. cell.colSpan = 2;
  499. cell.innerHTML = "<hr/>";
  500. //input section header
  501. row = content.insertRow(content.rows.length);
  502. cell = row.insertCell(row.cells.length);
  503. cell.colSpan = 2;
  504. dojo.addClass(cell, "ganttMenuDialogInputCellHeader");
  505. cell.innerHTML = "Customization: " + this.Description;
  506. //input details
  507. dojo.forEach(this.arrItems, function(item){
  508. row = content.insertRow(content.rows.length);
  509. cell = row.insertCell(row.cells.length);
  510. dojo.addClass(cell, "ganttMenuDialogInputCell");
  511. cellValue = row.insertCell(row.cells.length);
  512. dojo.addClass(cellValue, "ganttMenuDialogInputCellValue");
  513. cell.innerHTML = item.name;
  514. cellValue.appendChild(item.control.domNode);
  515. //initialize default value
  516. if(this.withDefaultValue && this.object){
  517. if(this.object.constructor == dojox.gantt.GanttTaskControl){
  518. if(item.key == "startTime"){
  519. item.control.textbox.value = this.encodeDate(this.object.taskItem.startTime);
  520. }else{
  521. item.control.textbox.value = item.key ? this.object.taskItem[item.key] : "";
  522. }
  523. }else{
  524. if(item.key == "startDate"){
  525. item.control.textbox.value = this.encodeDate(this.object.project.startDate);
  526. }else{
  527. item.control.textbox.value = item.key ? (this.object.project[item.key] || this.object[item.key] || "") : "";
  528. }
  529. }
  530. }else{
  531. //HTML5 placeholder property
  532. item.control.textbox.placeholder = item.required ? "---required---" : "---optional---";
  533. }
  534. }, this);
  535. this.tabMenu.ok.onClick = dojo.hitch(this, this.actionFunc);
  536. this.tabMenu.cancel.onClick = dojo.hitch(this, this.hide);
  537. },
  538. hide: function(){
  539. try{
  540. this.tabMenu.tabPanelDlg.hide();
  541. }catch(e){
  542. console.log("dialog show exception: " + e.message);
  543. this.tabMenu.tabPanelDlg.destroy();
  544. }
  545. var cell = this.tabMenu.paneContentArea.firstChild.rows[1].cells[0];
  546. cell.firstChild.parentNode.removeChild(cell.firstChild);
  547. cell.innerHTML = "<table></table>";
  548. dojo.addClass(cell.firstChild, "ganttDialogContentCell");
  549. },
  550. insertData: function(content, name, value){
  551. var cell, cellValue, row = null;
  552. row = content.insertRow(content.rows.length);
  553. cell = row.insertCell(row.cells.length);
  554. dojo.addClass(cell, "ganttMenuDialogDescCell");
  555. cell.innerHTML = name;
  556. cellValue = row.insertCell(row.cells.length);
  557. dojo.addClass(cellValue, "ganttMenuDialogDescCellValue");
  558. cellValue.innerHTML = value;
  559. }
  560. });
  561. })();
  562. }