7521b06e6b18

web: add hovering on comments to highlight lines
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 13 Jun 2010 02:11:28 -0400
parents 805b5a153985
children 444f6ef08d88
branches/tags (none)
files kick review/static/comments.js review/static/style.css review/static/style.less review/templates/diff.html review/web_ui.py

Changes

--- a/kick	Sun Jun 13 01:53:09 2010 -0400
+++ b/kick	Sun Jun 13 02:11:28 2010 -0400
@@ -3,4 +3,5 @@
 kicker -qs -l 0.1 -e reload_safari \
 review/**.py \
 review/**/*.html \
-review/**/*.less
+review/**/*.less \
+review/**/*.js
--- a/review/static/comments.js	Sun Jun 13 01:53:09 2010 -0400
+++ b/review/static/comments.js	Sun Jun 13 02:11:28 2010 -0400
@@ -11,6 +11,16 @@
         $(event.target).parents("form").hide();
         return false;
     });
+
+    $("tr.comment").hover(function(event) {
+        var diff = $(event.target).closest(".diff");
+        var lines = $(event.target).find(".commentlines").html().split(",");
+        for (i=0; i < lines.length; i++) {
+            diff.find(".line-" + lines[i]).addClass("viewing");
+        }
+    }, function(event) {
+        $(".viewing").removeClass("viewing");
+    });
     
     //$("span.cancel-line a").live("click", function(event) {
         //$(event.target).closest("tr").prev().removeClass("comment-line-selected").addClass("commentable");
--- a/review/static/style.css	Sun Jun 13 01:53:09 2010 -0400
+++ b/review/static/style.css	Sun Jun 13 02:11:28 2010 -0400
@@ -450,6 +450,9 @@
   border: 1px solid #ddd;
   background-color: #f9f9f9;
 }
+#changeset .content .diff table tr.viewing {
+  background-color: #f2f2d7;
+}
 #changeset .content .diff table td.code:after {
   color: #ccc;
   content: "↩";
--- a/review/static/style.less	Sun Jun 13 01:53:09 2010 -0400
+++ b/review/static/style.less	Sun Jun 13 02:11:28 2010 -0400
@@ -402,6 +402,9 @@
             border: 1px solid #ddd;
             background-color: #f9f9f9;
 
+            tr.viewing {
+                background-color: lighten(@c-cream, 5%);
+            }
             td.code:after {
                 color: #ccc;
                 content: "↩";
--- a/review/templates/diff.html	Sun Jun 13 01:53:09 2010 -0400
+++ b/review/templates/diff.html	Sun Jun 13 02:11:28 2010 -0400
@@ -30,7 +30,7 @@
                     </td></tr>
                 {% endfor %}
             {% else %}
-                <tr class="{{ utils['line_type'](line['content']) }}{% if not read_only %} commentable {% endif %}">
+            <tr class="{{ utils['line_type'](line['content']) }}{% if not read_only %} commentable {% endif %} line-{{ line['number'] }}">
                     <td class="linenumber">{{ line['number'] }}</td>
                     <td class="code"><code>{{ line['content'][1:]|escape }}</code></td>
                 </tr>
@@ -41,6 +41,7 @@
                     {% for comment in comments %}
                         <tr class="comment">
                             <td class="comment group" colspan="2">
+                                <span class="commentlines disabled">{{ ','.join(utils['map'](utils['str'], comment.lines)) }}</span>
                                 {{ macros.gravatar(comment, utils) }}
                                 <div>
                                     <div class="author">
--- a/review/web_ui.py	Sun Jun 13 01:53:09 2010 -0400
+++ b/review/web_ui.py	Sun Jun 13 02:11:28 2010 -0400
@@ -55,6 +55,8 @@
     'item_gravatar': _item_gravatar,
     'line_type': _line_type,
     'categorize_signoffs': _categorize_signoffs,
+    'map': map,
+    'str': str,
 }
 
 datastore = None