Skip to content

Commit dd97aa9

Browse files
committed
fixed tooltips for tag descriptions
1 parent b11b99e commit dd97aa9

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/main/resources/static/scripts/scoold.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ $(function () {
898898
});
899899

900900
var tagDescriptions = {};
901-
$(".tagchip").on("mousemove", function () {
901+
$(".tagchip").on("mouseenter mouseover mousemove", function () {
902902
var that = $(this);
903903
var tag = that.text();
904904
if (tag && $.trim(tag) !== "") {
@@ -909,16 +909,32 @@ $(function () {
909909
data.map(function (t) {
910910
if (t.description) {
911911
tagDescriptions[t.tag] = t.description;
912+
showTagTooltip(that, tagDescriptions[tag]);
913+
that.attr("title", "");
912914
}
913915
});
914916
});
915917
}
916-
if ($.trim(tagDescriptions[tag]) !== "" && that.attr("title") !== tagDescriptions[tag]) {
917-
that.attr("title", tagDescriptions[tag]);
918+
if ($.trim(tagDescriptions[tag]) !== "" && that.attr("data-tooltip") !== tagDescriptions[tag]) {
919+
that.attr("title", "");
920+
showTagTooltip(that, tagDescriptions[tag]);
918921
}
919922
}
920923
});
921924

925+
function showTagTooltip(that, text) {
926+
that.next("div.material-tooltip").css({
927+
"opacity":"1",
928+
"visibility":"visible",
929+
"left": that.offset().left,
930+
"top": that.offset().top + 40
931+
}).find(".tooltip-content").text(text);
932+
}
933+
934+
$(".tagchip").on("mouseleave", function () {
935+
$(this).next("div.material-tooltip").css({"opacity": "0", "visibility": "hidden"});
936+
});
937+
922938
/****************************************************
923939
* PAGINATION
924940
****************************************************/

src/main/resources/templates/macro.vm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@
257257
<span class="chip mrs">$!showtag</span>
258258
#else
259259
<a href="$link/tag/$!utils.urlEncode($showtag)" title="Posts tagged $!showtag" class="chip mrs tagchip">$!showtag</a>
260+
<div class="material-tooltip"><div class="tooltip-content"></div></div>
260261
#end
261262
#end
262263
#end

0 commit comments

Comments
 (0)