1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * @fileoverview function used in server privilege pages
4 * @name Database Operations
8 * @requires js/functions.js
13 * Ajax event handlers here for db_operations.php
15 * Actions Ajaxified here:
21 $(document).ready(function() {
24 * Ajax event handlers for 'Rename Database'
26 * @uses $.PMA_confirm()
27 * @uses PMA_ajaxShowUser()
29 $("#rename_db_form").live('submit', function(event) {
30 event.preventDefault();
32 var question = 'CREATE DATABASE ... and then DROP DATABASE ' + window.parent.db;
33 $(this).append('<input type="hidden" name="ajax_request" value="true" />');
36 * @var button_options Object containing options for jQueryUI dialog buttons
38 var button_options = {};
39 button_options[PMA_messages['strYes']] = function() {
40 $(this).dialog("close").remove();
41 window.parent.refreshMain();
42 window.parent.refreshNavigation();
44 button_options[PMA_messages['strNo']] = function() { $(this).dialog("close").remove(); }
46 $(this).PMA_confirm(question, $(this).attr('action'), function(url) {
47 PMA_ajaxShowMessage(PMA_messages['strRenamingDatabases']);
49 $.get(url, $("#rename_db_form").serialize() + '&is_js_confirmed=1', function(data) {
50 if(data.success == true) {
52 PMA_ajaxShowMessage(data.message);
54 window.parent.db = data.newname;
56 $("#topmenucontainer")
60 .after(data.sql_query);
62 //Remove the empty notice div generated due to a NULL query passed to PMA_showMessage()
63 var $notice_class = $("#topmenucontainer").next("div").find('.notice');
64 if ($notice_class.text() == '') {
65 $notice_class.remove();
68 $("<span>" + PMA_messages['strReloadDatabase'] + "?</span>").dialog({
69 buttons: button_options
70 }) //end dialog options
73 PMA_ajaxShowMessage(data.error);
77 }); // end Rename Database
80 * Ajax Event Handler for 'Copy Database'
82 * @uses PMA_ajaxShowMessage()
84 $("#copy_db_form").live('submit', function(event) {
85 event.preventDefault();
87 PMA_ajaxShowMessage(PMA_messages['strCopyingDatabase']);
88 $(this).append('<input type="hidden" name="ajax_request" value="true" />');
90 $.get($(this).attr('action'), $(this).serialize(), function(data) {
91 if(data.success == true) {
92 PMA_ajaxShowMessage(data.message);
93 if( $("#checkbox_switch").is(":checked")) {
94 window.parent.db = data.newname;
95 window.parent.refreshMain();
96 window.parent.refreshNavigation();
100 PMA_ajaxShowMessage(data.error);
103 }) // end copy database
106 * Ajax Event handler for 'Change Charset' of the database
108 * @uses PMA_ajaxShowMessage()
110 $("#change_db_charset_form").live('submit', function(event) {
111 event.preventDefault();
113 $(this).append('<input type="hidden" name="ajax_request" value="true" />');
115 PMA_ajaxShowMessage(PMA_messages['strChangingCharset']);
117 $.get($(this).attr('action'), $(this).serialize() + "&submitcollation=" + $(this).find("input[name=submitcollation]").attr('value'), function(data) {
118 if(data.success == true) {
119 PMA_ajaxShowMessage(data.message);
122 PMA_ajaxShowMessage(data.error);
125 }) // end change charset
127 }, 'top.frame_content');