TabMenu.js 20 KB

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