From c47a1a345a94277b342edf883c1e22ea1d7d0367 Mon Sep 17 00:00:00 2001 From: ninadsp Date: Thu, 15 Jul 2010 16:01:25 +0530 Subject: [PATCH] Started Ajaxification of Inline Editing. Simple data fields are replaced with textareas when edit button is clicked and vice versa. No provision yet for transformations and enum fields --- js/sql.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/js/sql.js b/js/sql.js index b531b1336..649f0ae5c 100644 --- a/js/sql.js +++ b/js/sql.js @@ -7,6 +7,12 @@ $(document).ready(function() { + var disp_mode = $("#top_direction_dropdown").val(); + + $("#top_direction_dropdown, #bottom_direction_dropdown").live('change', function(event) { + disp_mode = $(this).val(); + }) + $('') .html(PMA_messages['strToggleQueryBox']) .appendTo("#sqlqueryform"); @@ -73,4 +79,44 @@ $(document).ready(function() { $("#sqlqueryresults").html(data); }) })//end Sort results table + + $(".edit_row_anchor").live('click', function(event) { + event.preventDefault(); + + $(this).removeClass('edit_row_anchor').addClass('edit_row_anchor_active'); + + if(disp_mode == 'vertical') { + var this_row_index = $(this).index(); + var input_siblings = $(this).parents('tbody').find('tr').find('.data_inline_edit:nth('+this_row_index+')'); + } + else { + var input_siblings = $(this).parent('tr').find('.data_inline_edit'); + } + + $(input_siblings).each(function() { + var data_value = $(this).html(); + + $(this).html(''); + }) + }) + + $(".edit_row_anchor_active").live('click', function(event) { + event.preventDefault(); + + $(this).removeClass('edit_row_anchor_active').addClass('edit_row_anchor'); + + if(disp_mode == 'vertical') { + var this_row_index = $(this).index(); + var input_siblings = $(this).parents('tbody').find('tr').find('.data_inline_edit:nth('+this_row_index+')'); + } + else { + var input_siblings = $(this).parent('tr').find('.data_inline_edit'); + } + + $(input_siblings).each(function() { + var new_data_value = $(this).find('textarea').html(); + + $(this).html(new_data_value); + }) + }) }) \ No newline at end of file