Changeset 76268 in webkit


Ignore:
Timestamp:
Jan 20, 2011 11:21:40 AM (13 years ago)
Author:
ojan@chromium.org
Message:

2011-01-14 Ojan Vafai <ojan@chromium.org>

Reviewed by Adam Barth.

make line selection have a extend only from where you start the selection in the code review tool
https://bugs.webkit.org/show_bug.cgi?id=52485

  • code-review.js:
Location:
trunk/Websites/bugs.webkit.org
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Websites/bugs.webkit.org/ChangeLog

    r76082 r76268  
     12011-01-14  Ojan Vafai  <ojan@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        make line selection have a extend only from where you start the selection in the code review tool
     6        https://bugs.webkit.org/show_bug.cgi?id=52485
     7
     8        * code-review.js:
     9
    1102011-01-18  Ojan Vafai  <ojan@chromium.org>
    211
  • trunk/Websites/bugs.webkit.org/code-review.js

    r76082 r76268  
    10581058  }
    10591059
    1060   var in_drag_select = false;
     1060  var drag_select_start_index = -1;
    10611061
    10621062  function stopDragSelect() {
    10631063    $('.selected').removeClass('selected');
    1064     in_drag_select = false;
     1064    drag_select_start_index = -1;
    10651065  }
    10661066
     
    10851085      trimCommentContextToBefore(previousLineFor(line), line.attr('data-comment-base-line'));
    10861086  }).live('mousedown', function() {
    1087     in_drag_select = true;
    1088     lineFromLineDescendant($(this)).addClass('selected');
     1087    var line = lineFromLineDescendant($(this));
     1088    drag_select_start_index = numberFrom(line.attr('id'));
     1089    line.addClass('selected');
    10891090    event.preventDefault();
    10901091  });
    10911092
    1092   $('.LineContainer').live('mouseenter', function() {
    1093     if (!in_drag_select)
    1094       return;
    1095 
    1096     var line = lineFromLineContainer(this);
    1097     line.addClass('selected');
    1098   }).live('mouseup', function() {
    1099     if (!in_drag_select)
    1100       return;
    1101 
    1102     var selected = $('.selected');
    1103 
    1104     // Select all the lines between the first and last selected lines
    1105     // in case we didn't get mouseenter events for any of them.
    1106     var current_index = numberFrom(selected.first().attr('id'));
    1107     var last_index = numberFrom(selected.last().attr('id'));
    1108     while (current_index != last_index) {
     1093  function selectTo(focus_index) {
     1094    var selected = $('.selected').removeClass('selected');
     1095    var is_backward = drag_select_start_index > focus_index;
     1096    var current_index = is_backward ? focus_index : drag_select_start_index;
     1097    var last_index = is_backward ? drag_select_start_index : focus_index;
     1098    while (current_index <= last_index) {
    11091099      $('#line' + current_index).addClass('selected')
    11101100      current_index++;
    11111101    }
    1112 
    1113     selected = $('.selected');
     1102  }
     1103
     1104  function selectToLineContainer(line_container) {
     1105    var line = lineFromLineContainer(line_container);
     1106    selectTo(numberFrom(line.attr('id')));
     1107  }
     1108
     1109  $('.LineContainer').live('mouseenter', function() {
     1110    if (drag_select_start_index == -1)
     1111      return;
     1112    selectToLineContainer(this);
     1113  }).live('mouseup', function() {
     1114    if (drag_select_start_index == -1)
     1115      return;
     1116
     1117    selectToLineContainer(this);
     1118
     1119    var selected = $('.selected');
    11141120    var already_has_comment = selected.last().hasClass('commentContext');
    11151121    selected.addClass('commentContext');
Note: See TracChangeset for help on using the changeset viewer.