From d83e6e2b8503d81bc5e298f4311d8d2ab11974bb Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Tue, 22 Mar 2011 07:30:17 -0400 Subject: [PATCH] Use jQuery .data() mechanism --- js/sql.js | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/js/sql.js b/js/sql.js index acd9c8d54..e06b6225f 100644 --- a/js/sql.js +++ b/js/sql.js @@ -420,9 +420,10 @@ $(document).ready(function() { var $edit_td = $(this).parents('td'); $edit_td.removeClass('inline_edit_anchor').addClass('inline_edit_active').parent('tr').addClass('noclick'); - // adding submit and hide buttons to inline edit - // for "hide", button the original data to be restored is present in .original_data - // looping through all columns or rows, to find the required data and then storing it in an array. + // Adding submit and hide buttons to inline edit . + // For "hide" button the original data to be restored is + // kept in the jQuery data element 'original_data' inside the . + // Looping through all columns or rows, to find the required data and then storing it in an array. var $this_children = $edit_td.children('span.nowrap').children('a').children('span.nowrap'); if (disp_mode != 'vertical') { @@ -453,7 +454,7 @@ $(document).ready(function() { if($this_hide.siblings("td:eq(" + i + ")").hasClass("inline_edit") == false) { continue; } - txt = $this_hide.siblings("td:eq(" + i + ")").children(' .original_data').html(); + txt = $this_hide.siblings("td:eq(" + i + ")").data('original_data'); if($this_hide.siblings("td:eq(" + i + ")").children().length != 0) { $this_hide.siblings("td:eq(" + i + ")").empty(); $this_hide.siblings("td:eq(" + i + ")").append(txt); @@ -485,7 +486,7 @@ $(document).ready(function() { if( $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").hasClass("inline_edit") == false) { continue; } - txt = $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ") span.original_data").html(); + txt = $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").data('original_data'); $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").empty(); $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").append(txt); } @@ -572,7 +573,7 @@ $(document).ready(function() { }) } - // if 'chechbox_null__' is clicked empty the corresponding select/editor. + // if 'checkbox_null__' is clicked empty the corresponding select/editor. $('.checkbox_null_' + field_name + '_' + this_row_index).bind('click', function(e) { if ($this_field.is('.enum')) { $this_field.find('select').attr('value', ''); @@ -604,8 +605,7 @@ $(document).ready(function() { // handle non-truncated, non-transformed, non-relation values // We don't need to get any more data, just wrap the value $this_field.append(''); - $this_field.append(''+data_value+''); - $(".original_data").hide(); + $this_field.data('original_data', data_value); } else if($this_field.is('.truncated, .transformed')) { /** @lends jQuery */ @@ -626,8 +626,7 @@ $(document).ready(function() { }, function(data) { if(data.success == true) { $this_field.append(''); - $this_field.append(''+data_value+''); - $(".original_data").hide(); + $this_field.data('original_data', data_value); } else { PMA_ajaxShowMessage(data.error); @@ -653,8 +652,7 @@ $(document).ready(function() { $.post('sql.php', post_params, function(data) { $this_field.append(data.dropdown); - $this_field.append(''+data_value+''); - $(".original_data").hide(); + $this_field.data('original_data', data_value); }) // end $.post() } else if($this_field.is('.enum')) { @@ -676,8 +674,7 @@ $(document).ready(function() { $.post('sql.php', post_params, function(data) { $this_field.append(data.dropdown); - $this_field.append(''+data_value+''); - $(".original_data").hide(); + $this_field.data('original_data', data_value); }) // end $.post() } else if($this_field.is('.set')) { @@ -699,15 +696,13 @@ $(document).ready(function() { $.post('sql.php', post_params, function(data) { $this_field.append(data.select); - $this_field.append(''+data_value+''); - $(".original_data").hide(); + $this_field.data('original_data', data_value); }) // end $.post() } else if($this_field.is('.null')) { //handle null fields $this_field.append(''); - $this_field.append('NULL'); - $(".original_data").hide(); + $this_field.data('original_data', 'NULL'); } }) }) // End On click, replace the current field with an input/textarea