diff --git a/js/functions.js b/js/functions.js index 572c857501..6cae921b6c 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1269,7 +1269,7 @@ function PMA_ajaxShowMessage(message, timeout) { .hide(); }) } - + return $("#loading"); } @@ -1442,7 +1442,7 @@ $(document).ready(function() { open: PMA_verifyTypeOfAllColumns, buttons : button_options }); // end dialog options - } + } PMA_ajaxRemoveMessage($msgbox); }) // end $.get() @@ -1583,7 +1583,7 @@ $(document).ready(function() { $("#create_table_div").html(data); } PMA_verifyTypeOfAllColumns(); - PMA_ajaxRemoveMessage($msgbox); + PMA_ajaxRemoveMessage($msgbox); }) //end $.post() }) // end create table form (add fields) @@ -1733,7 +1733,7 @@ $(document).ready(function() { .dialog({ title: PMA_messages['strChangePassword'], width: 600, - close: function(ev,ui) {$(this).remove();}, + close: function(ev,ui) {$(this).remove();}, buttons : button_options, beforeClose: function(ev,ui){ $('#change_password_anchor.dialog_active').removeClass('dialog_active').addClass('ajax')} }) @@ -1772,7 +1772,7 @@ $(document).ready(function() { $("#change_password_dialog").hide().remove(); $("#edit_user_dialog").dialog("close").remove(); $('#change_password_anchor.dialog_active').removeClass('dialog_active').addClass('ajax'); - PMA_ajaxRemoveMessage($msgbox); + PMA_ajaxRemoveMessage($msgbox); } else { PMA_ajaxShowMessage(data.error); @@ -2278,3 +2278,64 @@ $(document).ready(function() { }) // end of $(document).ready() +/** + * Attach Ajax event handlers for Drop Table. + * + * @uses $.PMA_confirm() + * @uses PMA_ajaxShowMessage() + * @uses window.parent.refreshNavigation() + * @uses window.parent.refreshMain() + * @see $cfg['AjaxEnable'] + */ +$(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 + /** + * @var question String containing the question to be asked for confirmation + */ + var question = PMA_messages['strDropTableStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'DROP TABLE ' + window.parent.table; + + $(this).PMA_confirm(question, $(this).attr('href') ,function(url) { + + 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(); + }) // end $.get() + }); // end $.PMA_confirm() + }); //end of Drop Table Ajax action +}) // end of $(document).ready() for Drop Table + +/** + * Attach Ajax event handlers for Truncate Table. + * + * @uses $.PMA_confirm() + * @uses PMA_ajaxShowMessage() + * @uses window.parent.refreshNavigation() + * @uses window.parent.refreshMain() + * @see $cfg['AjaxEnable'] + */ +$(document).ready(function() { + $("#truncate_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 + /** + * @var question String containing the question to be asked for confirmation + */ + var question = PMA_messages['strTruncateTableStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'TRUNCATE TABLE ' + window.parent.table; + + $(this).PMA_confirm(question, $(this).attr('href') ,function(url) { + + 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(); + }) // end $.get() + }); // end $.PMA_confirm() + }); //end of Drop Table Ajax action +}) // end of $(document).ready() for Drop Table diff --git a/js/messages.php b/js/messages.php index 0f7c8c7c67..aadbcdf255 100644 --- a/js/messages.php +++ b/js/messages.php @@ -29,6 +29,8 @@ $js_messages['strNoDropDatabases'] = __('"DROP DATABASE" statements are disabled /* For confirmations */ $js_messages['strDoYouReally'] = __('Do you really want to '); $js_messages['strDropDatabaseStrongWarning'] = __('You are about to DESTROY a complete database!'); +$js_messages['strDropTableStrongWarning'] = __('You are about to DESTROY a complete table!'); +$js_messages['strTruncateTableStrongWarning'] = __('You are about to TRUNCATE a complete table!'); $js_messages['strDroppingEvent'] = __('Dropping Event'); $js_messages['strDroppingProcedure'] = __('Dropping Procedure'); $js_messages['strDeleteTrackingData'] = __('Delete tracking data for this table'); diff --git a/tbl_operations.php b/tbl_operations.php index 28530dae72..5ba5aab47e 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -30,6 +30,11 @@ $cfgRelation = PMA_getRelationsParam(); require_once './libraries/mysql_charsets.lib.php'; require_once './libraries/StorageEngine.class.php'; +// add a javascript file for jQuery functions to handle Ajax actions +// also add jQueryUI +$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; +$GLOBALS['js_include'][] = 'tbl_operations.js'; + /** * Class for partition management */ @@ -684,7 +689,7 @@ if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_ 'message_to_show' => sprintf(__('Table %s has been emptied'), htmlspecialchars($table)), )); ?> -