diff --git a/resources/report/js/script.js b/resources/report/js/script.js index e8732d13..60794002 100644 --- a/resources/report/js/script.js +++ b/resources/report/js/script.js @@ -1124,7 +1124,12 @@ function showHoverText(evt) { var rect = evt.target.getBoundingClientRect(); hoverText.style.left = (rect.left + evt.target.offsetWidth/2) + 'px'; - hoverText.style.top = (rect.bottom + 10) + 'px'; + + if (rect.bottom + 30 > window.innerHeight) { + hoverText.style.top = (rect.top - 30) + 'px'; + } else { + hoverText.style.top = (rect.bottom + 10) + 'px'; + } var dialog = getDialogParent(evt.target); if (dialog) { @@ -1132,6 +1137,14 @@ function showHoverText(evt) { } else { document.body.appendChild(hoverText); } + + /* Now check that the computed height isn't larger than expected. */ + var height = getComputedStyle(hoverText).height; + height = parseInt(height.substr(0, height.length - 2), 10); + if (height > 20 && rect.bottom + height + 10 > window.innerHeight) { + /* Tooltip is either covering its source element, or is going off-window. */ + hoverText.style.top = (rect.top - height - 10) + 'px'; + } } function hideHoverText(evt) { var hoverText = document.getElementById('hoverText');