diff --git a/js/functions.js b/js/functions.js index 58ad805911..ee83b8acfd 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1992,7 +1992,7 @@ $(document).ready(function() { **/ $("#alterTableOrderby.ajax").live('submit', function(event) { event.preventDefault(); - $form = $(this); + var $form = $(this); PMA_prepareForAjaxRequest($form); /*variables which stores the common attributes*/ @@ -2010,9 +2010,9 @@ $(document).ready(function() { $("#result_query .notice").remove(); $("#result_query").prepend((data.message)); } else { - $temp_div = $("
") + var $temp_div = $("") $temp_div.html(data.error); - $error = $temp_div.find("code").addClass("error"); + var $error = $temp_div.find("code").addClass("error"); PMA_ajaxShowMessage($error); } }) // end $.post() @@ -2023,7 +2023,7 @@ $(document).ready(function() { **/ $("#copyTable.ajax input[name='submit_copy']").live('click', function(event) { event.preventDefault(); - $form = $("#copyTable"); + var $form = $("#copyTable"); if($form.find("input[name='switch_to_new']").attr('checked')) { $form.append(''); $form.removeClass('ajax'); @@ -2052,15 +2052,53 @@ $(document).ready(function() { window.parent.frame_navigation.location.reload(); } } else { - $temp_div = $("") + var $temp_div = $(""); $temp_div.html(data.error); - $error = $temp_div.find("code").addClass("error"); + var $error = $temp_div.find("code").addClass("error"); PMA_ajaxShowMessage($error); } }) // end $.post() } });//end of copyTable ajax submit + /** + *Ajax events for actions in the "Table maintenance" + **/ + $("#tbl_maintenance.ajax li a.maintain_action").live('click', function(event) { + event.preventDefault(); + var $link = $(this); + var href = $link.attr("href"); + href = href.split('?'); + if ($("#sqlqueryresults").length != 0) { + $("#sqlqueryresults").remove(); + } + if ($("#result_query").length != 0) { + $("#result_query").remove(); + } + //variables which stores the common attributes + $.post(href[0], href[1]+"&ajax_request=true", function(data) { + if (data.success == undefined) { + var $temp_div = $(""); + $temp_div.html(data); + var $success = $temp_div.find("#result_query .success"); + PMA_ajaxShowMessage($success); + $("").insertAfter("#topmenucontainer"); + $("#sqlqueryresults").html(data); + PMA_init_slider(); + $("#sqlqueryresults").children("fieldset").remove(); + } else if (data.success == true ) { + PMA_ajaxShowMessage(data.message); + $("").insertAfter("#topmenucontainer"); + $("#sqlqueryresults").html(data.sql_query); + } else { + var $temp_div = $(""); + $temp_div.html(data.error); + var $error = $temp_div.find("code").addClass("error"); + PMA_ajaxShowMessage($error); + } + }) // end $.post() + });//end of table maintanance ajax click + }, 'top.frame_content'); //end $(document).ready for 'Table operations' @@ -2983,7 +3021,7 @@ $(document).ready(function() { $("#drop_tbl_anchor").live('click', function(event) { event.preventDefault(); - //context is top.frame_content, so we need to use window.parent.db to access the db var + //context is top.frame_content, so we need to use window.parent.table to access the table var /** * @var question String containing the question to be asked for confirmation */ @@ -3011,10 +3049,10 @@ $(document).ready(function() { * @see $cfg['AjaxEnable'] */ $(document).ready(function() { - $("#truncate_tbl_anchor").live('click', function(event) { + $("#truncate_tbl_anchor.ajax").live('click', function(event) { event.preventDefault(); - //context is top.frame_content, so we need to use window.parent.db to access the db var + //context is top.frame_content, so we need to use window.parent.table to access the table var /** * @var question String containing the question to be asked for confirmation */ @@ -3024,13 +3062,26 @@ $(document).ready(function() { PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); $.get(url, {'is_js_confirmed': '1', 'ajax_request': true}, function(data) { - //Database deleted successfully, refresh both the frames - window.parent.refreshNavigation(); - window.parent.refreshMain(); + if ($("#sqlqueryresults").length != 0) { + $("#sqlqueryresults").remove(); + } + if ($("#result_query").length != 0) { + $("#result_query").remove(); + } + if (data.success == true) { + PMA_ajaxShowMessage(data.message); + $("").insertAfter("#topmenucontainer"); + $("#sqlqueryresults").html(data.sql_query); + } else { + var $temp_div = $("") + $temp_div.html(data.error); + var $error = $temp_div.find("code").addClass("error"); + PMA_ajaxShowMessage($error); + } }) // end $.get() }); // end $.PMA_confirm() - }); //end of Drop Table Ajax action -}) // end of $(document).ready() for Drop Table + }); //end of Truncate Table Ajax action +}) // end of $(document).ready() for Truncate Table /** * Attach CodeMirror2 editor to SQL edit area. diff --git a/sql.php b/sql.php index 7e9c0f6486..60740f6448 100644 --- a/sql.php +++ b/sql.php @@ -767,6 +767,34 @@ else { PMA_ajaxResponse(NULL, true, $extra_data); } + if (isset($_REQUEST['ajax_request']) && isset($_REQUEST['table_maintenance'])) { + $GLOBALS['js_include'][] = 'functions.js'; + $GLOBALS['js_include'][] = 'makegrid.js'; + $GLOBALS['js_include'][] = 'sql.js'; + + // Gets the list of fields properties + if (isset($result) && $result) { + $fields_meta = PMA_DBI_get_fields_meta($result); + $fields_cnt = count($fields_meta); + } + + if (empty($disp_mode)) { + // see the "PMA_setDisplayMode()" function in + // libraries/display_tbl.lib.php + $disp_mode = 'urdr111101'; + } + + // hide edit and delete links for information_schema + if ($db == 'information_schema') { + $disp_mode = 'nnnn110111'; + } + + $message = PMA_Message::success($message); + echo PMA_showMessage($message, $GLOBALS['sql_query'], 'success'); + PMA_displayTable($result, $disp_mode, $analyzed_sql); + exit(); + } + // Displays the headers if (isset($show_query)) { unset($show_query); diff --git a/tbl_operations.php b/tbl_operations.php index a5a9eef6a9..3e536c2f92 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -593,7 +593,7 @@ if (isset($possible_row_formats[$tbl_type])) {