89e3867fdfe87e87227745aeaa56f8fd9c43faec chmalee Tue Feb 20 14:28:30 2024 -0800 Remove unused arguments and nop lines after mouseover refactoring, noticed by Angie's code review, refs #33002 diff --git src/hg/js/utils.js src/hg/js/utils.js index 628ee07..0cb4979 100644 --- src/hg/js/utils.js +++ src/hg/js/utils.js @@ -3982,47 +3982,47 @@ } function mouseIsOverItem(ev, ele, fudgeFactor=25) { /* 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, originalEl) { +function mousemoveTimerHelper(triggeringMouseMoveEv, currTooltip) { /* Called after 100ms 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, originalEl); + 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, 100, e, this, lastMouseoverEle); + mousemoveTimer = setTimeout(mousemoveTimerHelper, 100, 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 viisble, do nothing as the mousemove event helper will re-call us * after hiding the tooltip that is shown */ ev.preventDefault(); let referenceElement = lastMouseoverEle; @@ -4124,35 +4124,33 @@ function addMouseover(ele1, text = null, ele2 = null) { /* Adds wrapper elements to control various mouseover events */ if (!mouseoverContainer) { mouseoverContainer = document.createElement("div"); mouseoverContainer.className = "tooltip"; mouseoverContainer.style.position = "fixed"; mouseoverContainer.style.display = "inline-block"; mouseoverContainer.style.visibility = "hidden"; mouseoverContainer.style.opacity = "0"; mouseoverContainer.id = "mouseoverContainer"; let tooltipTextSize = localStorage.getItem("tooltipTextSize"); if (tooltipTextSize === null) {tooltipTextSize = window.browserTextSize;} mouseoverContainer.style.fontSize = tooltipTextSize + "px"; document.body.append(mouseoverContainer); } - // create a mouseover element out of text, or, if text is null, use already - // created ele2 and just show it - newEl = ele2; - ele1.setAttribute("mouseoverText", text); + if (ele1) { + 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) { titleTagToMouseover(a);