Skip to content

Commit

Permalink
fixed tooltips for tag descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Jun 19, 2024
1 parent b11b99e commit dd97aa9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/main/resources/static/scripts/scoold.js
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ $(function () {
});

var tagDescriptions = {};
$(".tagchip").on("mousemove", function () {
$(".tagchip").on("mouseenter mouseover mousemove", function () {
var that = $(this);
var tag = that.text();
if (tag && $.trim(tag) !== "") {
Expand All @@ -909,16 +909,32 @@ $(function () {
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("title") !== tagDescriptions[tag]) {
that.attr("title", tagDescriptions[tag]);
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);
}

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

/****************************************************
* PAGINATION
****************************************************/
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/templates/macro.vm
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
<span class="chip mrs">$!showtag</span>
#else
<a href="$link/tag/$!utils.urlEncode($showtag)" title="Posts tagged $!showtag" class="chip mrs tagchip">$!showtag</a>
<div class="material-tooltip"><div class="tooltip-content"></div></div>
#end
#end
#end
Expand Down

0 comments on commit dd97aa9

Please sign in to comment.