Guest User

dhtmlx-gantt-zoom-patch

a guest
Jun 12th, 2012
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 14:33:01.435484435 +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,33 @@
  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. + this.hourInPixelsWork = this.dayInPixels / this.hoursInDay;
  28. + this.hourInPixels = this.dayInPixels / 24;
  29. + this.xMovePadding = 24 * this.hourInPixels;
  30. + if(this.dayInPixels < 16)
  31. + this.showDayNumbers = false;
  32. + else
  33. + this.showDayNumbers = true;
  34. +}
  35. +/**
  36. + * @desc: Enables / disables displaying the day numbers
  37. + * @param: showDayNumbers
  38. + * @type: public
  39. + * @before_init: 1
  40. + */
  41. +GanttChart.prototype.setShowDayNumbers = function(showDayNumbers)
  42. +{
  43. + this.showDayNumbers = showDayNumbers;
  44. +}
  45. +/**
  46. * @desc: set url which is used to load chart data with loadData() method
  47. * @param: newPath - url to server script.
  48. * @type: public
  49. @@ -2405,9 +2434,12 @@
  50. divTasks.className = "taskPanel";
  51. divTasks.style.cssText = "position:relative;";
  52. divTasks.style.height = this.contentHeight - 63 + "px";
  53. + var bgWidth = 168 * (this.dayInPixels / this.defaultDayInPixels) + "px";
  54. + var bgHeight = "46px"; // The height of bg_week.png
  55. var w = this.startDate ? (this.startDate.getDay()-1) : ((new Date(0)).getDay()-1);
  56. if (w==-1) w=6;
  57. - divTasks.style.background = "url(" + this.imgs + "bg_week.png) -"+(w*24)+"px 0px";
  58. + divTasks.style.background = "url(" + this.imgs + "bg_week.png) -"+(w*this.dayInPixels)+"px 0px";
  59. + divTasks.style.backgroundSize = bgWidth + " " + bgHeight;
  60. this.panelTasks = divTasks;
  61. return divTasks;
  62. };
  63. @@ -2578,7 +2610,8 @@
  64.  
  65. date.setDate(date.getDate() + parseInt(idx));
  66. var day = date.getDate()
  67. - newCell.innerHTML = day;
  68. + if (this.showDayNumbers)
  69. + newCell.innerHTML = day;
  70. newCell.setAttribute("idx", idx);
  71.  
  72. var monthRow = row.parentNode.parentNode.rows[0];
  73. @@ -2805,6 +2838,9 @@
  74. {
  75. var self = this;
  76. var content = document.getElementById(divId);
  77. + while (content.hasChildNodes()) {
  78. + content.removeChild(content.lastChild);
  79. + }
  80. this.content = content;
  81. this.getBrowserType();
Advertisement
Add Comment
Please, Sign In to add comment