The branch, master has been updated via 67ad88f355d6e541f98d41c48ade42d6f41bd477 (commit) via c06c4af74047f147ebc3fa6c4a17badd4d41dd19 (commit) via 787d393d02974b3420d8691c6d1ccc2c5dd7037d (commit) from ad3e6eeba5c083519ae36d5670b243bc02940f49 (commit)
- Log ----------------------------------------------------------------- commit 67ad88f355d6e541f98d41c48ade42d6f41bd477 Author: Madhura Jayaratne madhura.cj@gmail.com Date: Sun Dec 11 22:35:34 2011 +0530
Adjust row numbers upon deletion of a row
commit c06c4af74047f147ebc3fa6c4a17badd4d41dd19 Author: Madhura Jayaratne madhura.cj@gmail.com Date: Sun Dec 11 22:24:06 2011 +0530
Use toggleRowColors() for tracking page
commit 787d393d02974b3420d8691c6d1ccc2c5dd7037d Author: Madhura Jayaratne madhura.cj@gmail.com Date: Sun Dec 11 22:23:17 2011 +0530
Adjust row colors of the remaining rows upon deletion of a row
-----------------------------------------------------------------------
Summary of changes: js/db_structure.js | 20 +++----------------- js/functions.js | 16 ++++++++++++++++ js/tbl_structure.js | 13 ++++++++++--- 3 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/js/db_structure.js b/js/db_structure.js index dcd4532..269f2b1 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -387,16 +387,9 @@ $(document).ready(function() { $('#tracked_tables').hide("slow").remove(); } else { // There are more rows left after the deletion + toggleRowColors($curr_tracking_row.next()); $curr_tracking_row.hide("slow", function() { $(this).remove(); - // Maybe some row classes are wrong now. Iterate and correct. - var ct = 0; - var rowclass = ''; - $tracked_table.find('tbody tr').each(function() { - rowclass = (ct % 2 === 0) ? 'odd' : 'even'; - $(this).removeClass().addClass(rowclass); - ct++; - }); }); }
@@ -428,23 +421,16 @@ $(document).ready(function() { // Insert the cloned row in an appropriate location. if (tmp_tbl_name > table_name) { $cloned.insertBefore($row); + toggleRowColors($row); return false; } else { $cloned.insertAfter($row); + toggleRowColors($cloned); } } }); }
- // Maybe some row classes are wrong now. Iterate and correct. - var ct = 0; - var rowclass = ''; - $untracked_table.find('tbody tr').each(function () { - rowclass = (ct % 2 === 0) ? 'odd' : 'even'; - $(this).removeClass().addClass(rowclass); - ct++; - }); - PMA_ajaxShowMessage(data.message); } else { PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error, false); diff --git a/js/functions.js b/js/functions.js index b51ef7c..f1e1277 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3720,3 +3720,19 @@ $(document).ready(function () { ); } }); + +/** + * Toggles row colors of a set of 'tr' elements starting from a given element + * + * @param $start Starting element + */ +function toggleRowColors($start) +{ + for (var $curr_row = $start; $curr_row.length > 0; $curr_row = $curr_row.next()) { + if ($curr_row.hasClass('odd')) { + $curr_row.removeClass('odd').addClass('even'); + } else if ($curr_row.hasClass('even')) { + $curr_row.removeClass('even').addClass('odd'); + } + } +} \ No newline at end of file diff --git a/js/tbl_structure.js b/js/tbl_structure.js index 651cab0..5564bc0 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -35,11 +35,11 @@ $(document).ready(function() { /** * @var curr_row Object reference to the currently selected row (i.e. field in the table) */ - var curr_row = $(this).parents('tr'); + var $curr_row = $(this).parents('tr'); /** * @var curr_column_name String containing name of the field referred to by {@link curr_row} */ - var curr_column_name = $(curr_row).children('th').children('label').text(); + var curr_column_name = $curr_row.children('th').children('label').text(); /** * @var $after_field_item Corresponding entry in the 'After' field. */ @@ -56,8 +56,14 @@ $(document).ready(function() { $.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) { if(data.success == true) { PMA_ajaxShowMessage(data.message); + toggleRowColors($curr_row.next()); + // Adjust the row numbers + for (var $row = $curr_row.next(); $row.length > 0; $row = $row.next()) { + var new_val = parseInt($row.find('td:nth-child(2)').text()) - 1; + $row.find('td:nth-child(2)').text(new_val); + } $after_field_item.remove(); - $(curr_row).hide("medium").remove(); + $curr_row.hide("medium").remove(); } else { PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error, false); @@ -151,6 +157,7 @@ $(document).ready(function() { $table_ref.siblings('div.notice').hide('medium'); } else { // We are removing some of the rows only + toggleRowColors($rows_to_hide.last().next()); $rows_to_hide.hide("medium", function () { $(this).remove(); });
hooks/post-receive