The branch, master has been updated via f599afd843befcbe98771d0129bc2bb1405bdb4d (commit) via ed00eea0a363f463a784a96caf5ddc0a702ea3c1 (commit) via 0068d42f73a1493d2ea05f729b2b7fa0afd80367 (commit) via 2e2474eb682f72389d90a9e5dbf8da32ec2ce1fe (commit) from 7ef6fbaabc39289ee743811e4a62fedd343b8a8a (commit)
- Log ----------------------------------------------------------------- commit f599afd843befcbe98771d0129bc2bb1405bdb4d Author: Madhura Jayaratne madhura.cj@gmail.com Date: Sat Mar 12 08:18:11 2011 +0530
Proper indentation.
commit ed00eea0a363f463a784a96caf5ddc0a702ea3c1 Author: Madhura Jayaratne madhura.cj@gmail.com Date: Sat Mar 12 08:09:46 2011 +0530
Code formatting. Make the code more readable.
commit 0068d42f73a1493d2ea05f729b2b7fa0afd80367 Author: Madhura Jayaratne madhura.cj@gmail.com Date: Sat Mar 12 07:59:29 2011 +0530
Optimize. We can do what is being done in two for-loops in one for-loop and avoid unnecessary temporary variables.
commit 2e2474eb682f72389d90a9e5dbf8da32ec2ce1fe Author: Madhura Jayaratne madhura.cj@gmail.com Date: Sat Mar 12 07:52:45 2011 +0530
Identify non inline-editable columns based on class 'inline_edit'.
-----------------------------------------------------------------------
Summary of changes: js/sql.js | 106 +++++++++++++++++++++++------------------------------------- 1 files changed, 41 insertions(+), 65 deletions(-)
diff --git a/js/sql.js b/js/sql.js index b513ffb..1c46c05 100644 --- a/js/sql.js +++ b/js/sql.js @@ -423,101 +423,77 @@ $(document).ready(function() { // looping through all columns or rows, to find the required data and then storing it in an array.
var $this_children = $(this).children('span.nowrap').children('a').children('span.nowrap'); - if (disp_mode != 'vertical'){ + if (disp_mode != 'vertical') { $this_children.empty(); $this_children.text(PMA_messages['strSave']); } else { - // vertical + // vertical data_vt = $this_children.html(); $this_children.text(PMA_messages['strSave']); }
var hide_link = '<br /><br /><a id="hide">' + PMA_messages['strHide'] + '</a>'; - if (disp_mode != 'vertical'){ + if (disp_mode != 'vertical') { $(this).append(hide_link); - $('#table_results tbody tr td a#hide').click(function(){ + $('#table_results tbody tr td a#hide').click(function() { $this_children = $(this).siblings('span.nowrap').children('a').children('span.nowrap'); $this_children.empty(); $this_children.text(PMA_messages['strInlineEdit']); + var $this_hide = $(this).parent(); $this_hide.removeClass("inline_edit_active hover").addClass("inline_edit_anchor"); $this_hide.parent().removeClass("hover"); $this_hide.siblings().removeClass("hover"); + var last_column = $this_hide.siblings().length; - var txt = []; - var blob_index = []; - var k = 0; - for(var i = 4; i < last_column; i++){ - if($this_hide.siblings("td:eq(" + i + ")").children('a:eq(0)').length ){ - blob_index[k] = i; - k++; - continue; - } - txt[i - 4] = $this_hide.siblings("td:eq(" + i + ")").children(' .original_data').html(); - } - k = 0; - for (var i = 4; i < last_column; i++){ - if ( blob_index[k] == i){ - k++; + var txt = ''; + for(var i = 4; i < last_column; i++) { + if($this_hide.siblings("td:eq(" + i + ")").hasClass("inline_edit") == false) { continue; } - if($this_hide.siblings("td:eq(" + i + ")").children().length !=0){ + txt = $this_hide.siblings("td:eq(" + i + ")").children(' .original_data').html(); + 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[i-4]); + $this_hide.siblings("td:eq(" + i + ")").append(txt); } } $(this).prev().prev().remove(); $(this).prev().remove(); $(this).remove(); - }); + }); } else { - var txt=[]; - var rows=$(this).parent().siblings().length;; + var txt = ''; + var rows = $(this).parent().siblings().length;
$(this).append(hide_link); - $('#table_results tbody tr td a#hide').click(function(){ - - var pos=$(this).parent().index(); - var $chg_submit=$(this).parent().children('span.nowrap').children('a').children('span.nowrap'); - $chg_submit.empty(); - $chg_submit.append(data_vt); - - var $this_row=$(this).parent().parent(); - //alert(pos); - if(parseInt(pos)%2==0){ - $this_row.siblings("tr:eq(3) td:eq(" + pos + ")").removeClass("odd edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_active").addClass("odd edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_anchor"); - - $this_row.siblings("tr:eq(3) td:eq(" + pos + ")").removeClass("odd edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_active hover").addClass("odd edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_anchor"); - } else { - $this_row.siblings("tr:eq(3) td:eq(" + pos + ")").removeClass("even edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_active").addClass("even edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_anchor"); + $('#table_results tbody tr td a#hide').click(function() { + var pos = $(this).parent().index(); + var $chg_submit = $(this).parent().children('span.nowrap').children('a').children('span.nowrap'); + $chg_submit.empty(); + $chg_submit.append(data_vt);
- $this_row.siblings("tr:eq(3) td:eq(" + pos + ")").removeClass("even edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_active hover").addClass("even edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_anchor"); + var $this_row = $(this).parent().parent(); + if(parseInt(pos) % 2 == 0) { + $this_row.siblings("tr:eq(3) td:eq(" + pos + ")").removeClass("odd edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_active").addClass("odd edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_anchor");
+ $this_row.siblings("tr:eq(3) td:eq(" + pos + ")").removeClass("odd edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_active hover").addClass("odd edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_anchor"); + } else { + $this_row.siblings("tr:eq(3) td:eq(" + pos + ")").removeClass("even edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_active").addClass("even edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_anchor"); + + $this_row.siblings("tr:eq(3) td:eq(" + pos + ")").removeClass("even edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_active hover").addClass("even edit_row_anchor row_" + pos + " vpointer vmarker inline_edit_anchor"); + } + for( var i = 6; i <= rows + 2; i++){ + if( $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").hasClass("inline_edit") == false) { + continue; } - var blob_index = []; - var k = 0; - for( var i = 6; i <= rows + 2; i++){ - if( $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ") a:eq(0)").length !=0 ){ - blob_index[k] = i; - k++; - continue; - } - txt[i - 6] = $this_row.siblings("tr:eq(" + i + ") td:eq("+pos+") span.original_data").html(); - } - k = 0; - for (var i = 6; i <= rows + 2; i++){ - if(blob_index[k] == i){ - k++; - continue; - } - $this_row.siblings("tr:eq("+i+") td:eq("+pos+")").empty(); - $this_row.siblings("tr:eq("+i+") td:eq("+pos+")").append(txt[ i - 6]); - } - $(this).prev().remove(); - $(this).prev().remove(); - $(this).remove(); - - }); + txt = $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ") span.original_data").html(); + $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").empty(); + $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").append(txt); + } + $(this).prev().remove(); + $(this).prev().remove(); + $(this).remove(); + }); }
// Initialize some variables
hooks/post-receive