Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a6fcf17238
126
js/sql.js
126
js/sql.js
@ -138,16 +138,10 @@ $(document).ready(function() {
|
||||
* @memberOf jQuery
|
||||
* @name sqlqueryform_submit
|
||||
*/
|
||||
$("#sqlqueryform.ajax input:submit").live('click', function(event) {
|
||||
$("#sqlqueryform.ajax").live('submit', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $form = $(this).closest("form");
|
||||
var clicked_button = $(this).attr('id');
|
||||
|
||||
if ('button_submit_query' == clicked_button) {
|
||||
$form.find("select[name=id_bookmark]").attr("value","");
|
||||
}
|
||||
|
||||
var $form = $(this);
|
||||
if (! checkSqlQuery($form[0])) {
|
||||
return false;
|
||||
}
|
||||
@ -161,78 +155,58 @@ $(document).ready(function() {
|
||||
PMA_prepareForAjaxRequest($form);
|
||||
|
||||
$.post($form.attr('action'), $form.serialize() , function(data) {
|
||||
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 {
|
||||
// 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 {
|
||||
// button_submit_bookmark
|
||||
//
|
||||
// view only
|
||||
if ('1' == data.action_bookmark) {
|
||||
$('#sqlquery').text(data.sql_query);
|
||||
// send to codemirror if possible
|
||||
setQuery(data.sql_query);
|
||||
}
|
||||
// delete
|
||||
if ('2' == data.action_bookmark) {
|
||||
$("#id_bookmark option[value='" + data.id_bookmark + "']").remove();
|
||||
}
|
||||
if (data.success == true) {
|
||||
// fade out previous messages, if any
|
||||
$('.success').fadeOut();
|
||||
$('.sqlquery_message').fadeOut();
|
||||
// show a message that stays on screen
|
||||
$('#sqlqueryform').before(data.message);
|
||||
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 {
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
}); // end $.post()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user