summaryrefslogtreecommitdiff
path: root/assets/js/core/tooltip.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/core/tooltip.js')
-rw-r--r--assets/js/core/tooltip.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/assets/js/core/tooltip.js b/assets/js/core/tooltip.js
index acb42bbd..ae5ac1c8 100644
--- a/assets/js/core/tooltip.js
+++ b/assets/js/core/tooltip.js
@@ -9,6 +9,19 @@ KB.tooltip = function () {
setTimeout(destroy, 500);
}
+ function mouseLeftParent() {
+ setTimeout(destroyIfNotOnTooltip, 500);
+ }
+
+ function mouseOnTooltip() {
+ document.getElementById("tooltip-container").mouseOnTooltip = true;
+ }
+
+ function destroyIfNotOnTooltip() {
+ var div = document.getElementById("tooltip-container");
+ if(div != null && !div.mouseOnTooltip) destroy();
+ }
+
function create(element) {
var contentElement = element.querySelector("script");
if (contentElement) {
@@ -45,6 +58,8 @@ KB.tooltip = function () {
containerElement.id = "tooltip-container";
containerElement.innerHTML = html;
containerElement.addEventListener("mouseleave", onMouseLeaveContainer, false);
+ containerElement.addEventListener("mouseenter", mouseOnTooltip, false);
+ containerElement.mouseOnTooltip = false;
var elementRect = element.getBoundingClientRect();
var top = elementRect.top + window.scrollY + elementRect.height;
@@ -81,5 +96,6 @@ KB.tooltip = function () {
var elements = document.querySelectorAll(".tooltip");
for (var i = 0; i < elements.length; i++) {
elements[i].addEventListener("mouseenter", onMouseOver, false);
+ elements[i].addEventListener("mouseleave", mouseLeftParent, false);
}
};