# HG changeset patch # User Denis Laxalde # Date 2017-04-06 17:24:04 # Node ID 5c1abb4bd3ee20b5eb878cfef29eced92536f4a7 # Parent 7160bdd56b84aec14c7e059146f32be91d685dec hgweb: position the "followlines" box close to latest cursor position diff --git a/mercurial/templates/static/followlines.js b/mercurial/templates/static/followlines.js --- a/mercurial/templates/static/followlines.js +++ b/mercurial/templates/static/followlines.js @@ -25,6 +25,14 @@ document.addEventListener('DOMContentLoa tooltip.textContent = initTooltipText; sourcelines.appendChild(tooltip); + //* position "element" on top-right of cursor */ + function positionTopRight(element, event) { + var x = (event.clientX + 10) + 'px', + y = (event.clientY - 20) + 'px'; + element.style.top = y; + element.style.left = x; + } + var tooltipTimeoutID; //* move the "tooltip" with cursor (top-right) and show it after 1s */ function moveAndShowTooltip(e) { @@ -33,10 +41,7 @@ document.addEventListener('DOMContentLoa window.clearTimeout(tooltipTimeoutID); } tooltip.classList.add('hidden'); - var x = (e.clientX + 10) + 'px', - y = (e.clientY - 20) + 'px'; - tooltip.style.top = y; - tooltip.style.left = x; + positionTopRight(tooltip, e); tooltipTimeoutID = window.setTimeout(function() { tooltip.classList.remove('hidden'); }, 1000); @@ -152,6 +157,8 @@ document.addEventListener('DOMContentLoa var div = divAndButton[0], button = divAndButton[1]; inviteElement.appendChild(div); + // set position close to cursor (top-right) + positionTopRight(div, e); //** event handler for cancelling selection */ function cancel() { diff --git a/mercurial/templates/static/style-paper.css b/mercurial/templates/static/style-paper.css --- a/mercurial/templates/static/style-paper.css +++ b/mercurial/templates/static/style-paper.css @@ -293,7 +293,7 @@ div#followlines { border: 1px solid #CCC; border-radius: 5px; padding: 4px; - position: absolute; + position: fixed; } div.followlines-cancel {