/* vim: set expandtab sw=4 ts=4 sts=4: */ /** * @fileoverview function used for index manipulation pages * @name Table Structure * * @requires jQuery * @requires jQueryUI * @required js/functions.js */ /** * Hides/shows the inputs and submits appropriately depending * on whether the index type chosen is 'SPATIAL' or not. */ function checkIndexType() { /** * @var Object Dropdown to select the index choice. */ $select_index_choice = $('#select_index_choice'); /** * @var Object Dropdown to select the index type. */ $select_index_type = $('#select_index_type'); /** * @var Object Table header for the size column. */ $size_header = $('#index_columns thead tr th:nth-child(2)'); /** * @var Object Inputs to specify the columns for the index. */ $column_inputs = $('select[name="index[columns][names][]"]'); /** * @var Object Inputs to specify sizes for columns of the index. */ $size_inputs = $('input[name="index[columns][sub_parts][]"]'); /** * @var Object Footer containg the controllers to add more columns */ $add_more = $('#index_frm .add_more'); if ($select_index_choice.val() == 'SPATIAL') { // Disable and hide the size column $size_header.hide(); $size_inputs.each(function () { $(this) .prop('disabled', true) .parent('td').hide(); }); // Disable and hide the columns of the index other than the first one var initial = true; $column_inputs.each(function () { $column_input = $(this); if (! initial) { $column_input .prop('disabled', true) .parent('td').hide(); } else { initial = false; } }); // Hide controllers to add more columns $add_more.hide(); } else { // Enable and show the size column $size_header.show(); $size_inputs.each(function () { $(this) .prop('disabled', false) .parent('td').show(); }); // Enable and show the columns of the index $column_inputs.each(function () { $(this) .prop('disabled', false) .parent('td').show(); }); // Show controllers to add more columns $add_more.show(); } if ($select_index_choice.val() == 'SPATIAL' || $select_index_choice.val() == 'FULLTEXT') { $select_index_type.val('').prop('disabled', true); } else { $select_index_type.prop('disabled', false) } } /** * Sets current index information into form parameters. * * @param array source_array Array containing index columns * @param string index_choice Choice of index * * @return void */ function PMA_setIndexFormParameters(source_array, index_choice) { if (index_choice == 'index') { $('input[name="indexes"]').val(JSON.stringify(source_array)); } else { $('input[name="' + index_choice + '_indexes"]').val(JSON.stringify(source_array)); } } /** * Removes a column from an Index. * * @param string col_index Index of column in form * * @return void */ function PMA_removeColumnFromIndex(col_index) { // Get previous index details. var previous_index = $('select[name="field_key[' + col_index + ']"]') .attr('data-index'); if (previous_index.length) { previous_index = previous_index.split(','); switch (previous_index[0].toLowerCase()) { case 'primary': source_array = primary_indexes; break; case 'unique': source_array = unique_indexes; break; case 'index': source_array = indexes; break; case 'fulltext': source_array = fulltext_indexes; break; default: return; } // Remove column from index array. var source_length = source_array[previous_index[1]].columns.length; for (var i=0; i' + '
' + PMA_messages.strCompositeWith + '
' + '' ); // Add each column to list available for composite index. var source_length = source_array.length; var already_present = false; for (var i=0; i' + '' + '