1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * Functions used in the export tab
8 * Disables the "Dump some row(s)" sub-options
10 function disable_dump_some_rows_sub_options()
12 $("label[for='limit_to']").fadeTo('fast', 0.4);
13 $("label[for='limit_from']").fadeTo('fast', 0.4);
14 $("input[type='text'][name='limit_to']").prop('disabled', 'disabled');
15 $("input[type='text'][name='limit_from']").prop('disabled', 'disabled');
19 * Enables the "Dump some row(s)" sub-options
21 function enable_dump_some_rows_sub_options()
23 $("label[for='limit_to']").fadeTo('fast', 1);
24 $("label[for='limit_from']").fadeTo('fast', 1);
25 $("input[type='text'][name='limit_to']").prop('disabled', '');
26 $("input[type='text'][name='limit_from']").prop('disabled', '');
30 * Unbind all event handlers before tearing down a page
32 AJAX.registerTeardown('export.js', function () {
33 $("#plugins").unbind('change');
34 $("input[type='radio'][name='sql_structure_or_data']").unbind('change');
35 $("input[type='radio'][name='latex_structure_or_data']").unbind('change');
36 $("input[type='radio'][name='odt_structure_or_data']").unbind('change');
37 $("input[type='radio'][name='texytext_structure_or_data']").unbind('change');
38 $("input[type='radio'][name='htmlword_structure_or_data']").unbind('change');
39 $("input[type='radio'][name='sql_structure_or_data']").unbind('change');
40 $("input[type='radio'][name='output_format']").unbind('change');
41 $("#checkbox_sql_include_comments").unbind('change');
42 $("#plugins").unbind('change');
43 $("input[type='radio'][name='quick_or_custom']").unbind('change');
44 $("input[type='radio'][name='allrows']").unbind('change');
47 AJAX.registerOnload('export.js', function () {
49 * Toggles the hiding and showing of each plugin's options
50 * according to the currently selected plugin from the dropdown list
52 $("#plugins").change(function () {
53 $("#format_specific_opts div.format_specific_options").hide();
54 var selected_plugin_name = $("#plugins option:selected").val();
55 $("#" + selected_plugin_name + "_options").show();
59 * Toggles the enabling and disabling of the SQL plugin's comment options that apply only when exporting structure
61 $("input[type='radio'][name='sql_structure_or_data']").change(function () {
62 var comments_are_present = $("#checkbox_sql_include_comments").prop("checked");
63 var show = $("input[type='radio'][name='sql_structure_or_data']:checked").val();
65 // disable the SQL comment options
66 if (comments_are_present) {
67 $("#checkbox_sql_dates").prop('disabled', true).parent().fadeTo('fast', 0.4);
69 $("#checkbox_sql_relation").prop('disabled', true).parent().fadeTo('fast', 0.4);
70 $("#checkbox_sql_mime").prop('disabled', true).parent().fadeTo('fast', 0.4);
72 // enable the SQL comment options
73 if (comments_are_present) {
74 $("#checkbox_sql_dates").removeProp('disabled').parent().fadeTo('fast', 1);
76 $("#checkbox_sql_relation").removeProp('disabled').parent().fadeTo('fast', 1);
77 $("#checkbox_sql_mime").removeProp('disabled').parent().fadeTo('fast', 1);
84 * Toggles the hiding and showing of plugin structure-specific and data-specific
87 function toggle_structure_data_opts(pluginName)
89 var radioFormName = pluginName + "_structure_or_data";
90 var dataDiv = "#" + pluginName + "_data";
91 var structureDiv = "#" + pluginName + "_structure";
92 var show = $("input[type='radio'][name='" + radioFormName + "']:checked").val();
94 $(dataDiv).slideDown('slow');
95 $(structureDiv).slideUp('slow');
97 $(structureDiv).slideDown('slow');
98 if (show == 'structure') {
99 $(dataDiv).slideUp('slow');
101 $(dataDiv).slideDown('slow');
106 AJAX.registerOnload('export.js', function () {
107 $("input[type='radio'][name='latex_structure_or_data']").change(function () {
108 toggle_structure_data_opts("latex");
110 $("input[type='radio'][name='odt_structure_or_data']").change(function () {
111 toggle_structure_data_opts("odt");
113 $("input[type='radio'][name='texytext_structure_or_data']").change(function () {
114 toggle_structure_data_opts("texytext");
116 $("input[type='radio'][name='htmlword_structure_or_data']").change(function () {
117 toggle_structure_data_opts("htmlword");
119 $("input[type='radio'][name='sql_structure_or_data']").change(function () {
120 toggle_structure_data_opts("sql");
125 * Toggles the disabling of the "save to file" options
127 function toggle_save_to_file()
129 if (!$("#radio_dump_asfile").prop("checked")) {
130 $("#ul_save_asfile > li").fadeTo('fast', 0.4);
131 $("#ul_save_asfile > li > input").prop('disabled', true);
132 $("#ul_save_asfile > li> select").prop('disabled', true);
134 $("#ul_save_asfile > li").fadeTo('fast', 1);
135 $("#ul_save_asfile > li > input").prop('disabled', false);
136 $("#ul_save_asfile > li> select").prop('disabled', false);
140 AJAX.registerOnload('export.js', function () {
141 toggle_save_to_file();
142 $("input[type='radio'][name='output_format']").change(toggle_save_to_file);
146 * For SQL plugin, toggles the disabling of the "display comments" options
148 function toggle_sql_include_comments()
150 $("#checkbox_sql_include_comments").change(function () {
151 if (!$("#checkbox_sql_include_comments").prop("checked")) {
152 $("#ul_include_comments > li").fadeTo('fast', 0.4);
153 $("#ul_include_comments > li > input").prop('disabled', true);
155 // If structure is not being exported, the comment options for structure should not be enabled
156 if ($("#radio_sql_structure_or_data_data").prop("checked")) {
157 $("#text_sql_header_comment").removeProp('disabled').parent("li").fadeTo('fast', 1);
159 $("#ul_include_comments > li").fadeTo('fast', 1);
160 $("#ul_include_comments > li > input").removeProp('disabled');
166 AJAX.registerOnload('export.js', function () {
168 * For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options
170 var $create = $("#checkbox_sql_create_table_statements");
171 var $create_options = $("#ul_create_table_statements input");
172 $create.change(function () {
173 $create_options.prop('checked', $(this).prop("checked"));
175 $create_options.change(function () {
176 if ($create_options.is(":checked")) {
177 $create.prop('checked', true);
182 * Disables the view output as text option if the output must be saved as a file
184 $("#plugins").change(function () {
185 var active_plugin = $("#plugins option:selected").val();
186 var force_file = $("#force_file_" + active_plugin).val();
187 if (force_file == "true") {
188 if ($("#radio_dump_asfile").prop('checked') !== true) {
189 $("#radio_dump_asfile").prop('checked', true);
190 toggle_save_to_file();
192 $("#radio_view_as_text").prop('disabled', true).parent().fadeTo('fast', 0.4);
194 $("#radio_view_as_text").prop('disabled', false).parent().fadeTo('fast', 1);
200 * Toggles display of options when quick and custom export are selected
202 function toggle_quick_or_custom()
204 if ($("#radio_custom_export").prop("checked")) {
205 $("#databases_and_tables").show();
208 $("#format_specific_opts").show();
209 $("#output_quick_export").hide();
210 var selected_plugin_name = $("#plugins option:selected").val();
211 $("#" + selected_plugin_name + "_options").show();
213 $("#databases_and_tables").hide();
216 $("#format_specific_opts").hide();
217 $("#output_quick_export").show();
221 function check_time_out(time_limit)
223 if (typeof time_limit === 'undefined' || time_limit === 0) {
226 //margin of one second to avoid race condition to set/access session variable
227 time_limit = time_limit + 1;
228 var href = "export.php";
230 'ajax_request' : true,
231 'token' : PMA_commonParams.get('token'),
232 'check_time_out' : true
234 clearTimeout(time_out);
235 time_out = setTimeout(function(){
236 $.get(href, params, function (data) {
237 if (data['message'] === 'timeout') {
239 '<div class="error">' +
240 PMA_messages.strTimeOutError +
246 }, time_limit * 1000);
249 AJAX.registerOnload('export.js', function () {
250 $("input[type='radio'][name='quick_or_custom']").change(toggle_quick_or_custom);
252 $("#scroll_to_options_msg").hide();
253 $("#format_specific_opts div.format_specific_options")
262 toggle_quick_or_custom();
263 toggle_structure_data_opts($("select#plugins").val());
264 toggle_sql_include_comments();
267 * Initially disables the "Dump some row(s)" sub-options
269 disable_dump_some_rows_sub_options();
272 * Disables the "Dump some row(s)" sub-options when it is not selected
274 $("input[type='radio'][name='allrows']").change(function () {
275 if ($("input[type='radio'][name='allrows']").prop("checked")) {
276 enable_dump_some_rows_sub_options();
278 disable_dump_some_rows_sub_options();