Skip to content

Commit 5dcb667

Browse files
committed
Custom classes for gant-hint
Add the possibility to add a custom classes for the item hint
1 parent fdbb279 commit 5dcb667

File tree

1 file changed

+37
-32
lines changed

1 file changed

+37
-32
lines changed

js/jquery.fn.gantt.js

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
waitText: "Please wait...",
4444
onItemClick: function (data) { return; },
4545
onAddClick: function (data) { return; },
46-
onRender: function() { return; },
46+
onRender: function () { return; },
4747
scrollToToday: true
4848
};
4949

@@ -185,7 +185,7 @@
185185

186186
// fixes https://github.com/taitems/jQuery.Gantt/issues/62
187187
function ktkGetNextDate(currentDate, scaleStep) {
188-
for(var minIncrements = 1;; minIncrements++) {
188+
for (var minIncrements = 1; ; minIncrements++) {
189189
var nextDate = new Date(currentDate);
190190
nextDate.setHours(currentDate.getHours() + scaleStep * minIncrements);
191191

@@ -205,7 +205,7 @@
205205
var core = {
206206
// Return the element whose topmost point lies under the given point
207207
// Normalizes for old browsers
208-
elementFromPoint: (function(){ // IIFE
208+
elementFromPoint: (function () { // IIFE
209209
// version for normal browsers
210210
if (document.compatMode === "CSS1Compat") {
211211
return function (x, y) {
@@ -291,7 +291,7 @@
291291
if (settings.scrollToToday) {
292292
core.navigateTo(element, 'now');
293293
core.scrollPanel(element, 0);
294-
// or, scroll the grid to the left most date in the panel
294+
// or, scroll the grid to the left most date in the panel
295295
} else {
296296
if (element.hPosition !== 0) {
297297
if (element.scaleOldWidth) {
@@ -490,7 +490,7 @@
490490
day_class = "holiday";
491491
}
492492
if (rgetDay !== getDay) {
493-
var day_class2 = (today - day === 0) ? "today" : tools.isHoliday( day.getTime() ) ? "holiday" : dowClass[getDay];
493+
var day_class2 = (today - day === 0) ? "today" : tools.isHoliday(day.getTime()) ? "holiday" : dowClass[getDay];
494494

495495
dayArr.push('<div class="row date ' + day_class2 + '" '
496496
+ ' style="width: ' + tools.getCellSize() * hoursInDay + 'px;"> '
@@ -530,7 +530,7 @@
530530

531531
var day_class = dowClass[day.getDay()];
532532

533-
if ( tools.isHoliday(day) ) {
533+
if (tools.isHoliday(day)) {
534534
day_class = "holiday";
535535
}
536536

@@ -554,7 +554,7 @@
554554

555555
break;
556556

557-
// **Weeks**
557+
// **Weeks**
558558
case "weeks":
559559
range = tools.parseWeeksRange(element.dateStart, element.dateEnd);
560560
yearArr = ['<div class="row"/>'];
@@ -619,7 +619,7 @@
619619

620620
break;
621621

622-
// **Months**
622+
// **Months**
623623
case 'months':
624624
range = tools.parseMonthsRange(element.dateStart, element.dateEnd);
625625

@@ -670,7 +670,7 @@
670670

671671
break;
672672

673-
// **Days (default)**
673+
// **Days (default)**
674674
default:
675675
range = tools.parseDateRange(element.dateStart, element.dateEnd);
676676

@@ -710,7 +710,7 @@
710710

711711
var getDay = rday.getDay();
712712
var day_class = dowClass[getDay];
713-
if ( tools.isHoliday(rday) ) {
713+
if (tools.isHoliday(rday)) {
714714
day_class = "holiday";
715715
}
716716

@@ -863,7 +863,7 @@
863863
$(document).mouseup(function () {
864864
element.scrollNavigation.scrollerMouseDown = false;
865865
});
866-
// Button navigation is provided by setting `settings.navigation='buttons'`
866+
// Button navigation is provided by setting `settings.navigation='buttons'`
867867
} else {
868868
ganttNavigate = $('<div class="navigate" />')
869869
.append($('<button type="button" class="nav-link nav-page-back"/>')
@@ -931,7 +931,7 @@
931931
// **Progress Bar**
932932
// Return an element representing a progress of position within
933933
// the entire chart
934-
createProgressBar: function (days, cls, desc, label, dataObj) {
934+
createProgressBar: function (days, cls, clsh, desc, label, dataObj) {
935935
var cellWidth = tools.getCellSize();
936936
var barMarg = tools.getProgressBarMargin() || 0;
937937
var bar = $('<div class="bar"><div class="fn-label">' + label + '</div></div>')
@@ -944,7 +944,7 @@
944944
if (desc) {
945945
bar
946946
.mouseover(function (e) {
947-
var hint = $('<div class="fn-gantt-hint" />').html(desc);
947+
var hint = $('<div class="fn-gantt-hint" />').addClass(clsh).html(desc);
948948
$("body").append(hint);
949949
hint.css("left", e.pageX);
950950
hint.css("top", e.pageY);
@@ -1024,6 +1024,7 @@
10241024
_bar = core.createProgressBar(
10251025
dl,
10261026
day.customClass ? day.customClass : "",
1027+
day.customHintClass ? day.customHintClass : "",
10271028
day.desc ? day.desc : "",
10281029
day.label ? day.label : "",
10291030
day.dataObj ? day.dataObj : null
@@ -1038,7 +1039,7 @@
10381039
datapanel.append(_bar);
10391040
break;
10401041

1041-
// **Weekly data**
1042+
// **Weekly data**
10421043
case "weeks":
10431044
var dtFrom = tools.dateDeserialize(day.from);
10441045
var dtTo = tools.dateDeserialize(day.to);
@@ -1067,6 +1068,7 @@
10671068
_bar = core.createProgressBar(
10681069
dl,
10691070
day.customClass ? day.customClass : "",
1071+
day.customHintClass ? day.customHintClass : "",
10701072
day.desc ? day.desc : "",
10711073
day.label ? day.label : "",
10721074
day.dataObj ? day.dataObj : null
@@ -1081,7 +1083,7 @@
10811083
datapanel.append(_bar);
10821084
break;
10831085

1084-
// **Monthly data**
1086+
// **Monthly data**
10851087
case "months":
10861088
var dtFrom = tools.dateDeserialize(day.from);
10871089
var dtTo = tools.dateDeserialize(day.to);
@@ -1107,6 +1109,7 @@
11071109
_bar = core.createProgressBar(
11081110
dl,
11091111
day.customClass ? day.customClass : "",
1112+
day.customHintClass ? day.customHintClass : "",
11101113
day.desc ? day.desc : "",
11111114
day.label ? day.label : "",
11121115
day.dataObj ? day.dataObj : null
@@ -1121,7 +1124,7 @@
11211124
datapanel.append(_bar);
11221125
break;
11231126

1124-
// **Days**
1127+
// **Days**
11251128
default:
11261129
var dFrom = tools.genId(tools.dateDeserialize(day.from).getTime());
11271130
var dTo = tools.genId(tools.dateDeserialize(day.to).getTime());
@@ -1133,6 +1136,7 @@
11331136
_bar = core.createProgressBar(
11341137
dl,
11351138
day.customClass ? day.customClass : "",
1139+
day.customHintClass ? day.customHintClass : "",
11361140
day.desc ? day.desc : "",
11371141
day.label ? day.label : "",
11381142
day.dataObj ? day.dataObj : null
@@ -1167,7 +1171,7 @@
11671171
var rightPanelWidth = $rightPanel.width();
11681172
var dataPanelWidth = $dataPanel.width();
11691173
var shift = function () {
1170-
core.repositionLabel(element);
1174+
core.repositionLabel(element);
11711175
};
11721176
switch (val) {
11731177
case "begin":
@@ -1298,10 +1302,10 @@
12981302
e.preventDefault(); // e is a jQuery Event
12991303

13001304
// attempts to normalize scroll wheel velocity
1301-
var delta = ( 'detail' in e ? e.detail :
1302-
'wheelDelta' in e.originalEvent ? - 1/120 * e.originalEvent.wheelDelta :
1305+
var delta = ('detail' in e ? e.detail :
1306+
'wheelDelta' in e.originalEvent ? -1 / 120 * e.originalEvent.wheelDelta :
13031307
e.originalEvent.deltaY ? e.originalEvent.deltaY / Math.abs(e.originalEvent.deltaY) :
1304-
e.originalEvent.detail );
1308+
e.originalEvent.detail);
13051309

13061310
// simpler normalization, ignoring per-device/browser/platform acceleration & semantic variations
13071311
//var delta = e.detail || - (e = e.originalEvent).wheelData || e.deltaY /* || e.deltaX */ || e.detail;
@@ -1422,7 +1426,7 @@
14221426
setTimeout(fn, 500);
14231427

14241428
} else if (element.loader) {
1425-
element.loader.detach();
1429+
element.loader.detach();
14261430
}
14271431
}
14281432
};
@@ -1534,7 +1538,7 @@
15341538

15351539
var ret = [];
15361540
var i = 0;
1537-
for(;;) {
1541+
for (; ;) {
15381542
var dayStartTime = new Date(current);
15391543
dayStartTime.setHours(Math.floor((current.getHours()) / scaleStep) * scaleStep);
15401544

@@ -1607,7 +1611,7 @@
16071611
date = date.replace(/\/Date\((.*)\)\//, "$1");
16081612
date = $.isNumeric(date) ? parseInt(date, 10) : $.trim(date);
16091613
}
1610-
return new Date( date );
1614+
return new Date(date);
16111615
},
16121616

16131617
// Generate an id for a date
@@ -1636,31 +1640,31 @@
16361640
},
16371641

16381642
// normalizes an array of dates into a map of start-of-day millisecond values
1639-
_datesToDays: function ( dates ) {
1643+
_datesToDays: function (dates) {
16401644
var dayMap = {};
16411645
for (var i = 0, len = dates.length, day; i < len; i++) {
1642-
day = tools.dateDeserialize( dates[i] );
1643-
dayMap[ day.setHours(0, 0, 0, 0) ] = true;
1646+
day = tools.dateDeserialize(dates[i]);
1647+
dayMap[day.setHours(0, 0, 0, 0)] = true;
16441648
}
16451649
return dayMap;
16461650
},
16471651
// Returns true when the given date appears in the array of holidays, if provided
1648-
isHoliday: (function() { // IIFE
1652+
isHoliday: (function () { // IIFE
16491653
// short-circuits the function if no holidays option was passed
16501654
if (!settings.holidays) {
1651-
return function () { return false; };
1655+
return function () { return false; };
16521656
}
16531657
var holidays = false;
16541658
// returns the function that will be used to check for holidayness of a given date
1655-
return function(date) {
1659+
return function (date) {
16561660
if (!holidays) {
1657-
holidays = tools._datesToDays( settings.holidays );
1661+
holidays = tools._datesToDays(settings.holidays);
16581662
}
16591663
return !!holidays[
16601664
// assumes numeric dates are already normalized to start-of-day
16611665
$.isNumeric(date) ?
1662-
date :
1663-
( new Date(date.getFullYear(), date.getMonth(), date.getDate()) ).getTime()
1666+
date :
1667+
(new Date(date.getFullYear(), date.getMonth(), date.getDate())).getTime()
16641668
];
16651669
};
16661670
})(),
@@ -1759,3 +1763,4 @@
17591763

17601764
};
17611765
})(jQuery);
1766+

0 commit comments

Comments
 (0)