diff options
author | Madhura Jayaratne <madhura.cj@gmail.com> | 2015-06-22 06:06:46 +0300 |
---|---|---|
committer | Madhura Jayaratne <madhura.cj@gmail.com> | 2015-06-22 06:06:46 +0300 |
commit | f889561c59247deb91a978710005bcf672a2268e (patch) | |
tree | e78f81da47e9e3f9742d5f789a34ae57881dca68 /js/functions.js | |
parent | b31b92032a45e7fb503b0720ec3e44c10405e8a2 (diff) |
Get default_fk_check_value on demand rather than checking the value in every script
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
Diffstat (limited to 'js/functions.js')
-rw-r--r-- | js/functions.js | 44 |
1 files changed, 31 insertions, 13 deletions
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 += "<div>"; - html += "<input type=\"hidden\" name=\"fk_checks\" value=\"0\" />"; - html += "<input type=\"checkbox\" name=\"fk_checks\"" - + " id=\"fk_checks\"" + (default_fk_check_value ? " checked=\"checked\"" : "") + " />"; - html += "<label for=\"fk_checks\">" + PMA_messages.strForeignKeyCheck + "</label>"; - html += "</div>"; +function getForeignKeyCheckboxLoader() { + var html = ''; + html += '<div>'; + html += '<div class="load-default-fk-check-value">'; + html += PMA_getImage('ajax_clock_small.gif'); + html += '</div>'; + html += '</div>'; 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 = '<input type="hidden" name="fk_checks" value="0" />' + + '<input type="checkbox" name="fk_checks" id="fk_checks"' + + (data.default_fk_check_value ? ' checked="checked"' : '') + ' />' + + '<label for="fk_checks">' + PMA_messages.strForeignKeyCheck + '</label>'; + $('.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 = "<textarea name=\"sql_query_edit\" id=\"sql_query_edit\">" + sql_query + "</textarea>\n"; - new_content += getForeignKeyCheckbox(); + new_content += getForeignKeyCheckboxLoader(); new_content += "<input type=\"submit\" id=\"sql_query_edit_save\" class=\"button btnSave\" value=\"" + PMA_messages.strGo + "\"/>\n"; new_content += "<input type=\"button\" id=\"sql_query_edit_discard\" class=\"button btnDiscard\" value=\"" + PMA_messages.strCancel + "\"/>\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 }); }; |