3336248e618a25a2b6b4ef45325ebd5ba04b542c chmalee Mon Apr 15 13:55:23 2024 -0700 Make the tooltip messages about basic genome browser function like 'click to drag' disappear, refs Ana diff --git src/hg/js/utils.js src/hg/js/utils.js index 4dd777a..0f5f9a5 100644 --- src/hg/js/utils.js +++ src/hg/js/utils.js @@ -3979,59 +3979,60 @@ tooltipTarget.style.visibility = "hidden"; } function mouseIsOverPopup(ev, ele, fudgeFactor=25) { /* Is the mouse positioned over the popup? */ let targetBox = ele.getBoundingClientRect(); let mouseX = ev.clientX; let mouseY = ev.clientY; if ( (mouseX >= (targetBox.left - fudgeFactor) && mouseX <= (targetBox.right + fudgeFactor) && mouseY >= (targetBox.top - fudgeFactor) && mouseY <= (targetBox.bottom + fudgeFactor)) ) { return true; } return false; } -function mouseIsOverItem(ev, ele, fudgeFactor=25) { +function mouseIsOverItem(ev, ele, fudgeFactor=15) { /* Is the mouse positioned over the item that triggered the popup? */ let origName = ele.getAttribute("origItemMouseoverId"); let origTargetBox = boundingRect($("[mouseoverid='"+origName+"']")[0]); let mouseX = ev.clientX; let mouseY = ev.clientY; if ( (mouseX >= (origTargetBox.left - fudgeFactor) && mouseX <= (origTargetBox.right + fudgeFactor) && mouseY >= (origTargetBox.top - fudgeFactor) && mouseY <= (origTargetBox.bottom + fudgeFactor)) ) { return true; } return false; } function mousemoveTimerHelper(triggeringMouseMoveEv, currTooltip) { /* Called after 500ms of the mouse being stationary, show a new tooltip * if we are over a new mouseover-able element */ e = triggeringMouseMoveEv; if (mousedNewItem && !(mouseIsOverPopup(e, currTooltip, 0))) { mousemoveController.abort(); hideMouseoverText(currTooltip); showMouseoverText(triggeringMouseMoveEv); } } function mousemoveHelper(e) { /* Helper function for deciding whether to keep a tooltip visible upon a mousemove event */ if (mousemoveTimer) { clearTimeout(mousemoveTimer); } + mousemoveTimer = setTimeout(mousemoveTimerHelper, 500, e, this); // we are moving the mouse away, hide the tooltip regardless how much time has passed if (!(mouseIsOverPopup(e, this) || mouseIsOverItem(e, this))) { mousemoveController.abort(); hideMouseoverText(this); return; } } function showMouseoverText(ev) { /* If a tooltip is not visible, show the tooltip text right away. If a tooltip * is visble, do nothing as the mousemove event helper will re-call us * after hiding the tooltip that is shown */ ev.preventDefault(); let referenceElement = lastMouseoverEle; @@ -4148,32 +4149,39 @@ ele1.setAttribute("mouseoverText", text); ele1.addEventListener("mouseover", showMouseover, {capture: true}); } } function titleTagToMouseover(mapEl) { /* for a given area tag, extract the title text into a div that can be positioned * like a standard tooltip mouseover next to the item */ addMouseover(mapEl, mapEl.title); } function convertTitleTagsToMouseovers() { /* make all the title tags in the document have mouseovers */ $("[title]").each(function(i, a) { if (a.title !== undefined && a.title.length > 0) { + if (a.title.startsWith("Click to alter the display density") || + a.title.startsWith("drag select or click to zoom") || + a.title.startsWith("click & drag to scroll")) { + // just remove these tooltips altogether + a.title = ""; + } else { titleTagToMouseover(a); } + } }); /* Mouseover should clear if you leave the document window altogether */ document.body.addEventListener("mouseleave", (ev) => { clearTimeout(mouseoverTimer); if (mousemoveController) { mousemoveController.abort(); } hideMouseoverText(mouseoverContainer); canShowNewMouseover = false; // let mouseovers show up again upon moving back in to the window // but only need the event once // use capture: true to force this event to happen // before the regular mouseover event document.body.addEventListener("mouseover", (evt) => { canShowNewMouseover = true; }, {capture: true, once: true});