Drizzle-compatible Status tab
[phpmyadmin-regexreplace.git] / js / db_operations.js
blob5169b553c307c752a081778d415b853420671a0c
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3 * @fileoverview function used in server privilege pages
4 * @name Database Operations
6 * @requires jQuery
7 * @requires jQueryUI
8 * @requires js/functions.js
12 /**
13 * Ajax event handlers here for db_operations.php
15 * Actions Ajaxified here:
16 * Rename Database
17 * Copy Database
18 * Change charset
21 $(document).ready(function() {
23 /**
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();
33 var $form = $(this);
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" />');
41 /**
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")
63 .next('div')
64 .remove()
65 .end()
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
78 else {
79 PMA_ajaxShowMessage(data.error);
81 }) // end $.get()
83 }); // end Rename Database
85 /**
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 var $msgbox = PMA_ajaxShowMessage(PMA_messages['strCopyingDatabase']);
96 var $form = $(this);
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();
112 } else {
113 // Here we force a refresh because the navigation
114 // frame url is not changing so this function would
115 // not refresh it
116 window.parent.refreshNavigation(true);
119 else {
120 $('#topmenucontainer').after(data.error);
123 PMA_ajaxRemoveMessage($msgbox);
124 }) // end $.get
125 }) // end copy database
128 * Ajax Event handler for 'Change Charset' of the database
130 * @uses PMA_ajaxShowMessage()
131 * @see $cfg['AjaxEnable']
133 $("#change_db_charset_form.ajax").live('submit', function(event) {
134 event.preventDefault();
136 var $form = $(this);
138 if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
139 $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
142 PMA_ajaxShowMessage(PMA_messages['strChangingCharset']);
144 $.get($form.attr('action'), $form.serialize() + "&submitcollation=" + $form.find("input[name=submitcollation]").attr('value'), function(data) {
145 if(data.success == true) {
146 PMA_ajaxShowMessage(data.message);
148 else {
149 PMA_ajaxShowMessage(data.error);
151 }) // end $.get()
152 }) // end change charset
154 }, 'top.frame_content');