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
14 * Ajax event handlers here for db_operations.php
16 * Actions Ajaxified here:
22 $(document).ready(function() {
25 * Ajax event handlers for 'Rename Database'
27 * @uses $.PMA_confirm()
28 * @uses PMA_ajaxShowUser()
30 $("#rename_db_form").live('submit', function(event) {
31 event.preventDefault();
33 var question = 'CREATE DATABASE ... and then DROP DATABASE ' + window.parent.db;
34 $(this).append('<input type="hidden" name="ajax_request" value="true" />');
37 * @var button_options Object containing options for jQueryUI dialog buttons
39 var button_options = {};
40 button_options[PMA_messages['strYes']] = function() {
41 $(this).dialog("close").remove();
42 window.parent.refreshMain();
43 window.parent.refreshNavigation();
45 button_options[PMA_messages['strNo']] = function() { $(this).dialog("close").remove(); }
47 $(this).PMA_confirm(question, $(this).attr('action'), function(url) {
48 PMA_ajaxShowMessage(PMA_messages['strRenamingDatabases']);
50 $.get(url, $("#rename_db_form").serialize() + '&is_js_confirmed=1', function(data) {
51 if(data.success == true) {
53 PMA_ajaxShowMessage(data.message);
55 window.parent.db = data.newname;
57 $("#topmenucontainer")
61 .after(data.sql_query);
63 //Remove the empty notice div generated due to a NULL query passed to PMA_showMessage()
64 var notice_class = $("#topmenucontainer").next("div").find('.notice');
65 if($(notice_class).text() == '') {
66 $(notice_class).remove();
69 $("<span>" + PMA_messages['strReloadDatabase'] + "?</span>").dialog({
70 buttons: button_options
71 }) //end dialog options
74 PMA_ajaxShowMessage(data.error);
78 }); // end Rename Database
81 * Ajax Event Handler for 'Copy Database'
83 * @uses PMA_ajaxShowMessage()
85 $("#copy_db_form").live('submit', function(event) {
86 event.preventDefault();
88 PMA_ajaxShowMessage(PMA_messages['strCopyingDatabase']);
89 $(this).append('<input type="hidden" name="ajax_request" value="true" />');
91 $.get($(this).attr('action'), $(this).serialize(), function(data) {
92 if(data.success == true) {
93 PMA_ajaxShowMessage(data.message);
94 if( $("#checkbox_switch").is(":checked")) {
95 window.parent.db = data.newname;
96 window.parent.refreshMain();
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');