Translation update done using Pootle.
[phpmyadmin/dkf.git] / js / db_operations.js
blob8bdeea2c39d555a7bdc5471ebe6410f0854562f3
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  * @fileoverview    function used in server privilege pages
4  * @name            Database Operations
5  *
6  * @requires    jQuery
7  * @requires    jQueryUI
8  * @requires    js/functions.js
9  *
10  * @version $Id$
11  */
13 /**
14  * Ajax event handlers here for db_operations.php
15  *
16  * Actions Ajaxified here:
17  * Rename Database
18  * Copy Database
19  * Change charset
20  */
22 $(document).ready(function() {
24     /**
25      * Ajax event handlers for 'Rename Database'
26      *
27      * @uses    $.PMA_confirm()
28      * @uses    PMA_ajaxShowUser()
29      */
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" />');
36         /**
37          * @var button_options  Object containing options for jQueryUI dialog buttons
38          */
39         var button_options = {};
40         button_options[PMA_messages['strYes']] = function() {
41                                                     $(this).dialog("close").remove();
42                                                     window.parent.refreshMain();
43                                                     window.parent.refreshNavigation();
44                                                 };
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) {
52                     
53                     PMA_ajaxShowMessage(data.message);
55                     window.parent.db = data.newname;
57                     $("#topmenucontainer")
58                     .next('div')
59                     .remove()
60                     .end()
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();
67                     }
69                     $("<span>" + PMA_messages['strReloadDatabase'] + "?</span>").dialog({
70                         buttons: button_options
71                     }) //end dialog options
72                 }
73                 else {
74                     PMA_ajaxShowMessage(data.error);
75                 }
76             }) // end $.get()
77         })
78     }); // end Rename Database
80     /**
81      * Ajax Event Handler for 'Copy Database'
82      *
83      * @uses    PMA_ajaxShowMessage()
84      */
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();
97                 }
98             }
99             else {
100                 PMA_ajaxShowMessage(data.error);
101             }
102         }) // end $.get
103     }) // end copy database
105     /**
106      * Ajax Event handler for 'Change Charset' of the database
107      *
108      * @uses    PMA_ajaxShowMessage()
109      */
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);
120             }
121             else {
122                 PMA_ajaxShowMessage(data.error);
123             }
124         }) // end $.get()
125     }) // end change charset
126     
127 }, 'top.frame_content');