Skip to content

Commit

Permalink
fixed JS for tooltips on tag descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Jun 21, 2024
1 parent 01bd358 commit cfb3c98
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/main/resources/static/scripts/scoold.js
Original file line number Diff line number Diff line change
Expand Up @@ -898,41 +898,43 @@ $(function () {
});

var tagDescriptions = {};
$(".tagchip").on("mouseenter mouseover mousemove", function () {
$(".tagchip").on("mouseenter", function () {
var that = $(this);
var tag = that.text();
if (tag && $.trim(tag) !== "") {
if (!tagDescriptions[tag] || tagDescriptions[tag] === "") {
tagDescriptions[tag] = " ";
$.get(CONTEXT_PATH + "/tags/" + tag, function (data) {
//if (data.length === 0) {data.push({tag: val});}
data.map(function (t) {
if (t.description) {
tagDescriptions[t.tag] = t.description;
showTagTooltip(that, tagDescriptions[tag]);
that.attr("title", "");
}
});
});
}
if ($.trim(tagDescriptions[tag]) !== "" && that.attr("data-tooltip") !== tagDescriptions[tag]) {
that.attr("title", "");
showTagTooltip(that, tagDescriptions[tag]);
}
}
});

function showTagTooltip(that, text) {
that.next("div.material-tooltip").css({
"opacity":"1",
"visibility":"visible",
"left": that.offset().left,
"top": that.offset().top + 40
}).find(".tooltip-content").text(text);
if (text && $.trim(text) !== "") {
that.attr("title", "");
that.next("div.material-tooltip").css({
"opacity":"1",
"visibility":"visible",
"left": that.offset().left,
"top": that.offset().top + 40
}).find(".tooltip-content").text(text);
}
}

$(".tagchip").on("mouseleave", function () {
$(this).next("div.material-tooltip").css({"opacity": "0", "visibility": "hidden"});
var that = $(this);
setTimeout(function () {
that.next("div.material-tooltip").css({"opacity": "0", "visibility": "hidden"});
}, 150);
});

/****************************************************
Expand Down

0 comments on commit cfb3c98

Please sign in to comment.