Translation update done using Pootle.
[phpmyadmin/last10db.git] / js / db_operations.js
blob4e3dedf4f950eed2aa98bca5978c41ab93c4499b
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  */
12 /**
13  * Ajax event handlers here for db_operations.php
14  *
15  * Actions Ajaxified here:
16  * Rename Database
17  * Copy Database
18  * Change charset
19  */
21 $(document).ready(function() {
23     /**
24      * Ajax event handlers for 'Rename Database'
25      *
26      * @uses    $.PMA_confirm()
27      * @uses    PMA_ajaxShowUser()
28      */
29     $("#rename_db_form").live('submit', function(event) {
30         event.preventDefault();
32         var question = 'CREATE DATABASE ... and then DROP DATABASE ' + window.parent.db;
33         $(this).append('<input type="hidden" name="ajax_request" value="true" />');
35         /**
36          * @var button_options  Object containing options for jQueryUI dialog buttons
37          */
38         var button_options = {};
39         button_options[PMA_messages['strYes']] = function() {
40                                                     $(this).dialog("close").remove();
41                                                     window.parent.refreshMain();
42                                                     window.parent.refreshNavigation();
43                                                 };
44         button_options[PMA_messages['strNo']] = function() { $(this).dialog("close").remove(); }
46         $(this).PMA_confirm(question, $(this).attr('action'), function(url) {
47             PMA_ajaxShowMessage(PMA_messages['strRenamingDatabases']);
49             $.get(url, $("#rename_db_form").serialize() + '&is_js_confirmed=1', function(data) {
50                 if(data.success == true) {
51                     
52                     PMA_ajaxShowMessage(data.message);
54                     window.parent.db = data.newname;
56                     $("#topmenucontainer")
57                     .next('div')
58                     .remove()
59                     .end()
60                     .after(data.sql_query);
62                     //Remove the empty notice div generated due to a NULL query passed to PMA_showMessage()
63                     var notice_class = $("#topmenucontainer").next("div").find('.notice');
64                     if($(notice_class).text() == '') {
65                         $(notice_class).remove();
66                     }
68                     $("<span>" + PMA_messages['strReloadDatabase'] + "?</span>").dialog({
69                         buttons: button_options
70                     }) //end dialog options
71                 }
72                 else {
73                     PMA_ajaxShowMessage(data.error);
74                 }
75             }) // end $.get()
76         })
77     }); // end Rename Database
79     /**
80      * Ajax Event Handler for 'Copy Database'
81      *
82      * @uses    PMA_ajaxShowMessage()
83      */
84     $("#copy_db_form").live('submit', function(event) {
85         event.preventDefault();
87         PMA_ajaxShowMessage(PMA_messages['strCopyingDatabase']);
88         $(this).append('<input type="hidden" name="ajax_request" value="true" />');
90         $.get($(this).attr('action'), $(this).serialize(), function(data) {
91             if(data.success == true) {
92                 PMA_ajaxShowMessage(data.message);
93                 if( $("#checkbox_switch").is(":checked")) {
94                     window.parent.db = data.newname;
95                     window.parent.refreshMain();
96                     window.parent.refreshNavigation();
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');