From b97aeef6b6a71519af3cf39b2866629a472ea283 Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Tue, 28 Jun 2011 10:25:11 +0800 Subject: [PATCH] Fix bug in shift+click --- js/functions.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/js/functions.js b/js/functions.js index 836671ab70..95f3b9f020 100644 --- a/js/functions.js +++ b/js/functions.js @@ -643,14 +643,15 @@ $(document).ready(function() { } else { $tr.removeClass('marked'); } + last_click_checked = checked; } else { // normaln data table, just toggle class $tr.toggleClass('marked'); + last_click_checked = false; } // remember the last clicked row - last_click_checked = checked; - last_clicked_row = $tr.index(); + last_clicked_row = last_click_checked ? $('tr.odd:not(.noclick), tr.even:not(.noclick)').index(this) : -1; last_shift_clicked_row = -1; } else { // handle the shift click @@ -665,7 +666,7 @@ $(document).ready(function() { start = last_shift_clicked_row; end = last_clicked_row; } - $tr.parent().find('tr:not(.noclick)') + $tr.parent().find('tr.odd:not(.noclick), tr.even:not(.noclick)') .slice(start, end + 1) .removeClass('marked') .find(':checkbox') @@ -673,7 +674,7 @@ $(document).ready(function() { } // handle new shift click - var curr_row = $tr.index(); + var curr_row = $('tr.odd:not(.noclick), tr.even:not(.noclick)').index(this); if (curr_row >= last_clicked_row) { start = last_clicked_row; end = curr_row; @@ -681,11 +682,11 @@ $(document).ready(function() { start = curr_row; end = last_clicked_row; } - $tr.parent().find('tr:not(.noclick)') + $tr.parent().find('tr.odd:not(.noclick), tr.even:not(.noclick)') .slice(start, end + 1) - .toggleClass('marked', last_click_checked) + .addClass('marked') .find(':checkbox') - .attr('checked', last_click_checked); + .attr('checked', true); // remember the last shift clicked row last_shift_clicked_row = curr_row;