Patchwork [2,of,3] hgweb: rely on a specific class to change cursor type in followlines UI

login
register
mail settings
Submitter Denis Laxalde
Date April 3, 2017, 8:33 a.m.
Message ID <99f5eb0cb78b74e418a2.1491208432@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/19926/
State Accepted
Headers show

Comments

Denis Laxalde - April 3, 2017, 8:33 a.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1491206316 -7200
#      Mon Apr 03 09:58:36 2017 +0200
# Node ID 99f5eb0cb78b74e418a2035dde180381a0b89622
# Parent  0ac235a0ef4f08d227d96de458a91cbaff46dc92
# Available At http://hg.logilab.org/users/dlaxalde/hg
#              hg pull http://hg.logilab.org/users/dlaxalde/hg -r 99f5eb0cb78b
hgweb: rely on a specific class to change cursor type in followlines UI

The previous CSS rule would also apply in pages where followlines UI was not
available (e.g. "changeset" view at /rev/<node>/). We insert a
"followlines-select" class in JavaScript on actually selectable lines and
restrict the CSS selector to use it.

Patch

diff --git a/mercurial/templates/static/linerangelog.js b/mercurial/templates/static/linerangelog.js
--- a/mercurial/templates/static/linerangelog.js
+++ b/mercurial/templates/static/linerangelog.js
@@ -22,6 +22,11 @@  document.addEventListener('DOMContentLoa
         sourcelines.children,
         function(x) { return x.tagName === 'SPAN' });
 
+    // add a "followlines-select" class to change cursor type in CSS
+    for (var i = 0; i < spans.length; i++) {
+        spans[i].classList.add('followlines-select');
+    }
+
     var lineSelectedCSSClass = 'followlines-selected';
 
     //** add CSS class on <span> element in `from`-`to` line range */
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
@@ -280,7 +280,7 @@  td.annotate:hover div.annotate-info { di
   background-color: #bfdfff;
 }
 
-div.overflow pre.sourcelines > span:hover {
+div.overflow pre.sourcelines > span.followlines-select:hover {
   cursor: cell;
 }