diff --git a/js/db_structure.js b/js/db_structure.js index e7074ba878..2a3be33cb6 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -245,7 +245,7 @@ AJAX.registerOnload('db_structure.js', function () { */ var question = PMA_messages.strTruncateTableStrongWarning + ' ' + PMA_sprintf(PMA_messages.strDoYouReally, 'TRUNCATE ' + escapeHtml(curr_table_name)) - + getForeignKeyCheckbox(); + + getForeignKeyCheckboxLoader(); $this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function (url) { @@ -273,7 +273,7 @@ AJAX.registerOnload('db_structure.js', function () { PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest + " : " + data.error, false); } }); // end $.get() - }); //end $.PMA_confirm() + }, loadForeignKeyCheckbox); //end $.PMA_confirm() }); //end of Truncate Table Ajax action /** @@ -308,7 +308,7 @@ AJAX.registerOnload('db_structure.js', function () { question = PMA_sprintf(PMA_messages.strDoYouReally, 'DROP VIEW ' + escapeHtml(curr_table_name)); } - question += getForeignKeyCheckbox(); + question += getForeignKeyCheckboxLoader(); $this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function (url) { @@ -328,7 +328,7 @@ AJAX.registerOnload('db_structure.js', function () { PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest + " : " + data.error, false); } }); // end $.get() - }); // end $.PMA_confirm() + }, loadForeignKeyCheckbox); // end $.PMA_confirm() }); //end of Drop Table Ajax action /** diff --git a/js/functions.js b/js/functions.js index 01b2e649ec..b25e264298 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1695,18 +1695,33 @@ function pdfPaperSize(format, axis) * * @return string */ -function getForeignKeyCheckbox() { - default_fk_check_value = PMA_commonParams.get('default_fk_check_value'); - var html = ""; - html += "
"; - html += ""; - html += ""; - html += ""; - html += "
"; +function getForeignKeyCheckboxLoader() { + var html = ''; + html += '
'; + html += '
'; + html += PMA_getImage('ajax_clock_small.gif'); + html += '
'; + html += '
'; return html; } +function loadForeignKeyCheckbox() { + // Load default foreign key check value + var params = { + 'ajax_request': true, + 'token': PMA_commonParams.get('token'), + 'server': PMA_commonParams.get('server'), + 'get_default_fk_check_value': true + }; + $.get('sql.php', params, function (data) { + var html = '' + + '' + + ''; + $('.load-default-fk-check-value').replaceWith(html); + }); +} + function getJSConfirmCommonParam(elem) { return { 'is_js_confirmed' : 1, @@ -1765,7 +1780,7 @@ AJAX.registerOnload('functions.js', function () { var old_text = $inner_sql.html(); var new_content = "\n"; - new_content += getForeignKeyCheckbox(); + new_content += getForeignKeyCheckboxLoader(); new_content += "\n"; new_content += "\n"; var $editor_area = $('div#inline_editor'); @@ -1774,6 +1789,7 @@ AJAX.registerOnload('functions.js', function () { $editor_area.insertBefore($inner_sql); } $editor_area.html(new_content); + loadForeignKeyCheckbox(); $inner_sql.hide(); bindCodeMirrorToInlineEditor(); @@ -2595,12 +2611,13 @@ function PMA_SQLPrettyPrint(string) * return a jQuery object yet and hence cannot be chained * * @param string question - * @param string url URL to be passed to the callbackFn to make + * @param string url URL to be passed to the callbackFn to make * an Ajax call to - * @param function callbackFn callback to execute after user clicks on OK + * @param function callbackFn callback to execute after user clicks on OK + * @param function openCallback optional callback to run when dialog is shown */ -jQuery.fn.PMA_confirm = function (question, url, callbackFn) { +jQuery.fn.PMA_confirm = function (question, url, callbackFn, openCallback) { var confirmState = PMA_commonParams.get('confirm'); if (! confirmState) { // user does not want to confirm @@ -2644,6 +2661,7 @@ jQuery.fn.PMA_confirm = function (question, url, callbackFn) { close: function () { $(this).remove(); }, + open: openCallback, modal: true }); }; diff --git a/js/tbl_operations.js b/js/tbl_operations.js index 7f14b62bd3..a47e8fc2a6 100644 --- a/js/tbl_operations.js +++ b/js/tbl_operations.js @@ -203,7 +203,7 @@ AJAX.registerOnload('tbl_operations.js', function () { question += PMA_sprintf( PMA_messages.strDoYouReally, 'DROP TABLE ' + escapeHtml(PMA_commonParams.get('table')) - ) + getForeignKeyCheckbox(); + ) + getForeignKeyCheckboxLoader(); $(this).PMA_confirm(question, $(this).attr('href'), function (url) { @@ -227,7 +227,7 @@ AJAX.registerOnload('tbl_operations.js', function () { PMA_ajaxShowMessage(data.error, false); } }); // end $.get() - }); // end $.PMA_confirm() + }, loadForeignKeyCheckbox); // end $.PMA_confirm() }); //end of Drop Table Ajax action $(document).on('click', "#drop_view_anchor.ajax", function (event) { @@ -272,7 +272,7 @@ AJAX.registerOnload('tbl_operations.js', function () { question += PMA_sprintf( PMA_messages.strDoYouReally, 'TRUNCATE ' + escapeHtml(PMA_commonParams.get('table')) - ) + getForeignKeyCheckbox(); + ) + getForeignKeyCheckboxLoader(); $(this).PMA_confirm(question, $(this).attr('href'), function (url) { PMA_ajaxShowMessage(PMA_messages.strProcessingRequest); @@ -294,7 +294,7 @@ AJAX.registerOnload('tbl_operations.js', function () { PMA_ajaxShowMessage(data.error, false); } }); // end $.get() - }); // end $.PMA_confirm() + }, loadForeignKeyCheckbox); // end $.PMA_confirm() }); //end of Truncate Table Ajax action }); //end $(document).ready for 'Table operations' diff --git a/libraries/Header.class.php b/libraries/Header.class.php index 352d1fff11..d7b037f334 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -257,7 +257,6 @@ class PMA_Header 'confirm' => $GLOBALS['cfg']['Confirm'], 'LoginCookieValidity' => $GLOBALS['cfg']['LoginCookieValidity'], 'logged_in' => isset($GLOBALS['userlink']) ? true : false, - 'default_fk_check_value' => PMA_Util::getDefaultFKCheckValue() ? 1 : 0 ); if (isset($GLOBALS['cfg']['Server']) && isset($GLOBALS['cfg']['Server']['auth_type']) diff --git a/sql.php b/sql.php index 9c2e790552..29ab3202b9 100644 --- a/sql.php +++ b/sql.php @@ -109,6 +109,16 @@ if (isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) { // script has exited at this point } +if (isset($_REQUEST['get_default_fk_check_value']) + && $_REQUEST['get_default_fk_check_value'] == true +) { + $response = PMA_Response::getInstance(); + $response->addJSON( + 'default_fk_check_value', PMA_Util::getDefaultFKCheckValue() + ); + exit; +} + /** * Check ajax request to set the column order and visibility */