post tooltips: don't show if lost focus during ajax call (#3689).

Fix the tooltip appearing and getting stuck when the user mouses out
during the ajax request.
This commit is contained in:
evazion
2018-04-29 01:58:39 -05:00
parent 57203727b6
commit 862b1bc4c8

View File

@@ -6,6 +6,12 @@ Danbooru.PostTooltip.render_tooltip = function (event, qtip) {
$.get("/posts/" + post_id, { variant: "tooltip" }).then(function (html) {
qtip.set("content.text", html);
qtip.elements.tooltip.removeClass("post-tooltip-loading");
// Hide the tooltip if the user stopped hovering before the ajax request completed.
if (Danbooru.PostTooltip.lostFocus) {
console.log("hiding");
qtip.hide();
}
});
};
@@ -61,6 +67,12 @@ Danbooru.PostTooltip.initialize = function () {
} else {
$(this).qtip(Danbooru.PostTooltip.QTIP_OPTIONS, event);
}
Danbooru.PostTooltip.lostFocus = false;
});
$(document).on("mouseleave", Danbooru.PostTooltip.POST_SELECTOR, function (event) {
Danbooru.PostTooltip.lostFocus = true;
});
// Hide tooltips when pressing keys or clicking thumbnails.