The branch, master has been updated via 516891a6b8b38c6fc0921e434318a834d2133038 (commit) from b4d96e83df4bd4a1a7eb54199879b187f4f2cda9 (commit)
- Log ----------------------------------------------------------------- commit 516891a6b8b38c6fc0921e434318a834d2133038 Author: Marc Delisle marc@infomarc.info Date: Tue Sep 20 08:47:18 2011 -0400
View only bookmark did not work with CodeMirror
-----------------------------------------------------------------------
Summary of changes: import.php | 8 ++++- js/sql.js | 109 ++++++++++++++++++++++++++++++++--------------------------- 2 files changed, 66 insertions(+), 51 deletions(-)
diff --git a/import.php b/import.php index 92859ff..12af12f 100644 --- a/import.php +++ b/import.php @@ -164,7 +164,13 @@ if (!empty($id_bookmark)) { break; case 1: // bookmarked query that have to be displayed $import_text = PMA_Bookmark_get($db, $id_bookmark); - $run_query = false; + if ($GLOBALS['is_ajax_request'] == true) { + $extra_data['sql_query'] = $import_text; + $message = PMA_Message::success(__('Showing bookmark')); + PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); + } else { + $run_query = false; + } break; case 2: // bookmarked query that have to be deleted $import_text = PMA_Bookmark_get($db, $id_bookmark); diff --git a/js/sql.js b/js/sql.js index d6e3bf9..2572c35 100644 --- a/js/sql.js +++ b/js/sql.js @@ -161,63 +161,72 @@ $(document).ready(function() { PMA_prepareForAjaxRequest($form);
$.post($form.attr('action'), $form.serialize() , function(data) { - if (data.success == true) { - // fade out previous messages, if any - $('.success').fadeOut(); - $('.sqlquery_message').fadeOut(); - // show a message that stays on screen - if (typeof data.sql_query != 'undefined') { - $('<div class="sqlquery_message"></div>') - .html(data.sql_query) - .insertBefore('#sqlqueryform'); - // unnecessary div that came from data.sql_query - $('.notice').remove(); + if ('button_submit_query' == clicked_button) { + if (data.success == true) { + // fade out previous messages, if any + $('.success').fadeOut(); + $('.sqlquery_message').fadeOut(); + // show a message that stays on screen + if (typeof data.sql_query != 'undefined') { + $('<div class="sqlquery_message"></div>') + .html(data.sql_query) + .insertBefore('#sqlqueryform'); + // unnecessary div that came from data.sql_query + $('.notice').remove(); + } else { + $('#sqlqueryform').before(data.message); + } + $sqlqueryresults.show(); + // this happens if a USE command was typed + if (typeof data.reload != 'undefined') { + // Unbind the submit event before reloading. See bug #3295529 + $("#sqlqueryform.ajax").die('submit'); + $form.find('input[name=db]').val(data.db); + // need to regenerate the whole upper part + $form.find('input[name=ajax_request]').remove(); + $form.append('<input type="hidden" name="reload" value="true" />'); + $.post('db_sql.php', $form.serialize(), function(data) { + $('body').html(data); + }); // end inner post + } + } else if (data.success == false ) { + // show an error message that stays on screen + $('#sqlqueryform').before(data.error); + $sqlqueryresults.hide(); } else { - $('#sqlqueryform').before(data.message); - } - $sqlqueryresults.show(); - // this happens if a USE command was typed - if (typeof data.reload != 'undefined') { - // Unbind the submit event before reloading. See bug #3295529 - $("#sqlqueryform.ajax").die('submit'); - $form.find('input[name=db]').val(data.db); - // need to regenerate the whole upper part - $form.find('input[name=ajax_request]').remove(); - $form.append('<input type="hidden" name="reload" value="true" />'); - $.post('db_sql.php', $form.serialize(), function(data) { - $('body').html(data); - }); // end inner post + // real results are returned + // fade out previous messages, if any + $('.success').fadeOut(); + $('.sqlquery_message').fadeOut(); + var $received_data = $(data); + var $zero_row_results = $received_data.find('textarea[name="sql_query"]'); + // if zero rows are returned from the query execution + if ($zero_row_results.length > 0) { + $('#sqlquery').val($zero_row_results.val()); + } else { + $sqlqueryresults + .show() + .html(data) + .trigger('makegrid'); + $('#togglequerybox').show(); + if ($("#togglequerybox").siblings(":visible").length > 0) { + $("#togglequerybox").trigger('click'); + } + PMA_init_slider(); + } } - } - else if (data.success == false ) { - // show an error message that stays on screen - $('#sqlqueryform').before(data.error); - $sqlqueryresults.hide(); - } - else { - // real results are returned + } else { + // button_submit_bookmark + $('#sqlquery').text(data.sql_query); + // send to codemirror if possible + setQuery(data.sql_query); // fade out previous messages, if any $('.success').fadeOut(); $('.sqlquery_message').fadeOut(); - var $received_data = $(data); - var $zero_row_results = $received_data.find('textarea[name="sql_query"]'); - // if zero rows are returned from the query execution - if ($zero_row_results.length > 0) { - $('#sqlquery').val($zero_row_results.val()); - } else { - $sqlqueryresults - .show() - .html(data) - .trigger('makegrid'); - $('#togglequerybox').show(); - if ($("#togglequerybox").siblings(":visible").length > 0) { - $("#togglequerybox").trigger('click'); - } - PMA_init_slider(); - } + // show a message that stays on screen + $('#sqlqueryform').before(data.message); } PMA_ajaxRemoveMessage($msgbox); - }) // end $.post() }) // end SQL Query submit
hooks/post-receive