Create PMA_is_system_schema() function which checks whether current database server...
[phpmyadmin.git] / js / indexes.js
blobabbf4d8b4960d15a6d8babbb57a2286a52c9a59b
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  * function used for index manipulation pages
4  *
5  */
7 /**
8  * Hides/shows the inputs and submits appropriately depending
9  * on whether the index type chosen is 'SPATIAL' or not.
10  */
11 function checkIndexType()
13     /**
14      * @var Object Dropdown to select the index type.
15      */
16     $select_index_type = $('#select_index_type');
17     /**
18      * @var Object Table header for the size column.
19      */
20     $size_header = $('#index_columns thead tr th:nth-child(2)');
21     /**
22      * @var Object Inputs to specify the columns for the index.
23      */
24     $column_inputs = $('select[name="index[columns][names][]"]');
25     /**
26      * @var Object Inputs to specify sizes for columns of the index.
27      */
28     $size_inputs = $('input[name="index[columns][sub_parts][]"]');
29     /**
30      * @var Object Span containg the controllers to add more columns
31      */
32     $add_more = $('#addMoreColumns');
34     if ($select_index_type.val() == 'SPATIAL') {
35         // Disable and hide the size column
36         $size_header.hide();
37         $size_inputs.each(function(){
38             $(this)
39                 .attr('disabled', true)
40                 .parent('td').hide();
41         });
43         // Disable and hide the columns of the index other than the first one
44         var initial = true;
45         $column_inputs.each(function() {
46             $column_input = $(this);
47             if (! initial) {
48                 $column_input
49                     .attr('disabled', true)
50                     .parent('td').hide();
51             } else {
52                 initial = false;
53             }
54         });
56         // Hide controllers to add more columns
57         $add_more.hide();
58     } else {
59         // Enable and show the size column
60         $size_header.show();
61         $size_inputs.each(function() {
62             $(this)
63                 .attr('disabled', false)
64                 .parent('td').show();
65         });
67         // Enable and show the columns of the index
68         $column_inputs.each(function() {
69             $(this)
70                 .attr('disabled', false)
71                 .parent('td').show();
72         });
74         // Show controllers to add more columns
75         $add_more.show();
76     }
79 /**#@+
80  * @namespace   jQuery
81  */
83 /**
84  * @description <p>Ajax scripts for table index page</p>
85  *
86  * Actions ajaxified here:
87  * <ul>
88  * <li>Showing/hiding inputs depending on the index type chosen</li>
89  * </ul>
90  *
91  * @name        document.ready
92  * @memberOf    jQuery
93  */
94 $(document).ready(function() {
95     checkIndexType();
96     checkIndexName("index_frm");
97     $('#select_index_type').live('change', function(event){
98         event.preventDefault();
99         checkIndexType();
100         checkIndexName("index_frm");
101     });
104 /**#@- */