From dd58a5bc239b6dedb1e2ec971a0c812ec44fca4c Mon Sep 17 00:00:00 2001 From: ninadsp Date: Sun, 11 Jul 2010 23:14:41 +0530 Subject: [PATCH] Removed inline calls to confirmLink() for Empty/Drop Table actions in libraries/tbl_links.inc.php --- js/functions.js | 60 ++++++++++++++++++++++++++++++++++++- libraries/tbl_links.inc.php | 4 +-- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/js/functions.js b/js/functions.js index 36c9089fa..63edd90a7 100755 --- a/js/functions.js +++ b/js/functions.js @@ -1871,4 +1871,62 @@ $(document).ready(function() { } }) // end create table form submit button actions -}, 'top.frame_content'); //end $(document).ready for 'Create Table' \ No newline at end of file +}, 'top.frame_content'); //end $(document).ready for 'Create Table' + +/** + * jQuery coding for Empty Table and Drop Table. Used wherever libraries/ + * tbl_links.inc.php is used. + */ +$(document).ready(function() { + + //Empty Table + $("#empty_table_anchor").live('click', function(event) { + event.preventDefault(); + + var question = '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) { + if(data.success == true) { + PMA_ajaxShowMessage(data.message); + $("#topmenucontainer") + .next('div') + .remove() + .end() + .after(data.sql_query); + } + else { + PMA_ajaxShowMessage(data.error); + } + }) // end $.get + }) + }) // end Empty Table + + //Drop Table + $("#drop_table_anchor").live('click', function(event) { + event.preventDefault(); + + var question = 'DROP TABLE/VIEW ' + 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) { + if(data.success == true) { + PMA_ajaxShowMessage(data.message); + $("#topmenucontainer") + .next('div') + .remove() + .end() + .after(data.sql_query); + window.parent.table = ''; + window.parent.refreshNavigation(); + } + else { + PMA_ajaxShowMessage(data.error); + } + }) // end $.get + }) + }) +}); //end $(document).ready() for libraries/tbl_links.inc.php \ No newline at end of file diff --git a/libraries/tbl_links.inc.php b/libraries/tbl_links.inc.php index e9b4cb939..36e7f84ed 100755 --- a/libraries/tbl_links.inc.php +++ b/libraries/tbl_links.inc.php @@ -98,7 +98,7 @@ if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_ $tabs['empty']['args']['reload'] = 1; $tabs['empty']['args']['sql_query'] = 'TRUNCATE TABLE ' . PMA_backquote($table); $tabs['empty']['args']['zero_rows'] = sprintf(__('Table %s has been emptied'), htmlspecialchars($table)); - $tabs['empty']['attr'] = 'onclick="return confirmLink(this, \'TRUNCATE TABLE ' . PMA_jsFormat($table) . '\')"'; + $tabs['empty']['id'] = 'empty_table_anchor'; $tabs['empty']['args']['goto'] = 'tbl_structure.php'; $tabs['empty']['class'] = 'caution'; $tabs['empty']['icon'] = 'b_empty.png'; @@ -131,7 +131,7 @@ if (! (isset($db_is_information_schema) && $db_is_information_schema)) { $tabs['drop']['args']['sql_query'] = $drop_command . ' ' . PMA_backquote($table); $tabs['drop']['args']['goto'] = 'db_structure.php'; $tabs['drop']['args']['zero_rows'] = sprintf(($tbl_is_view ? __('View %s has been dropped') : __('Table %s has been dropped')), htmlspecialchars($table)); - $tabs['drop']['attr'] = 'onclick="return confirmLink(this, \'' . $drop_command . ' ' . PMA_jsFormat($table) . '\')"'; + $tabs['drop']['id'] = 'drop_table_anchor'; unset($drop_command); $tabs['drop']['class'] = 'caution'; }