Permalink
Browse files

added a simple click event to the gantt blocks

  • Loading branch information...
1 parent 575419a commit ba44ca538bc1e27e6268621600d7e02b83a408ad @thegrubbsian thegrubbsian committed Jun 18, 2010
Showing with 27 additions and 6 deletions.
  1. +2 −1 jquery.ganttView.css
  2. +25 −5 jquery.ganttView.js
@@ -1,5 +1,5 @@
/*
-jQuery.ganttView v.0.7
+jQuery.ganttView v.0.7.2
Copyright (c) 2010 JC Grubbs - jc.grubbs@devmynd.com
MIT License Applies
*/
@@ -59,6 +59,7 @@ div.ganttview-vtheader {
div.ganttview-vtheader-item {
overflow: hidden;
+ color: #666;
}
div.ganttview-vtheader-item-name {
View
@@ -1,5 +1,5 @@
/*
-jQuery.ganttView v.0.7.1
+jQuery.ganttView v.0.7.2
Copyright (c) 2010 JC Grubbs - jc.grubbs@devmynd.com
MIT License Applies
*/
@@ -25,7 +25,8 @@ slideWidth: number
cellWidth: 21,
cellHeight: 31,
slideWidth: 400,
- vHeaderWidth: 100
+ vHeaderWidth: 100,
+ blockClick: null
};
var opts = jQuery.extend(defaults, options);
var months = Chart.getMonths(opts.start, opts.end);
@@ -55,6 +56,8 @@ slideWidth: number
container.css("width", (w + 2) + "px");
Chart.applyLastClass(container);
+
+ Events.bindBlockClick(container, opts.blockClick);
});
};
@@ -157,15 +160,23 @@ slideWidth: number
var rowIdx = 0;
for (var i = 0; i < data.length; i++) {
for (var j = 0; j < data[i].series.length; j++) {
- var size = DateUtils.daysBetween(data[i].series[j].start, data[i].series[j].end);
- var offset = DateUtils.daysBetween(start, data[i].series[j].start);
+ var series = data[i].series[j];
+ var size = DateUtils.daysBetween(series.start, series.end);
+ var offset = DateUtils.daysBetween(start, series.start);
var blockDiv = jQuery("<div>", {
"class": "ganttview-block",
- "title": data[i].series[j].name + ", " + size + " days",
+ "title": series.name + ", " + size + " days",
"css": {
"width": ((size * cellWidth) - 9) + "px",
"margin-left": ((offset * cellWidth) + 3) + "px"
}
+ }).data("block-data", {
+ id: data[i].id,
+ itemName: data[i].name,
+ seriesName: series.name,
+ start: Date.parse(series.start),
+ end: Date.parse(series.end),
+ color: series.color
});
if (data[i].series[j].color) {
blockDiv.css("background-color", data[i].series[j].color);
@@ -185,6 +196,15 @@ slideWidth: number
};
+ var Events = {
+
+ bindBlockClick: function (div, callback) {
+ $("div.ganttview-block").live("click", function () {
+ if (callback) { callback($(this).data("block-data")); }
+ });
+ }
+ };
+
var ArrayUtils = {
contains: function (arr, obj) {
var has = false;

0 comments on commit ba44ca5

Please sign in to comment.