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 if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
38 $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
42 * @var button_options Object containing options for jQueryUI dialog buttons
44 var button_options = {};
45 button_options[PMA_messages['strYes']] = function() {
46 $(this).dialog("close").remove();
47 window.parent.refreshMain();
48 window.parent.refreshNavigation();
50 button_options[PMA_messages['strNo']] = function() { $(this).dialog("close").remove(); }
52 $form.PMA_confirm(question, $form.attr('action'), function(url) {
53 PMA_ajaxShowMessage(PMA_messages['strRenamingDatabases']);
55 $.get(url, $("#rename_db_form").serialize() + '&is_js_confirmed=1', function(data) {
56 if(data.success == true) {
58 PMA_ajaxShowMessage(data.message);
60 window.parent.db = data.newname;
62 $("#topmenucontainer")
66 .after(data.sql_query);
68 //Remove the empty notice div generated due to a NULL query passed to PMA_showMessage()
69 var $notice_class = $("#topmenucontainer").next("div").find('.notice');
70 if ($notice_class.text() == '') {
71 $notice_class.remove();
74 $("<span>" + PMA_messages['strReloadDatabase'] + "?</span>").dialog({
75 buttons: button_options
76 }) //end dialog options
79 PMA_ajaxShowMessage(data.error);
83 }); // end Rename Database
86 * Ajax Event Handler for 'Copy Database'
88 * @uses PMA_ajaxShowMessage()
89 * @see $cfg['AjaxEnable']
91 $("#copy_db_form.ajax").live('submit', function(event) {
92 event.preventDefault();
94 PMA_ajaxShowMessage(PMA_messages['strCopyingDatabase']);
98 if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
99 $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
102 $.get($form.attr('action'), $form.serialize(), function(data) {
103 // use messages that stay on screen
104 $('.success').fadeOut();
105 $('.error').fadeOut();
106 if(data.success == true) {
107 $('#topmenucontainer').after(data.message);
108 if( $("#checkbox_switch").is(":checked")) {
109 window.parent.db = data.newname;
110 window.parent.refreshMain();
111 window.parent.refreshNavigation();
113 // Here we force a refresh because the navigation
114 // frame url is not changing so this function would
116 window.parent.refreshNavigation(true);
120 $('#topmenucontainer').after(data.error);
123 }) // end copy database
126 * Ajax Event handler for 'Change Charset' of the database
128 * @uses PMA_ajaxShowMessage()
129 * @see $cfg['AjaxEnable']
131 $("#change_db_charset_form.ajax").live('submit', function(event) {
132 event.preventDefault();
136 if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
137 $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
140 PMA_ajaxShowMessage(PMA_messages['strChangingCharset']);
142 $.get($form.attr('action'), $form.serialize() + "&submitcollation=" + $form.find("input[name=submitcollation]").attr('value'), function(data) {
143 if(data.success == true) {
144 PMA_ajaxShowMessage(data.message);
147 PMA_ajaxShowMessage(data.error);
150 }) // end change charset
152 }, 'top.frame_content');