Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customClass to bar hover hint #98

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@
height: 18px;
margin: 4px 3px 3px 3px;
position: absolute;
z-index: 10;
text-align: center;
-webkit-box-shadow: 0 0 1px rgba(0,0,0,0.25) inset;
-moz-box-shadow: 0 0 1px rgba(0,0,0,0.25) inset;
Expand Down
33 changes: 26 additions & 7 deletions js/jquery.fn.gantt.js
Original file line number Diff line number Diff line change
Expand Up @@ -945,20 +945,22 @@
.data("dataObj", dataObj);

if (desc) {
var hint;
bar
.mouseover(function (e) {
var hint = $('<div class="fn-gantt-hint" />').html(desc);
$("body").append(hint);
hint.css("left", e.pageX);
hint.css("top", e.pageY);
if (!hint) {
hint = $('<div class="fn-gantt-hint" />').html(desc);
}

$(this).append(hint);
core.updateHintPosition(hint, e);
hint.show();
})
.mouseout(function () {
$(".fn-gantt-hint").remove();
hint = hint.detach();
})
.mousemove(function (e) {
$(".fn-gantt-hint").css("left", e.pageX);
$(".fn-gantt-hint").css("top", e.pageY + 15);
core.updateHintPosition(hint, e);
});
}
bar.click(function (e) {
Expand All @@ -968,6 +970,23 @@
return bar;
},

// updates the x/y position of the bar hint
// offsetX/Y is available in Chrome/IE but not Firefox
// see http://bugs.jquery.com/ticket/8523
updateHintPosition: function(hint, e) {
var hintOffset = 15;
var x = e.offsetX, y = e.offsetY;

if (typeof x === "undefined" || typeof y === "undefined") {
var targetOffset = $(e.target).offset();
x = e.pageX - targetOffset.left;
y = e.pageY - targetOffset.top;
}

hint.css("left", x + hintOffset);
hint.css("top", y + hintOffset);
},

// Remove the `wd` (weekday) class and add `today` class to the
// current day/week/month (depending on the current scale)
markNow: function (element) {
Expand Down