Skip to content

Commit

Permalink
Fix for issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
mbielanczuk committed Sep 11, 2011
1 parent 34e0a12 commit 245849e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 32 deletions.
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jQuery.Gantt</name>
<comment>jQuery gantt chart</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
6 changes: 1 addition & 5 deletions js/data.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@



[{ "name": "Jan Kowalski",
"desc": "Programista",
"values": [
{"from": "/Date(1309471200000)/", "to": "/Date(1310421600000)/", "desc": "<b>Type</b>: Task<br/><b>name</b>: Task 1<br/><b>Description</b>: Task desc."},
{"from": "/Date(1310594400000)/", "to": "/Date(1311112800000)/", "desc": "<b>Type</b>: Task<br/><b>name</b>: Task 2<br/><b>Description</b>: Task desc.", "customClass": "ganttOrange"}
{"from": "/Date(1302203200000)/", "to": "/Date(1310508000000)/", "desc": "Type: Task<br/>name: Task 3<br/>Description: Task desc.", "customClass": "ganttRed"}
]
},
{ "name": "Jan Nowak",
Expand Down
39 changes: 21 additions & 18 deletions js/jquery.fn.gantt.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ jQuery.fn.gantt = function (options) {
var dRow = jQuery('<div class="row">');
jQuery.each(range, function(j, day) {
var todayCls = (today - day == 0) ? ' today' : day.getDay() == 6 ? ' sa' : (day.getDay() == 0 ? ' sn' : '');
dRow.append(jQuery('<div class="row day' + todayCls + '" id="d'+i+'-'+day.getTime()+'" />')
dRow.append(jQuery('<div class="row day' + todayCls + '" id="d'+i+'-'+ tools.genId(day.getTime())+'" />')
.html(day));
});
dataPanel.append(dRow);
Expand Down Expand Up @@ -240,7 +240,7 @@ jQuery.fn.gantt = function (options) {
{
jQuery.each(data, function(i, entry) {
jQuery.each(options.hollydays, function(j, hollyday) {
jQuery('#d'+i+'-'+ tools.dateDeserialize(hollyday).getTime())
jQuery('#d'+i+'-'+ tools.genId(tools.dateDeserialize(hollyday).getTime()))
.addClass("hollyday");
});
});
Expand All @@ -252,16 +252,16 @@ jQuery.fn.gantt = function (options) {
if (i >= pageNum * options.itemsPerPage && i < (pageNum*options.itemsPerPage+options.itemsPerPage))
{
jQuery.each(entry.values, function(j, day) {
jQuery('#d'+i+'-'+ tools.dateDeserialize(day.from).getTime())
.append(
createProgressBar(
Math.floor(((Date.parse(tools.dateDeserialize(day.to)) / 1000)
- (Date.parse(tools.dateDeserialize(day.from)) / 1000)) / 86400),
day.customClass ? day.customClass : '',
day.desc ? day.desc : ''
)
)
})
var _bar = createProgressBar(
Math.floor(((Date.parse(tools.dateDeserialize(day.to)) / 1000)
- (Date.parse(tools.dateDeserialize(day.from)) / 1000)) / 86400),
day.customClass ? day.customClass : '',
day.desc ? day.desc : ''
);
jQuery('#d'+i+'-'+ tools.genId(tools.dateDeserialize(day.from).getTime()))
.append(_bar
);
});
}
});
};
Expand All @@ -271,13 +271,13 @@ jQuery.fn.gantt = function (options) {
case 'begin':
jQuery('.fn-gantt .dataPanel').animate({
'margin-left': '0px'
}, 'fast', function() {repositionLabel()});
}, 'fast', function() {repositionLabel();});
break;
case 'end':
var mLeft = jQuery('.fn-gantt .dataPanel').width() - jQuery('.fn-gantt .rightPanel').width();
jQuery('.fn-gantt .dataPanel').animate({
'margin-left': '-' + mLeft + 'px'
}, 'fast', function() {repositionLabel()});
}, 'fast', function() {repositionLabel();});
break;
default:
var max_left = (jQuery('.fn-gantt .dataPanel').width() - jQuery('.fn-gantt .rightPanel').width()) * -1;
Expand Down Expand Up @@ -318,7 +318,7 @@ jQuery.fn.gantt = function (options) {
{
var viewArea = {
left: objDim.offset.left > wrapper.offset.left ? objDim.offset.left : wrapper.offset.left,
right: objDim.offset.left+objDim.width < wrapper.offset.left + wrapper.width ? objDim.offset.left+objDim.width : wrapper.offset.left + wrapper.width,
right: objDim.offset.left+objDim.width < wrapper.offset.left + wrapper.width ? objDim.offset.left+objDim.width : wrapper.offset.left + wrapper.width
};
jQuery(obj).children(".label").css("float", "left");
var labelWidth = jQuery(obj).children(".label").width();
Expand Down Expand Up @@ -365,12 +365,16 @@ jQuery.fn.gantt = function (options) {
do {
ret[i++] = new Date(current.getTime());
current.setDate(current.getDate()+1);
} while (current <= to)
} while (current <= to);
return ret;
};
this.dateDeserialize = function (dateStr) {
return eval('new' + dateStr.replace(/\//g, ' '));
};
this.genId = function (ticks) {
var t = Math.floor(ticks / 86400000);
return t * 86400000;
};
var _getCellSize = null;
this.getCellSize = function() {
if (!_getCellSize)
Expand Down Expand Up @@ -402,5 +406,4 @@ jQuery.fn.gantt = function (options) {
};
jQuery(this).empty();
create(jQuery(this));

}
};
Loading

0 comments on commit 245849e

Please sign in to comment.