[PATCH 2 of 2] hgweb: position the "followlines" box close to latest cursor position

Denis Laxalde denis at laxalde.org
Fri Apr 7 04:55:42 EDT 2017


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1491499444 -7200
#      Thu Apr 06 19:24:04 2017 +0200
# Node ID 59f99f6267b84e06589334b1057a98e8051fb562
# Parent  e8cc0233064b9aaf4e99efa960d857c9884266c4
# Available At http://hg.logilab.org/users/dlaxalde/hg
#              hg pull http://hg.logilab.org/users/dlaxalde/hg -r 59f99f6267b8
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 {


More information about the Mercurial-devel mailing list