Better looking settings tabs in pmahomme
[phpmyadmin.git] / js / export.js
bloba356d4526c8834881e6f4a7ebeca30340d974463
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  * Functions used in the export tab
4  *
5  */
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)
55     var radioFormName = pluginName + "_structure_or_data";
56     var dataDiv = "#" + pluginName + "_data";
57     var structureDiv = "#" + pluginName + "_structure";
58     var show = $("input[type='radio'][name='" + radioFormName + "']:checked").attr("value");
59     if(show == 'data') {
60         $(dataDiv).slideDown('slow');
61         $(structureDiv).slideUp('slow');
62     } else {
63         $(structureDiv).slideDown('slow');
64         if(show == 'structure') {
65             $(dataDiv).slideUp('slow');
66         } else {
67             $(dataDiv).slideDown('slow');
68         }
69     }
72 $(document).ready(function() {
73     $("input[type='radio'][name='latex_structure_or_data']").change(function() {
74         toggle_structure_data_opts("latex");
75     });
76     $("input[type='radio'][name='odt_structure_or_data']").change(function() {
77         toggle_structure_data_opts("odt");
78     });
79     $("input[type='radio'][name='texytext_structure_or_data']").change(function() {
80         toggle_structure_data_opts("texytext");
81     });
82     $("input[type='radio'][name='htmlword_structure_or_data']").change(function() {
83         toggle_structure_data_opts("htmlword");
84     });
85     $("input[type='radio'][name='sql_structure_or_data']").change(function() {
86         toggle_structure_data_opts("sql");
87     });
88 });
90 /**
91  * Toggles the disabling of the "save to file" options
92  */
93 function toggle_save_to_file()
95     if($("#radio_dump_asfile:checked").length == 0) {
96         $("#ul_save_asfile > li").fadeTo('fast', 0.4);
97         $("#ul_save_asfile > li > input").attr('disabled', 'disabled');
98         $("#ul_save_asfile > li> select").attr('disabled', 'disabled');
99     } else {
100         $("#ul_save_asfile > li").fadeTo('fast', 1);
101         $("#ul_save_asfile > li > input").removeAttr('disabled');
102         $("#ul_save_asfile > li> select").removeAttr('disabled');
103     }
106 $(document).ready(function() {
107     toggle_save_to_file();
108     $("input[type='radio'][name='output_format']").change(function() {
109         toggle_save_to_file();
110     });
114  * For SQL plugin, toggles the disabling of the "display comments" options
115  */
116 function toggle_sql_include_comments()
118     $("#checkbox_sql_include_comments").change(function() {
119         if($("#checkbox_sql_include_comments:checked").length == 0) {
120             $("#ul_include_comments > li").fadeTo('fast', 0.4);
121             $("#ul_include_comments > li > input").attr('disabled', 'disabled');
122          } else {
123             // If structure is not being exported, the comment options for structure should not be enabled
124             if($("#radio_sql_structure_or_data_data:checked").length == 1) {
125                 $("#text_sql_header_comment").parent("li").fadeTo('fast', 1);
126                 $("#text_sql_header_comment").removeAttr('disabled');
127             } else {
128                 $("#ul_include_comments > li").fadeTo('fast', 1);
129                 $("#ul_include_comments > li > input").removeAttr('disabled');
130             }
131          }
132      });
136  * For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options
137  */
138 $(document).ready(function() {
139      $("#checkbox_sql_create_table_statements").change(function() {
140          if($("#checkbox_sql_create_table_statements:checked").length == 0) {
141             $("#checkbox_sql_if_not_exists").removeAttr('checked');
142             $("#checkbox_sql_auto_increment").removeAttr('checked');
143         } else {
144             $("#checkbox_sql_if_not_exists").attr('checked', 'checked');
145             $("#checkbox_sql_auto_increment").attr('checked', 'checked');
146         }
147     });
151  * Disables the view output as text option if the output must be saved as a file
152  */
153 $(document).ready(function() {
154     $("#plugins").change(function() {
155         var active_plugin = $("#plugins option:selected").attr("value");
156          var force_file = $("#force_file_" + active_plugin).attr("value");
157         if(force_file == "true") {
158             $("#radio_view_as_text").attr('disabled', 'disabled');
159             $("#radio_view_as_text").parent().fadeTo('fast', 0.4);
160         } else {
161             $("#radio_view_as_text").removeAttr('disabled');
162             $("#radio_view_as_text").parent().fadeTo('fast', 1);
163         }
164     });
168  * Toggles display of options when quick and custom export are selected
169  */
170 function toggle_quick_or_custom()
172     if($("$(this):checked").attr("value") == "custom") {
173         $("#databases_and_tables").show();
174         $("#rows").show();
175         $("#output").show();
176         $("#format_specific_opts").show();
177         $("#output_quick_export").hide();
178         var selected_plugin_name = $("#plugins option:selected").attr("value");
179         $("#" + selected_plugin_name + "_options").show();
180     } else {
181         $("#databases_and_tables").hide();
182         $("#rows").hide();
183         $("#output").hide();
184         $("#format_specific_opts").hide();
185         $("#output_quick_export").show();
186     }
189 $(document).ready(function() {
190     $("input[type='radio'][name='quick_or_custom']").change(function() {
191         toggle_quick_or_custom();
192     });
196  * Sets up the interface for Javascript-enabled browsers since the default is for
197  *  Javascript-disabled browsers
198  */
199  $(document).ready(function() {
200     if($("input[type='hidden'][name='export_method']").attr("value") != "custom-no-form") {
201         $("#quick_or_custom").show();
202     }
203     $("#scroll_to_options_msg").hide();
204     $(".format_specific_options").hide();
205     $(".format_specific_options").css({ "border": 0, "margin": 0, "padding": 0});
206     $(".format_specific_options h3").remove();
207     toggle_quick_or_custom();
208     toggle_structure_data_opts($("select[id='plugins']").attr("value"));
209     toggle_sql_include_comments();
213  * Disables the "Dump some row(s)" sub-options when it is not selected
214  */
215  $(document).ready(function() {
216      $("input[type='radio'][name='allrows']").change(function() {
217          if($("input[type='radio'][name='allrows']:checked").attr("value") == "1") {
218             $("label[for='limit_to']").fadeTo('fast', 0.4);
219              $("label[for='limit_from']").fadeTo('fast', 0.4);
220              $("input[type='text'][name='limit_to']").attr('disabled', 'disabled');
221              $("input[type='text'][name='limit_from']").attr('disabled', 'disabled');
222          } else {
223             $("label[for='limit_to']").fadeTo('fast', 1);
224             $("label[for='limit_from']").fadeTo('fast', 1);
225             $("input[type='text'][name='limit_to']").removeAttr('disabled');
226             $("input[type='text'][name='limit_from']").removeAttr('disabled');
227          }
228      });