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:
@@ -6,6 +6,12 @@ Danbooru.PostTooltip.render_tooltip = function (event, qtip) {
|
|||||||
$.get("/posts/" + post_id, { variant: "tooltip" }).then(function (html) {
|
$.get("/posts/" + post_id, { variant: "tooltip" }).then(function (html) {
|
||||||
qtip.set("content.text", html);
|
qtip.set("content.text", html);
|
||||||
qtip.elements.tooltip.removeClass("post-tooltip-loading");
|
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 {
|
} else {
|
||||||
$(this).qtip(Danbooru.PostTooltip.QTIP_OPTIONS, event);
|
$(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.
|
// Hide tooltips when pressing keys or clicking thumbnails.
|
||||||
|
|||||||
Reference in New Issue
Block a user