Skip to content

Commit 245849e

Browse files
committed
Fix for issue mbielanczuk#1
1 parent 34e0a12 commit 245849e

File tree

5 files changed

+48
-32
lines changed

5 files changed

+48
-32
lines changed

.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>jQuery.Gantt</name>
4+
<comment>jQuery gantt chart</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
16+
</natures>
17+
</projectDescription>

js/data.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
2-
3-
41
[{ "name": "Jan Kowalski",
52
"desc": "Programista",
63
"values": [
7-
{"from": "/Date(1309471200000)/", "to": "/Date(1310421600000)/", "desc": "<b>Type</b>: Task<br/><b>name</b>: Task 1<br/><b>Description</b>: Task desc."},
8-
{"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"}
4+
{"from": "/Date(1302203200000)/", "to": "/Date(1310508000000)/", "desc": "Type: Task<br/>name: Task 3<br/>Description: Task desc.", "customClass": "ganttRed"}
95
]
106
},
117
{ "name": "Jan Nowak",

js/jquery.fn.gantt.js

+21-18
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ jQuery.fn.gantt = function (options) {
196196
var dRow = jQuery('<div class="row">');
197197
jQuery.each(range, function(j, day) {
198198
var todayCls = (today - day == 0) ? ' today' : day.getDay() == 6 ? ' sa' : (day.getDay() == 0 ? ' sn' : '');
199-
dRow.append(jQuery('<div class="row day' + todayCls + '" id="d'+i+'-'+day.getTime()+'" />')
199+
dRow.append(jQuery('<div class="row day' + todayCls + '" id="d'+i+'-'+ tools.genId(day.getTime())+'" />')
200200
.html(day));
201201
});
202202
dataPanel.append(dRow);
@@ -240,7 +240,7 @@ jQuery.fn.gantt = function (options) {
240240
{
241241
jQuery.each(data, function(i, entry) {
242242
jQuery.each(options.hollydays, function(j, hollyday) {
243-
jQuery('#d'+i+'-'+ tools.dateDeserialize(hollyday).getTime())
243+
jQuery('#d'+i+'-'+ tools.genId(tools.dateDeserialize(hollyday).getTime()))
244244
.addClass("hollyday");
245245
});
246246
});
@@ -252,16 +252,16 @@ jQuery.fn.gantt = function (options) {
252252
if (i >= pageNum * options.itemsPerPage && i < (pageNum*options.itemsPerPage+options.itemsPerPage))
253253
{
254254
jQuery.each(entry.values, function(j, day) {
255-
jQuery('#d'+i+'-'+ tools.dateDeserialize(day.from).getTime())
256-
.append(
257-
createProgressBar(
258-
Math.floor(((Date.parse(tools.dateDeserialize(day.to)) / 1000)
259-
- (Date.parse(tools.dateDeserialize(day.from)) / 1000)) / 86400),
260-
day.customClass ? day.customClass : '',
261-
day.desc ? day.desc : ''
262-
)
263-
)
264-
})
255+
var _bar = createProgressBar(
256+
Math.floor(((Date.parse(tools.dateDeserialize(day.to)) / 1000)
257+
- (Date.parse(tools.dateDeserialize(day.from)) / 1000)) / 86400),
258+
day.customClass ? day.customClass : '',
259+
day.desc ? day.desc : ''
260+
);
261+
jQuery('#d'+i+'-'+ tools.genId(tools.dateDeserialize(day.from).getTime()))
262+
.append(_bar
263+
);
264+
});
265265
}
266266
});
267267
};
@@ -271,13 +271,13 @@ jQuery.fn.gantt = function (options) {
271271
case 'begin':
272272
jQuery('.fn-gantt .dataPanel').animate({
273273
'margin-left': '0px'
274-
}, 'fast', function() {repositionLabel()});
274+
}, 'fast', function() {repositionLabel();});
275275
break;
276276
case 'end':
277277
var mLeft = jQuery('.fn-gantt .dataPanel').width() - jQuery('.fn-gantt .rightPanel').width();
278278
jQuery('.fn-gantt .dataPanel').animate({
279279
'margin-left': '-' + mLeft + 'px'
280-
}, 'fast', function() {repositionLabel()});
280+
}, 'fast', function() {repositionLabel();});
281281
break;
282282
default:
283283
var max_left = (jQuery('.fn-gantt .dataPanel').width() - jQuery('.fn-gantt .rightPanel').width()) * -1;
@@ -318,7 +318,7 @@ jQuery.fn.gantt = function (options) {
318318
{
319319
var viewArea = {
320320
left: objDim.offset.left > wrapper.offset.left ? objDim.offset.left : wrapper.offset.left,
321-
right: objDim.offset.left+objDim.width < wrapper.offset.left + wrapper.width ? objDim.offset.left+objDim.width : wrapper.offset.left + wrapper.width,
321+
right: objDim.offset.left+objDim.width < wrapper.offset.left + wrapper.width ? objDim.offset.left+objDim.width : wrapper.offset.left + wrapper.width
322322
};
323323
jQuery(obj).children(".label").css("float", "left");
324324
var labelWidth = jQuery(obj).children(".label").width();
@@ -365,12 +365,16 @@ jQuery.fn.gantt = function (options) {
365365
do {
366366
ret[i++] = new Date(current.getTime());
367367
current.setDate(current.getDate()+1);
368-
} while (current <= to)
368+
} while (current <= to);
369369
return ret;
370370
};
371371
this.dateDeserialize = function (dateStr) {
372372
return eval('new' + dateStr.replace(/\//g, ' '));
373373
};
374+
this.genId = function (ticks) {
375+
var t = Math.floor(ticks / 86400000);
376+
return t * 86400000;
377+
};
374378
var _getCellSize = null;
375379
this.getCellSize = function() {
376380
if (!_getCellSize)
@@ -402,5 +406,4 @@ jQuery.fn.gantt = function (options) {
402406
};
403407
jQuery(this).empty();
404408
create(jQuery(this));
405-
406-
}
409+
};

0 commit comments

Comments
 (0)