Advertisement
Guest User

dhtmlx-gantt-zoom-patch

a guest
Jun 12th, 2012
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. Index: dhtmlx/dhtmlxGantt/sources/dhtmlxgantt.js
  2. ===================================================================
  3. --- dhtmlx.orig/dhtmlxGantt/sources/dhtmlxgantt.js 2012-06-12 13:49:29.542481180 +0200
  4. +++ dhtmlx/dhtmlxGantt/sources/dhtmlxgantt.js 2012-06-12 13:59:50.909197607 +0200
  5. @@ -356,7 +356,9 @@
  6.  
  7. //settings
  8. this.heightTaskItem = 12;
  9. + this.defaultDayInPixels = 24;
  10. this.dayInPixels = 24;
  11. + this.showDayNumbers = true;
  12. this.hoursInDay = 8;
  13. this._showTreePanel = true;
  14. this._showTooltip = true;
  15. @@ -456,6 +458,30 @@
  16. this.savePath = newPath;
  17. };
  18. /**
  19. + * @desc: Set the number of pixels per day (horizontal zoom). This will also affect showDayNumbers
  20. + * @param: pixelsPerDay
  21. + * @type: public
  22. + * @before_init: 1
  23. + */
  24. +GanttChart.prototype.setPixelsPerDay = function(numPixels)
  25. +{
  26. + this.dayInPixels = numPixels;
  27. + if(this.dayInPixels < 16)
  28. + this.showDayNumbers = false;
  29. + else
  30. + this.showDayNumbers = true;
  31. +}
  32. +/**
  33. + * @desc: Enables / disables displaying the day numbers
  34. + * @param: showDayNumbers
  35. + * @type: public
  36. + * @before_init: 1
  37. + */
  38. +GanttChart.prototype.setShowDayNumbers = function(showDayNumbers)
  39. +{
  40. + this.showDayNumbers = showDayNumbers;
  41. +}
  42. +/**
  43. * @desc: set url which is used to load chart data with loadData() method
  44. * @param: newPath - url to server script.
  45. * @type: public
  46. @@ -2405,9 +2431,12 @@
  47. divTasks.className = "taskPanel";
  48. divTasks.style.cssText = "position:relative;";
  49. divTasks.style.height = this.contentHeight - 63 + "px";
  50. + var bgWidth = 168 * (this.dayInPixels / this.defaultDayInPixels) + "px";
  51. + var bgHeight = "46px"; // The height of bg_week.png
  52. var w = this.startDate ? (this.startDate.getDay()-1) : ((new Date(0)).getDay()-1);
  53. if (w==-1) w=6;
  54. - divTasks.style.background = "url(" + this.imgs + "bg_week.png) -"+(w*24)+"px 0px";
  55. + divTasks.style.background = "url(" + this.imgs + "bg_week.png) -"+(w*this.dayInPixels)+"px 0px";
  56. + divTasks.style.backgroundSize = bgWidth + " " + bgHeight;
  57. this.panelTasks = divTasks;
  58. return divTasks;
  59. };
  60. @@ -2578,7 +2607,8 @@
  61.  
  62. date.setDate(date.getDate() + parseInt(idx));
  63. var day = date.getDate()
  64. - newCell.innerHTML = day;
  65. + if (this.showDayNumbers)
  66. + newCell.innerHTML = day;
  67. newCell.setAttribute("idx", idx);
  68.  
  69. var monthRow = row.parentNode.parentNode.rows[0];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement