Translation update done using Pootle.
[phpmyadmin/dkf.git] / js / import.js
blobbe79388867632176b9bc3256da1f5b0c10f7ae44
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3 * Functions used in the import tab
5 * @version $Id$
6 */
9 /**
10 * Toggles the hiding and showing of each plugin's options
11 * according to the currently selected plugin from the dropdown list
13 function changePluginOpts() {
14 $(".format_specific_options").each(function() {
15 $(this).hide();
16 });
17 var selected_plugin_name = $("#plugins option:selected").attr("value");
18 $("#" + selected_plugin_name + "_options").fadeIn('slow');
19 if(selected_plugin_name == "csv") {
20 $("#import_notification").text("Note: If the file contains multiple tables, they will be combined into one");
21 } else {
22 $("#import_notification").text("");
26 /**
27 * Toggles the hiding and showing of each plugin's options and sets the selected value
28 * in the plugin dropdown list according to the format of the selected file
30 function matchFile(fname) {
31 var fname_array = fname.toLowerCase().split(".");
32 var len = fname_array.length;
33 if(len != 0) {
34 var extension = fname_array[len - 1];
35 if (extension == "gz" || extension == "bz2" || extension == "zip") {
36 len--;
38 // Only toggle if the format of the file can be imported
39 if($("select[name='format'] option[value='" + fname_array[len - 1] + "']").length == 1) {
40 $("#plugins option:selected").removeAttr("selected");
41 $("select[name='format'] option[value='" + fname_array[len - 1] + "']").attr('selected', 'selected');
42 changePluginOpts();
46 $(document).ready(function() {
47 // Initially display the options for the selected plugin
48 changePluginOpts();
50 // Whenever the selected plugin changes, change the options displayed
51 $("#plugins").change(function() {
52 changePluginOpts();
53 });
55 $("#input_import_file").change(function() {
56 matchFile($(this).attr("value"));
57 });
59 $("#select_local_import_file").change(function() {
60 matchFile($(this).attr("value"));
61 });
64 * When the "Browse the server" form is clicked or the "Select from the web server upload directory"
65 * form is clicked, the radio button beside it becomes selected and the other form becomes disabled.
67 $("#input_import_file").focus(function() {
68 $("#radio_import_file").attr('checked', 'checked');
69 $("#radio_local_import_file").removeAttr('checked');
70 });
71 $("#select_local_import_file").focus(function() {
72 $("#radio_local_import_file").attr('checked', 'checked');
73 $("#radio_import_file").removeAttr('checked');
74 });
76 /**
77 * Set up the interface for Javascript-enabled browsers since the default is for
78 * Javascript-disabled browsers
80 $("#scroll_to_options_msg").hide();
81 $(".format_specific_options").css({ "border": 0, "margin": 0, "padding": 0 });
82 $(".format_specific_options h3").remove();
83 });