1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * function used for index manipulation pages
8 * Ensures indexes names are valid according to their type and, for a primary
9 * key, lock index name to 'PRIMARY'
11 * @return boolean false if there is no index form, true else
13 function checkIndexName()
15 if (typeof(document.forms['index_frm']) == 'undefined') {
19 // Gets the elements pointers
20 var the_idx_name = document.forms['index_frm'].elements['index'];
21 var the_idx_type = document.forms['index_frm'].elements['index_type'];
23 // Index is a primary key
24 if (the_idx_type.options[0].value == 'PRIMARY' && the_idx_type.options[0].selected) {
25 document.forms['index_frm'].elements['index'].value = 'PRIMARY';
26 if (typeof(the_idx_name.disabled) != 'undefined') {
27 document.forms['index_frm'].elements['index'].disabled = true;
33 if (the_idx_name.value == 'PRIMARY') {
34 document.forms['index_frm'].elements['index'].value = '';
36 if (typeof(the_idx_name.disabled) != 'undefined') {
37 document.forms['index_frm'].elements['index'].disabled = false;
42 } // end of the 'checkIndexName()' function
44 onload = checkIndexName;
47 * Hides/shows the inputs and submits appropriately depending
48 * on whether the index type chosen is 'SPATIAL' or not.
50 function checkIndexType()
53 * @var Object Dropdown to select the index type.
55 $select_index_type = $('#select_index_type');
57 * @var Object Table header for the size column.
59 $size_header = $('thead tr th:nth-child(2)');
61 * @var Object Inputs to specify the columns for the index.
63 $column_inputs = $('select[name="index[columns][names][]"]');
65 * @var Object Inputs to specify sizes for columns of the index.
67 $size_inputs = $('input[name="index[columns][sub_parts][]"]');
69 * @var Object Span containg the controllers to add more columns
71 $add_more = $('#addMoreColumns');
73 if ($select_index_type.val() == 'SPATIAL') {
74 // Disable and hide the size column
76 $size_inputs.each(function(){
78 .attr('disabled', true)
82 // Disable and hide the columns of the index other than the first one
84 $column_inputs.each(function() {
85 $column_input = $(this);
88 .attr('disabled', true)
95 // Hide controllers to add more columns
98 // Enable and show the size column
100 $size_inputs.each(function() {
102 .attr('disabled', false)
103 .parent('td').show();
106 // Enable and show the columns of the index
107 $column_inputs.each(function() {
109 .attr('disabled', false)
110 .parent('td').show();
113 // Show controllers to add more columns
123 * @description <p>Ajax scripts for table index page</p>
125 * Actions ajaxified here:
127 * <li>Showing/hiding inputs depending on the index type chosen</li>
130 * @name document.ready
133 $(document).ready(function() {
135 $('#select_index_type').bind('change', checkIndexType);