diff options
author | Madhura Jayaratne <madhura.cj@gmail.com> | 2014-12-01 15:33:01 +0300 |
---|---|---|
committer | Madhura Jayaratne <madhura.cj@gmail.com> | 2014-12-01 15:33:01 +0300 |
commit | 395c718075bb6cc912e0463c0a1c299bff08be54 (patch) | |
tree | 7b3ecfe08bc13eccae678d01fc857093a2066be0 /js/tbl_operations.js | |
parent | c099f04bc6c17eab179411e72093b841f7a88d27 (diff) |
Move more JS code to tbl_operations.js
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
Diffstat (limited to 'js/tbl_operations.js')
-rw-r--r-- | js/tbl_operations.js | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/js/tbl_operations.js b/js/tbl_operations.js index 80e23396ad..89fb849154 100644 --- a/js/tbl_operations.js +++ b/js/tbl_operations.js @@ -6,6 +6,9 @@ AJAX.registerTeardown('tbl_operations.js', function () { $("#moveTableForm").die('submit'); $("#tableOptionsForm").die('submit'); $("#tbl_maintenance li a.maintain_action.ajax").die('click'); + $("#drop_tbl_anchor.ajax").die('click'); + $("#drop_view_anchor.ajax").die('click'); + $("#truncate_tbl_anchor.ajax").die('click'); }); /** @@ -136,4 +139,102 @@ AJAX.registerOnload('tbl_operations.js', function () { } }); // end $.post() });//end of table maintenance ajax click + + $("#drop_tbl_anchor.ajax").live('click', function (event) { + event.preventDefault(); + /** + * @var question String containing the question to be asked for confirmation + */ + var question = PMA_messages.strDropTableStrongWarning + ' '; + question += PMA_sprintf( + PMA_messages.strDoYouReally, + 'DROP TABLE ' + escapeHtml(PMA_commonParams.get('table')) + ); + + $(this).PMA_confirm(question, $(this).attr('href'), function (url) { + + var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest); + $.get(url, {'is_js_confirmed': '1', 'ajax_request': true}, function (data) { + if (typeof data !== 'undefined' && data.success === true) { + PMA_ajaxRemoveMessage($msgbox); + // Table deleted successfully, refresh both the frames + PMA_reloadNavigation(); + PMA_commonParams.set('table', ''); + PMA_commonActions.refreshMain( + PMA_commonParams.get('opendb_url'), + function () { + PMA_ajaxShowMessage(data.message); + } + ); + } else { + PMA_ajaxShowMessage(data.error, false); + } + }); // end $.get() + }); // end $.PMA_confirm() + }); //end of Drop Table Ajax action + + $("#drop_view_anchor.ajax").live('click', function (event) { + event.preventDefault(); + /** + * @var question String containing the question to be asked for confirmation + */ + var question = PMA_messages.strDropTableStrongWarning + ' '; + question += PMA_sprintf( + PMA_messages.strDoYouReally, + 'DROP VIEW ' + escapeHtml(PMA_commonParams.get('table')) + ); + + $(this).PMA_confirm(question, $(this).attr('href'), function (url) { + + var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest); + $.get(url, {'is_js_confirmed': '1', 'ajax_request': true}, function (data) { + if (typeof data !== 'undefined' && data.success === true) { + PMA_ajaxRemoveMessage($msgbox); + // Table deleted successfully, refresh both the frames + PMA_reloadNavigation(); + PMA_commonParams.set('table', ''); + PMA_commonActions.refreshMain( + PMA_commonParams.get('opendb_url'), + function () { + PMA_ajaxShowMessage(data.message); + } + ); + } else { + PMA_ajaxShowMessage(data.error, false); + } + }); // end $.get() + }); // end $.PMA_confirm() + }); //end of Drop View Ajax action + + $("#truncate_tbl_anchor.ajax").live('click', function (event) { + event.preventDefault(); + /** + * @var question String containing the question to be asked for confirmation + */ + var question = PMA_messages.strTruncateTableStrongWarning + ' '; + question += PMA_sprintf( + PMA_messages.strDoYouReally, + 'TRUNCATE ' + escapeHtml(PMA_commonParams.get('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 ($(".sqlqueryresults").length !== 0) { + $(".sqlqueryresults").remove(); + } + if ($(".result_query").length !== 0) { + $(".result_query").remove(); + } + if (typeof data !== 'undefined' && data.success === true) { + PMA_ajaxShowMessage(data.message); + $("<div class='sqlqueryresults ajax'></div>").prependTo("#page_content"); + $(".sqlqueryresults").html(data.sql_query); + PMA_highlightSQL($('#page_content')); + } else { + PMA_ajaxShowMessage(data.error, false); + } + }); // end $.get() + }); // end $.PMA_confirm() + }); //end of Truncate Table Ajax action + }); //end $(document).ready for 'Table operations' |