The branch, master has been updated via d83e6e2b8503d81bc5e298f4311d8d2ab11974bb (commit) from c1a994bce2205c4999e2e5570a0171777b0604ec (commit)
- Log ----------------------------------------------------------------- commit d83e6e2b8503d81bc5e298f4311d8d2ab11974bb Author: Marc Delisle marc@infomarc.info Date: Tue Mar 22 07:30:17 2011 -0400
Use jQuery .data() mechanism
-----------------------------------------------------------------------
Summary of changes: js/sql.js | 31 +++++++++++++------------------ 1 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/js/sql.js b/js/sql.js index acd9c8d..e06b622 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 <td> - // 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 <td>. + // For "hide" button the original data to be restored is + // kept in the jQuery data element 'original_data' inside the <td>. + // 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_<field_name>_<row_index>' is clicked empty the corresponding select/editor. + // if 'checkbox_null_<field_name>_<row_index>' 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('<textarea>'+data_value+'</textarea>'); - $this_field.append('<span class="original_data">'+data_value+'</span>'); - $(".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('<textarea>'+data.value+'</textarea>'); - $this_field.append('<span class="original_data">'+data_value+'</span>'); - $(".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('<span class="original_data">'+data_value+'</span>'); - $(".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('<span class="original_data">'+data_value+'</span>'); - $(".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('<span class="original_data">'+data_value+'</span>'); - $(".original_data").hide(); + $this_field.data('original_data', data_value); }) // end $.post() } else if($this_field.is('.null')) { //handle null fields $this_field.append('<textarea></textarea>'); - $this_field.append('<span class="original_data">NULL</span>'); - $(".original_data").hide(); + $this_field.data('original_data', 'NULL'); } }) }) // End On click, replace the current field with an input/textarea
hooks/post-receive