patch for Copy set of tables to new name pattern.
[phpmyadmin/dennischen.git] / js / export.js
blob1cf9de50b7961da0cda2d1823a5e4f3544a00418
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  * Functions used in the export tab
4  *
5  */
6  
7  /**
8   * Toggles the hiding and showing of each plugin's options
9   * according to the currently selected plugin from the dropdown list
10   */
11  $(document).ready(function() {
12     $("#plugins").change(function() {
13         $(".format_specific_options").each(function() {
14             $(this).hide();
15         });
16         var selected_plugin_name = $("#plugins option:selected").attr("value");
17         $("#" + selected_plugin_name + "_options").show();
18      });
19 });
21 /**
22  * Toggles the enabling and disabling of the SQL plugin's comment options that apply only when exporting structure 
23  */
24 $(document).ready(function() {
25     $("input[type='radio'][name$='sql_structure_or_data']").change(function() {
26         var show = $("input[type='radio'][name$='sql_structure_or_data']:checked").attr("value");
27         if(show == 'data') {
28             // disable the SQL comment options
29             $("#checkbox_sql_dates").parent().fadeTo('fast', 0.4);
30             $("#checkbox_sql_dates").attr('disabled', 'disabled');
31             $("#checkbox_sql_relation").parent().fadeTo('fast', 0.4);
32             $("#checkbox_sql_relation").attr('disabled', 'disabled');
33             $("#checkbox_sql_mime").parent().fadeTo('fast', 0.4);
34             $("#checkbox_sql_mime").attr('disabled', 'disabled');
35         } else {
36             // enable the SQL comment options
37             $("#checkbox_sql_dates").parent().fadeTo('fast', 1);
38             $("#checkbox_sql_dates").removeAttr('disabled');
39             $("#checkbox_sql_relation").parent().fadeTo('fast', 1);
40             $("#checkbox_sql_relation").removeAttr('disabled');
41             $("#checkbox_sql_mime").parent().fadeTo('fast', 1);
42             $("#checkbox_sql_mime").removeAttr('disabled');
43         }
44      });
45 });
48 /**
49  * Toggles the hiding and showing of plugin structure-specific and data-specific
50  * options
51  */
53 function toggle_structure_data_opts(pluginName) {
54     var radioFormName = pluginName + "_structure_or_data";
55     var dataDiv = "#" + pluginName + "_data";
56     var structureDiv = "#" + pluginName + "_structure";
57     var show = $("input[type='radio'][name='" + radioFormName + "']:checked").attr("value");
58     if(show == 'data') {
59         $(dataDiv).slideDown('slow');
60         $(structureDiv).slideUp('slow');
61     } else {
62         $(structureDiv).slideDown('slow');
63         if(show == 'structure') {
64             $(dataDiv).slideUp('slow');
65         } else {
66             $(dataDiv).slideDown('slow');
67         }
68     }
71 $(document).ready(function() {
72     $("input[type='radio'][name='latex_structure_or_data']").change(function() {
73         toggle_structure_data_opts("latex");
74     });
75     $("input[type='radio'][name='odt_structure_or_data']").change(function() {
76         toggle_structure_data_opts("odt");
77     });
78     $("input[type='radio'][name='texytext_structure_or_data']").change(function() {
79         toggle_structure_data_opts("texytext");
80     });
81     $("input[type='radio'][name='htmlword_structure_or_data']").change(function() {
82         toggle_structure_data_opts("htmlword");
83     });
84     $("input[type='radio'][name='sql_structure_or_data']").change(function() {
85         toggle_structure_data_opts("sql");
86     });
87 });
89 /**
90  * Toggles the disabling of the "save to file" options
91  */
92 $(document).ready(function() {
93     $("input[type='radio'][name='output_format']").change(function() {
94         if($("#radio_dump_asfile:checked").length == 0) {
95             $("#ul_save_asfile > li").fadeTo('fast', 0.4);
96             $("#ul_save_asfile > li > input").attr('disabled', 'disabled');
97             $("#ul_save_asfile > li> select").attr('disabled', 'disabled');
98         } else {
99             $("#ul_save_asfile > li").fadeTo('fast', 1);
100             $("#ul_save_asfile > li > input").removeAttr('disabled');
101             $("#ul_save_asfile > li> select").removeAttr('disabled');
102         }
103      });
107  * For SQL plugin, toggles the disabling of the "display comments" options
108  */
109 function toggle_sql_include_comments() {
110     $("#checkbox_sql_include_comments").change(function() {
111         if($("#checkbox_sql_include_comments:checked").length == 0) {
112             $("#ul_include_comments > li").fadeTo('fast', 0.4);
113             $("#ul_include_comments > li > input").attr('disabled', 'disabled');
114          } else {
115             // If structure is not being exported, the comment options for structure should not be enabled
116             if($("#radio_sql_structure_or_data_data:checked").length == 1) {
117                 $("#text_sql_header_comment").parent("li").fadeTo('fast', 1);
118                 $("#text_sql_header_comment").removeAttr('disabled');
119             } else {
120                 $("#ul_include_comments > li").fadeTo('fast', 1);
121                 $("#ul_include_comments > li > input").removeAttr('disabled');
122             }
123          }
124      });
128  * For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options 
129  */ 
130 $(document).ready(function() {
131      $("#checkbox_sql_create_table_statements").change(function() {
132          if($("#checkbox_sql_create_table_statements:checked").length == 0) {
133             $("#checkbox_sql_if_not_exists").removeAttr('checked');
134             $("#checkbox_sql_auto_increment").removeAttr('checked');
135         } else {
136             $("#checkbox_sql_if_not_exists").attr('checked', 'checked');
137             $("#checkbox_sql_auto_increment").attr('checked', 'checked');
138         }
139     });
142 /** 
143  * Disables the view output as text option if the output must be saved as a file
144  */
145 $(document).ready(function() {
146     $("#plugins").change(function() {
147         var active_plugin = $("#plugins option:selected").attr("value");
148          var force_file = $("#force_file_" + active_plugin).attr("value");
149         if(force_file == "true") {
150             $("#radio_view_as_text").attr('disabled', 'disabled');
151             $("#radio_view_as_text").parent().fadeTo('fast', 0.4);
152         } else {
153             $("#radio_view_as_text").removeAttr('disabled');
154             $("#radio_view_as_text").parent().fadeTo('fast', 1);
155         }
156     });
160  * Toggles display of options when quick and custom export are selected
161  */
162 function toggle_quick_or_custom() {
163     if($("$(this):checked").attr("value") == "custom") {
164         $("#databases_and_tables").show();
165         $("#rows").show();
166         $("#output").show();
167         $("#format_specific_opts").show();
168         $("#output_quick_export").hide();
169         var selected_plugin_name = $("#plugins option:selected").attr("value");
170         $("#" + selected_plugin_name + "_options").show();
171     } else {
172         $("#databases_and_tables").hide();
173         $("#rows").hide();
174         $("#output").hide();
175         $("#format_specific_opts").hide();
176         $("#output_quick_export").show();
177     }
180 $(document).ready(function() {
181     $("input[type='radio'][name='quick_or_custom']").change(function() {
182         toggle_quick_or_custom();
183     });
187  * Sets up the interface for Javascript-enabled browsers since the default is for
188  *  Javascript-disabled browsers
189  */
190  $(document).ready(function() {
191     if($("input[type='hidden'][name='export_method']").attr("value") != "custom-no-form") {
192         $("#quick_or_custom").show();
193     }
194     $("#scroll_to_options_msg").hide();
195     $(".format_specific_options").hide();
196     $(".format_specific_options").css({ "border": 0, "margin": 0, "padding": 0});
197     $(".format_specific_options h3").remove();
198     toggle_quick_or_custom();
199     toggle_structure_data_opts($("select[id='plugins']").attr("value"));
200     toggle_sql_include_comments();
204  * Disables the "Dump some row(s)" sub-options when it is not selected
205  */
206  $(document).ready(function() {
207      $("input[type='radio'][name='allrows']").change(function() {
208          if($("input[type='radio'][name='allrows']:checked").attr("value") == "1") {
209             $("label[for='limit_to']").fadeTo('fast', 0.4);
210              $("label[for='limit_from']").fadeTo('fast', 0.4);
211              $("input[type='text'][name='limit_to']").attr('disabled', 'disabled');
212              $("input[type='text'][name='limit_from']").attr('disabled', 'disabled');
213          } else {
214             $("label[for='limit_to']").fadeTo('fast', 1);
215             $("label[for='limit_from']").fadeTo('fast', 1);
216             $("input[type='text'][name='limit_to']").removeAttr('disabled');
217             $("input[type='text'][name='limit_from']").removeAttr('disabled');
218          }
219      });