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()
28 * @see $cfg['AjaxEnable']
30 $("#rename_db_form.ajax").live('submit', function(event) {
31 event.preventDefault();
35 var question = 'CREATE DATABASE ' + $('#new_db_name').val() + ' / DROP DATABASE ' + window.parent.db;
37 PMA_prepareForAjaxRequest($form);
39 * @var button_options Object containing options for jQueryUI dialog buttons
41 var button_options = {};
42 button_options[PMA_messages['strYes']] = function() {
43 $(this).dialog("close").remove();
44 window.parent.refreshMain();
45 window.parent.refreshNavigation();
47 button_options[PMA_messages['strNo']] = function() { $(this).dialog("close").remove(); }
49 $form.PMA_confirm(question, $form.attr('action'), function(url) {
50 PMA_ajaxShowMessage(PMA_messages['strRenamingDatabases']);
52 $.get(url, $("#rename_db_form").serialize() + '&is_js_confirmed=1', function(data) {
53 if(data.success == true) {
55 PMA_ajaxShowMessage(data.message);
57 window.parent.db = data.newname;
59 $("#topmenucontainer")
63 .after(data.sql_query);
65 //Remove the empty notice div generated due to a NULL query passed to PMA_showMessage()
66 var $notice_class = $("#topmenucontainer").next("div").find('.notice');
67 if ($notice_class.text() == '') {
68 $notice_class.remove();
71 $("<span>" + PMA_messages['strReloadDatabase'] + "?</span>").dialog({
72 buttons: button_options
73 }) //end dialog options
76 PMA_ajaxShowMessage(data.error);
80 }); // end Rename Database
83 * Ajax Event Handler for 'Copy Database'
85 * @uses PMA_ajaxShowMessage()
86 * @see $cfg['AjaxEnable']
88 $("#copy_db_form.ajax").live('submit', function(event) {
89 event.preventDefault();
91 var $msgbox = PMA_ajaxShowMessage(PMA_messages['strCopyingDatabase']);
95 PMA_prepareForAjaxRequest($form);
97 $.get($form.attr('action'), $form.serialize(), function(data) {
98 // use messages that stay on screen
99 $('.success').fadeOut();
100 $('.error').fadeOut();
101 if(data.success == true) {
102 $('#topmenucontainer').after(data.message);
103 if( $("#checkbox_switch").is(":checked")) {
104 window.parent.db = data.newname;
105 window.parent.refreshMain();
106 window.parent.refreshNavigation();
108 // Here we force a refresh because the navigation
109 // frame url is not changing so this function would
111 window.parent.refreshNavigation(true);
115 $('#topmenucontainer').after(data.error);
118 PMA_ajaxRemoveMessage($msgbox);
120 }) // end copy database
123 * Ajax Event handler for 'Change Charset' of the database
125 * @uses PMA_ajaxShowMessage()
126 * @see $cfg['AjaxEnable']
128 $("#change_db_charset_form.ajax").live('submit', function(event) {
129 event.preventDefault();
133 PMA_prepareForAjaxRequest($form);
135 PMA_ajaxShowMessage(PMA_messages['strChangingCharset']);
137 $.get($form.attr('action'), $form.serialize() + "&submitcollation=" + $form.find("input[name=submitcollation]").attr('value'), function(data) {
138 if(data.success == true) {
139 PMA_ajaxShowMessage(data.message);
142 PMA_ajaxShowMessage(data.error);
145 }) // end change charset
147 }, 'top.frame_content');