diff --git a/js/functions.js b/js/functions.js index 6efb5f3626..4d33ce95dc 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3363,8 +3363,7 @@ function indexEditorDialog(url, title, callback_success, callback_failure) .dialog({ title: title, width: 450, - // increase the chance that the footer will be visible: - height: 450, + height: 350, open: PMA_verifyColumnsProperties, modal: true, buttons: button_options, @@ -3372,42 +3371,48 @@ function indexEditorDialog(url, title, callback_success, callback_failure) $(this).remove(); } }); - checkIndexType(); - checkIndexName("index_frm"); - $('#index_columns td').each(function () { - $(this).css("width", $(this).width() + 'px'); - }); - $('#index_columns tbody').sortable(); - PMA_showHints($div); - PMA_init_slider(); - // Add a slider for selecting how many columns to add to the index - $div.find('.slider').slider({ - animate: true, - value: 1, - min: 1, - max: 16, - slide: function (event, ui) { - $(this).closest('fieldset').find('input[type=submit]').val( - PMA_sprintf(PMA_messages.strAddToIndex, ui.value) - ); - } - }); - // focus index size input on column picked - $div.find('table#index_columns select').change(function () { - if ($(this).find("option:selected").val() === '') { - return true; - } - $(this).closest("tr").find("input").focus(); - }); - // Focus the slider, otherwise it looks nearly transparent - $('a.ui-slider-handle').addClass('ui-state-focus'); - // set focus on index name input, if empty - var input = $div.find('input#input_index_name'); - input.val() || input.focus(); + $div.find('.tblFooters').remove(); + showIndexEditDialog($div); } }); // end $.get() } +function showIndexEditDialog($outer) +{ + checkIndexType(); + checkIndexName("index_frm"); + $('#index_columns td').each(function () { + $(this).css("width", $(this).width() + 'px'); + }); + $('#index_columns tbody').sortable(); + PMA_showHints($outer); + PMA_init_slider(); + // Add a slider for selecting how many columns to add to the index + $outer.find('.slider').slider({ + animate: true, + value: 1, + min: 1, + max: 16, + slide: function (event, ui) { + $(this).closest('fieldset').find('input[type=submit]').val( + PMA_sprintf(PMA_messages.strAddToIndex, ui.value) + ); + } + }); + // focus index size input on column picked + $outer.find('table#index_columns select').change(function () { + if ($(this).find("option:selected").val() === '') { + return true; + } + $(this).closest("tr").find("input").focus(); + }); + // Focus the slider, otherwise it looks nearly transparent + $('a.ui-slider-handle').addClass('ui-state-focus'); + // set focus on index name input, if empty + var input = $outer.find('input#input_index_name'); + input.val() || input.focus(); +} + /** * Function to display tooltips that were * generated on the PHP side by PMA_Util::showHint() diff --git a/js/indexes.js b/js/indexes.js index b1040a7f28..d5588d5814 100644 --- a/js/indexes.js +++ b/js/indexes.js @@ -37,7 +37,7 @@ function checkIndexType() /** * @var Object Footer containg the controllers to add more columns */ - $add_more = $('#index_frm .tblFooters'); + $add_more = $('#index_frm .add_more'); if ($select_index_choice.val() == 'SPATIAL') { // Disable and hide the size column @@ -469,6 +469,8 @@ function PMA_indexTypeSelectionDialog(source_array, index_choice, col_index) * Unbind all event handlers before tearing down a page */ AJAX.registerTeardown('indexes.js', function () { + $(document).off('click', '#save_index_frm'); + $(document).off('click', '#preview_index_frm'); $(document).off('change', '#select_index_choice'); $(document).off('click', 'a.drop_primary_key_index_anchor.ajax'); $(document).off('click', "#table_index tbody tr td.edit_index.ajax, #indexes .add_index.ajax"); @@ -492,8 +494,25 @@ AJAX.registerOnload('indexes.js', function () { indexes = []; fulltext_indexes = []; - checkIndexType(); - checkIndexName("index_frm"); + var $form = $("#index_frm"); + if ($form.length > 0) { + showIndexEditDialog($form); + } + + $(document).on('click', '#save_index_frm', function (event) { + event.preventDefault(); + var $form = $("#index_frm"); + var submitData = $form.serialize() + '&do_save_data=1&ajax_request=true&ajax_page_request=true'; + var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest); + AJAX.source = $form; + $.post($form.attr('action'), submitData, AJAX.responseHandler); + }) + + $(document).on('click', '#preview_index_frm', function (event) { + event.preventDefault(); + PMA_previewSQL($('#index_frm')); + }) + $(document).on('change', '#select_index_choice', function (event) { event.preventDefault(); checkIndexType(); diff --git a/libraries/tbl_indexes.lib.php b/libraries/tbl_indexes.lib.php index 37b6ee7c84..b7db2d99af 100644 --- a/libraries/tbl_indexes.lib.php +++ b/libraries/tbl_indexes.lib.php @@ -459,18 +459,21 @@ function PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields) $html .= ''; - $html .= ''; - - $html .= '
'; - + $html .= '
'; $btn_value = sprintf(__('Add %s column(s) to index'), 1); $html .= '
'; $html .= '
'; - $html .= ''; + $html .= ''; + $html .= '
'; $html .= '
'; $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + $html .= ''; return $html;