2011-01-14 Ojan Vafai <ojan@chromium.org>
[WebKit.git] / Websites / bugs.webkit.org / code-review.js
index 3555784dff882cdadb5c154429a502cafe0a7cac..8ab7899d677437a382a949ccaa79814e1e3a7412 100644 (file)
   }
 
   $('.lineNumber').live('click', function() {
   }
 
   $('.lineNumber').live('click', function() {
-    var line = $(this).parents('.Line');
+    var line = lineFromLineDescendant($(this));
     if (line.hasClass('commentContext'))
       trimCommentContextToBefore(previousLineFor(line), line.attr('data-comment-base-line'));
   }).live('mousedown', function() {
     in_drag_select = true;
     if (line.hasClass('commentContext'))
       trimCommentContextToBefore(previousLineFor(line), line.attr('data-comment-base-line'));
   }).live('mousedown', function() {
     in_drag_select = true;
-    $(lineFromLineDescendant(this)).addClass('selected');
+    lineFromLineDescendant($(this)).addClass('selected');
     event.preventDefault();
   });
 
     event.preventDefault();
   });
 
       return;
 
     var selected = $('.selected');
       return;
 
     var selected = $('.selected');
+
+    // Select all the lines between the first and last selected lines
+    // in case we didn't get mouseenter events for any of them.
+    var current_index = numberFrom(selected.first().attr('id'));
+    var last_index = numberFrom(selected.last().attr('id'));
+    while (current_index != last_index) {
+      $('#line' + current_index).addClass('selected')
+      current_index++;
+    }
+
+    selected = $('.selected');
     var already_has_comment = selected.last().hasClass('commentContext');
     selected.addClass('commentContext');
 
     var already_has_comment = selected.last().hasClass('commentContext');
     selected.addClass('commentContext');
 
     if (already_has_comment)
       comment_base_line = selected.last().attr('data-comment-base-line');
     else {
     if (already_has_comment)
       comment_base_line = selected.last().attr('data-comment-base-line');
     else {
-      var last = lineFromLineDescendant(selected.last()[0]);
+      var last = lineFromLineDescendant(selected.last());
       addCommentFor($(last));
       comment_base_line = last.id;
     }
       addCommentFor($(last));
       comment_base_line = last.id;
     }
   }
 
   function lineFromLineDescendant(descendant) {
   }
 
   function lineFromLineDescendant(descendant) {
-    while (descendant && !$(descendant).hasClass('Line')) {
-      descendant = descendant.parentNode;
-    }
-    return descendant;
+    return descendant.hasClass('Line') ? descendant : descendant.parents('.Line');
   }
 
   function lineFromLineContainer(lineContainer) {
   }
 
   function lineFromLineContainer(lineContainer) {