From b37d10c3f1fee524a296da6f9202774acf57ce6e Mon Sep 17 00:00:00 2001 From: Benoit Dumesnil Date: Sun, 27 Mar 2011 05:06:48 +0200 Subject: [PATCH] Feature Request #3187076 This patch transforms the old-style pop-up of truncate and drop table to a ajax style pop-up --- js/messages.php | 2 ++ js/tbl_operations.js | 64 +++++++++++++++++++++++++++++++++++++++++++- tbl_operations.php | 9 +++++-- 3 files changed, 72 insertions(+), 3 deletions(-) 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/js/tbl_operations.js b/js/tbl_operations.js index 6f5aa97cf6..6c293fe051 100644 --- a/js/tbl_operations.js +++ b/js/tbl_operations.js @@ -17,4 +17,66 @@ * Analyze * Flush * Optimize - */ \ No newline at end of file + */ + + /** + * 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 \ No newline at end of file diff --git a/tbl_operations.php b/tbl_operations.php index 3c8b5dd45b..d85501482b 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)), )); ?> -
  • +
  • >
  • @@ -704,7 +709,7 @@ if (! (isset($db_is_information_schema) && $db_is_information_schema)) { 'table' => $GLOBALS['table'], )); ?> -
  • +
  • >