diff --git a/ChangeLog b/ChangeLog index 4df55e5fd7..b03cafbb35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -34,6 +34,7 @@ phpMyAdmin - ChangeLog + Show/hide column in table Browse - bug #3353856 [AJAX] AJAX dialogs use wrong font-size - bug #3354356 [interface] Timepicker does not work in AJAX dialogs ++ AJAX for table Structure Indexes Edit 3.4.4.0 (not yet released) - bug #3323060 [parser] SQL parser breaks AJAX requests if query has unclosed quotes diff --git a/js/functions.js b/js/functions.js index 9cdb44e751..ae5cdbad8f 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2152,9 +2152,45 @@ function displayMoreTableOpts() { } }); } + } $(document).ready(initTooltips); +/** + * Ensures indexes names are valid according to their type and, for a primary + * key, lock index name to 'PRIMARY' + * @param string form_id Variable which parses the form name as + * the input + * @return boolean false if there is no index form, true else + */ +function checkIndexName(form_id) +{ + if ($("#"+form_id).length == 0) { + return false; + } + + // Gets the elements pointers + var $the_idx_name = $("#input_index_name"); + var $the_idx_type = $("#select_index_type"); + + // Index is a primary key + if ($the_idx_type.find("option:selected").attr("value") == 'PRIMARY') { + $the_idx_name.attr("value", 'PRIMARY'); + $the_idx_name.attr("disabled", true); + } + + // Other cases + else { + if ($the_idx_name.attr("value") == 'PRIMARY') { + $the_idx_name.attr("value", ''); + } + $the_idx_name.attr("disabled", false); + } + + return true; +} // end of the 'checkIndexName()' function + + /* Displays tooltips */ function initTooltips() { // Hide the footnotes from the footer (which are displayed for diff --git a/js/indexes.js b/js/indexes.js index ef6f877bdd..abbf4d8b49 100644 --- a/js/indexes.js +++ b/js/indexes.js @@ -4,45 +4,6 @@ * */ -/** - * Ensures indexes names are valid according to their type and, for a primary - * key, lock index name to 'PRIMARY' - * - * @return boolean false if there is no index form, true else - */ -function checkIndexName() -{ - if (typeof(document.forms['index_frm']) == 'undefined') { - return false; - } - - // Gets the elements pointers - var the_idx_name = document.forms['index_frm'].elements['index[Key_name]']; - var the_idx_type = document.forms['index_frm'].elements['index[Index_type]']; - - // Index is a primary key - if (the_idx_type.options[0].value == 'PRIMARY' && the_idx_type.options[0].selected) { - document.forms['index_frm'].elements['index[Key_name]'].value = 'PRIMARY'; - if (typeof(the_idx_name.disabled) != 'undefined') { - document.forms['index_frm'].elements['index[Key_name]'].disabled = true; - } - } - - // Other cases - else { - if (the_idx_name.value == 'PRIMARY') { - document.forms['index_frm'].elements['index[Key_name]'].value = ''; - } - if (typeof(the_idx_name.disabled) != 'undefined') { - document.forms['index_frm'].elements['index[Key_name]'].disabled = false; - } - } - - return true; -} // end of the 'checkIndexName()' function - -onload = checkIndexName; - /** * Hides/shows the inputs and submits appropriately depending * on whether the index type chosen is 'SPATIAL' or not. @@ -56,7 +17,7 @@ function checkIndexType() /** * @var Object Table header for the size column. */ - $size_header = $('thead tr th:nth-child(2)'); + $size_header = $('#index_columns thead tr th:nth-child(2)'); /** * @var Object Inputs to specify the columns for the index. */ @@ -132,7 +93,12 @@ function checkIndexType() */ $(document).ready(function() { checkIndexType(); - $('#select_index_type').bind('change', checkIndexType); + checkIndexName("index_frm"); + $('#select_index_type').live('change', function(event){ + event.preventDefault(); + checkIndexType(); + checkIndexName("index_frm"); + }); }); /**#@- */ diff --git a/js/tbl_structure.js b/js/tbl_structure.js index d4ef1cdf97..49e3fe08f5 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -179,6 +179,7 @@ $(document).ready(function() { height: 230, width: 900, open: PMA_verifyTypeOfAllColumns, + modal: true, buttons : button_options_error })// end dialog options } else { @@ -189,6 +190,7 @@ $(document).ready(function() { height: 600, width: 900, open: PMA_verifyTypeOfAllColumns, + modal: true, buttons : button_options }) //Remove the top menu container from the dialog @@ -269,10 +271,10 @@ $(document).ready(function() { */ var button_options = {}; // in the following function we need to use $(this) - button_options[PMA_messages['strCancel']] = function() {$(this).parent().dialog('close').remove();} + button_options[PMA_messages['strCancel']] = function() {$(this).dialog('close').remove();} var button_options_error = {}; - button_options_error[PMA_messages['strOK']] = function() {$(this).parent().dialog('close').remove();} + button_options_error[PMA_messages['strOK']] = function() {$(this).dialog('close').remove();} var $msgbox = PMA_ajaxShowMessage(); $.get( "tbl_indexes.php" , url , function(data) { @@ -285,6 +287,7 @@ $(document).ready(function() { height: 230, width: 900, open: PMA_verifyTypeOfAllColumns, + modal: true, buttons : button_options_error })// end dialog options } else { @@ -295,16 +298,18 @@ $(document).ready(function() { height: 600, width: 900, open: PMA_verifyTypeOfAllColumns, + modal: true, buttons : button_options }) //Remove the top menu container from the dialog .find("#topmenucontainer").hide() ; // end dialog options + checkIndexName("index_frm"); } PMA_ajaxRemoveMessage($msgbox); }) // end $.get() }); - + /** *Ajax action for submiting the index form **/ @@ -337,8 +342,14 @@ $(document).ready(function() { } } else { - var temp_div = $("