The branch, master has been updated via 0242446e4682cff050e2c61f151a266b1b86bc83 (commit) via 555f5fa8c4878ac3a15f7145e394a2bf724e2c07 (commit) via 2630f3e34c4d445468a28b121fbaef29183bd029 (commit) from 7cbaf739e40a2642d0a3176a8cf961bfdea8ec75 (commit)
- Log ----------------------------------------------------------------- commit 0242446e4682cff050e2c61f151a266b1b86bc83 Author: Marc Delisle marc@infomarc.info Date: Sat Mar 5 07:13:43 2011 -0500
Localize hide/submit messages Replace submit with Save (an existing message)
commit 555f5fa8c4878ac3a15f7145e394a2bf724e2c07 Author: Marc Delisle marc@infomarc.info Date: Sat Mar 5 06:57:24 2011 -0500
Remove author name from variable name Tidy jQuery code Proper indentation
commit 2630f3e34c4d445468a28b121fbaef29183bd029 Author: onebighack onebighack@users.sourceforge.net Date: Sat Mar 5 06:22:50 2011 -0500
Patch #3195202 Inline edit Hide
-----------------------------------------------------------------------
Summary of changes: js/messages.php | 2 + js/sql.js | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 99 insertions(+), 8 deletions(-)
diff --git a/js/messages.php b/js/messages.php index fc28b2e..9da01ca 100644 --- a/js/messages.php +++ b/js/messages.php @@ -86,6 +86,8 @@ $js_messages['strSearching'] = __('Searching'); $js_messages['strHideQueryBox'] = __('Hide query box'); $js_messages['strShowQueryBox'] = __('Show query box'); $js_messages['strInlineEdit'] = __('Inline Edit'); +$js_messages['strSave'] = __('Save'); +$js_messages['strHide'] = __('Hide');
/* For tbl_select.js */ $js_messages['strHideSearchCriteria'] = __('Hide search criteria'); diff --git a/js/sql.js b/js/sql.js index 1cbbca2..3e0388e 100644 --- a/js/sql.js +++ b/js/sql.js @@ -13,6 +13,7 @@ * @param string str * @return string the URL-decoded string */ +var data_vt; function PMA_urldecode(str) { return decodeURIComponent(str.replace(/+/g, '%20')); } @@ -408,9 +409,83 @@ $(document).ready(function() { $(".inline_edit_anchor").live('click', function(event) { /** @lends jQuery */ event.preventDefault(); - $(this).removeClass('inline_edit_anchor').addClass('inline_edit_active');
+ // 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. + + var $this_children = $(this).children('span.nowrap').children('a').children('span.nowrap'); + if (disp_mode != 'vertical'){ + $this_children.empty(); + $this_children.text(PMA_messages['strSave']); + } else { + // 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'){ + $(this).append(hide_link); + $('#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"); + var last_column = $this_hide.siblings().length; + var txt=[]; + for(var i=4; i < last_column; i++){ + txt[i-4] = $this_hide.siblings("td:eq(" + i + ")").children(' .original_data').text(); + } + for (var i=4; i < last_column; i++){ + $this_hide.siblings("td:eq(" + i + ")").empty(); + $this_hide.siblings("td:eq(" + i + ")").append(txt[i-4]); + } + $(this).prev().prev().remove(); + $(this).prev().remove(); + $(this).remove(); + }); + } else { + 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"); + + $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++){ + txt[i-6]=$this_row.siblings("tr:eq("+i+") td:eq("+pos+") span.original_data").text(); + } + for (var i=6;i<=rows+2;i++){ + $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(); + + }); + } + // Initialize some variables if(disp_mode == 'vertical') { /** @@ -636,8 +711,9 @@ $(document).ready(function() { * @see PMA_ajaxShowMessage() * @see getFieldName() */ - $(".inline_edit_active").live('click', function(event) { + $(".inline_edit_active span a").live('click', function(event) { /** @lends jQuery */ + event.preventDefault();
/** @@ -646,8 +722,7 @@ $(document).ready(function() { * being edited * */ - var $this_td = $(this); - + var $this_td = $(this).parent().parent(); var $test_element = ''; // to test the presence of a element
// Initialize variables @@ -665,8 +740,7 @@ $(document).ready(function() { * @var where_clause String containing the WHERE clause to select this row */ var where_clause = $this_td.parents('tbody').find('tr').find('.where_clause:nth('+this_td_index+')').val(); - } - else { + } else { var $input_siblings = $this_td.parent('tr').find('.inline_edit'); var where_clause = $this_td.parent('tr').find('.where_clause').val(); } @@ -705,7 +779,7 @@ $(document).ready(function() { /** * @var this_field Object referring to this field (<td>) */ - var $this_field = $(this); + var $this_field = $(this); /** * @var field_name String containing the name of this field. * @see getFieldName() @@ -756,7 +830,6 @@ $(document).ready(function() { $.extend(relation_fields, this_field_params); } } - sql_query += ' ' + field_name + "='" + this_field_params[field_name].replace(/'/g, "''") + "' , "; } }) @@ -794,8 +867,24 @@ $(document).ready(function() { 'submit_type' : 'save' };
+ // if inline_edit is successful, we need to go back to default view + var $del_hide=$(this).parent(); + var $chg_submit=$(this); + $.post('tbl_replace.php', post_params, function(data) { if(data.success == true) { + // deleting the hide button if my query was successful + // remove <br><br><a> tags + for ( var i=0;i<=2;i++) { $del_hide.next().remove(); } + if(disp_mode!='vertical'){ + $chg_submit.empty(); + $chg_submit.text(PMA_messages['strInlineEdit']); + } + else { + $chg_submit.children('span.nowrap').empty(); + $chg_submit.children('span.nowrap').append(data_vt); + } + PMA_ajaxShowMessage(data.message); $this_td.removeClass('inline_edit_active').addClass('inline_edit_anchor');
hooks/post-receive