From f328f6d4a933cb4b0d0328687c214f809a919749 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sat, 5 Feb 2011 07:18:42 -0500 Subject: [PATCH 1/4] Conditional Ajax in Privileges --- js/server_privileges.js | 27 ++++++++++++++++++--------- server_privileges.php | 18 ++++++++++++------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/js/server_privileges.js b/js/server_privileges.js index 01ffac448..a18ec9f4a 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -148,11 +148,12 @@ $(document).ready(function() { * * @see PMA_ajaxShowMessage() * @see appendNewUser() + * @see $cfg['AjaxEnable'] * @memberOf jQuery * @name add_user_click * */ - $("#fieldset_add_user a").live("click", function(event) { + $("#fieldset_add_user a.ajax").live("click", function(event) { /** @lends jQuery */ event.preventDefault(); @@ -225,10 +226,11 @@ $(document).ready(function() { * Ajax event handler for 'Reload Privileges' anchor * * @see PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] * @memberOf jQuery * @name reload_privileges_click */ - $("#reload_privileges_anchor").live("click", function(event) { + $("#reload_privileges_anchor.ajax").live("click", function(event) { event.preventDefault(); PMA_ajaxShowMessage(PMA_messages['strReloadingPrivileges']); @@ -248,20 +250,23 @@ $(document).ready(function() { * AJAX handler for 'Revoke User' * * @see PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] * @memberOf jQuery * @name revoke_user_click */ - $("#fieldset_delete_user_footer #buttonGo").live('click', function(event) { + $("#fieldset_delete_user_footer #buttonGo.ajax").live('click', function(event) { event.preventDefault(); PMA_ajaxShowMessage(PMA_messages['strRemovingSelectedUsers']); + + $form = $("#usersForm"); - $.post($("#usersForm").attr('action'), $("#usersForm").serialize() + "&delete=" + $(this).attr('value') + "&ajax_request=true", function(data) { + $.post($form.attr('action'), $form.serialize() + "&delete=" + $(this).attr('value') + "&ajax_request=true", function(data) { if(data.success == true) { PMA_ajaxShowMessage(data.message); //Remove the revoked user from the users list - $("#usersForm").find("input:checkbox:checked").parents("tr").slideUp("medium", function() { + $form.find("input:checkbox:checked").parents("tr").slideUp("medium", function() { var this_user_initial = $(this).find('input:checkbox').val().charAt(0).toUpperCase(); $(this).remove(); @@ -271,7 +276,7 @@ $(document).ready(function() { } //Re-check the classes of each row - $("#usersForm") + $form .find('tbody').find('tr:odd') .removeClass('even').addClass('odd') .end() @@ -296,8 +301,9 @@ $(document).ready(function() { * Step 1: Load Edit User Dialog * @memberOf jQuery * @name edit_user_click + * @see $cfg['AjaxEnable'] */ - $(".edit_user_anchor").live('click', function(event) { + $(".edit_user_anchor.ajax").live('click', function(event) { /** @lends jQuery */ event.preventDefault(); @@ -326,6 +332,7 @@ $(document).ready(function() { * Step 2: Submit the Edit User Dialog * * @see PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] * @memberOf jQuery * @name edit_user_submit */ @@ -395,10 +402,11 @@ $(document).ready(function() { * AJAX handler for 'Export Privileges' * * @see PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] * @memberOf jQuery * @name export_user_click */ - $(".export_user_anchor").live('click', function(event) { + $(".export_user_anchor.ajax").live('click', function(event) { /** @lends jQuery */ event.preventDefault(); @@ -424,10 +432,11 @@ $(document).ready(function() { * AJAX handler to Paginate the Users Table * * @see PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] * @name paginate_users_table_click * @memberOf jQuery */ - $("#initials_table").find("a").live('click', function(event) { + $("#initials_table.ajax").find("a").live('click', function(event) { event.preventDefault(); PMA_ajaxShowMessage(); diff --git a/server_privileges.php b/server_privileges.php index c65030026..499fea693 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -19,6 +19,12 @@ $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; require './libraries/server_common.inc.php'; +if ($GLOBALS['cfg']['AjaxEnable']) { + $conditional_class = 'ajax'; +} else { + $conditional_class = ''; +} + /** * Messages are built using the message name */ @@ -1346,7 +1352,7 @@ if (isset($_REQUEST['flush_privileges'])) { /** * defines some standard links */ -$link_edit = ''; -$link_export = ''; + echo ''; foreach ($array_initials as $tmp_initial => $initial_was_found) { if ($initial_was_found) { echo '' . "\n"; @@ -1685,7 +1691,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs // add/delete user fieldset echo '
' . "\n" - . ' ' . "\n" + . ' ' . "\n" . PMA_getIcon('b_usradd.png') . ' ' . __('Add a new User') . '' . "\n" . '
' . "\n" @@ -1702,7 +1708,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . '' . "\n"; } else { @@ -1720,7 +1726,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs } $flushnote = new PMA_Message(__('Note: phpMyAdmin gets the users\' privileges directly from MySQL\'s privilege tables. The content of these tables may differ from the privileges the server uses, if they have been changed manually. In this case, you should %sreload the privileges%s before you continue.'), PMA_Message::NOTICE); - $flushnote->addParam('', false); + $flushnote->addParam('', false); $flushnote->addParam('', false); $flushnote->display(); } From 3be186360686d07efa34c005248097914a8eced1 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sat, 5 Feb 2011 07:34:56 -0500 Subject: [PATCH 2/4] Conditional Ajax on sorting results --- js/sql.js | 6 ++++-- libraries/display_tbl.lib.php | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/js/sql.js b/js/sql.js index f4fe70847..1cae3c515 100644 --- a/js/sql.js +++ b/js/sql.js @@ -269,6 +269,7 @@ $(document).ready(function() { * @memberOf jQuery * @name paginate_nav_button_click * @uses PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] */ $("input[name=navig].ajax").live('click', function(event) { /** @lends jQuery */ @@ -293,11 +294,11 @@ $(document).ready(function() { * Paginate results with Page Selector dropdown * @memberOf jQuery * @name paginate_dropdown_change + * @see $cfg['AjaxEnable'] */ $("#pageselector").live('change', function(event) { var $the_form = $(this).parent("form"); - // see $cfg['AjaxEnable'] if ($(this).hasClass('ajax')) { event.preventDefault(); @@ -317,8 +318,9 @@ $(document).ready(function() { * Ajax Event handler for sorting the results table * @memberOf jQuery * @name table_results_sort_click + * @see $cfg['AjaxEnable'] */ - $("#table_results").find("a[title=Sort]").live('click', function(event) { + $("#table_results.ajax").find("a[title=Sort]").live('click', function(event) { event.preventDefault(); PMA_ajaxShowMessage(); diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 875cff22e..082e93cd2 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -623,7 +623,11 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ echo '' . "\n"; } - echo '
' . $tmp_initial . '
' . "\n"; + echo '
' . "\n"; if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') { echo '' . "\n"; From 8b72097fb0333b61da594fdf38361318c360333d Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sat, 5 Feb 2011 07:46:27 -0500 Subject: [PATCH 3/4] Unneeded wrapping of jQuery object --- js/sql.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/js/sql.js b/js/sql.js index 1cae3c515..843c37b5d 100644 --- a/js/sql.js +++ b/js/sql.js @@ -325,9 +325,12 @@ $(document).ready(function() { PMA_ajaxShowMessage(); - $.get($(this).attr('href'), $(this).serialize() + '&ajax_request=true', function(data) { - $("#sqlqueryresults").html(data); - $("#sqlqueryresults").trigger('appendAnchor'); + $anchor = $(this); + + $.get($anchor.attr('href'), $anchor.serialize() + '&ajax_request=true', function(data) { + $("#sqlqueryresults") + .html(data) + .trigger('appendAnchor'); }) // end $.get() })//end Sort results table From 9443d6efc2359ba104714fc8d29a4ab2f2ac0447 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sat, 5 Feb 2011 07:57:30 -0500 Subject: [PATCH 4/4] Conditional Ajax on display Options --- js/sql.js | 12 ++++++++---- libraries/display_tbl.lib.php | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/js/sql.js b/js/sql.js index 843c37b5d..593cbe7de 100644 --- a/js/sql.js +++ b/js/sql.js @@ -338,13 +338,17 @@ $(document).ready(function() { * Ajax Event handler for the display options * @memberOf jQuery * @name displayOptionsForm_submit + * @see $cfg['AjaxEnable'] */ - $("#displayOptionsForm").live('submit', function(event) { + $("#displayOptionsForm.ajax").live('submit', function(event) { event.preventDefault(); - $.post($(this).attr('action'), $(this).serialize() + '&ajax_request=true' , function(data) { - $("#sqlqueryresults").html(data); - $("#sqlqueryresults").trigger('appendAnchor'); + $form = $(this); + + $.post($form.attr('action'), $form.serialize() + '&ajax_request=true' , function(data) { + $("#sqlqueryresults") + .html(data) + .trigger('appendAnchor'); }) // end $.post() }) //end displayOptionsForm handler diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 082e93cd2..7d0299ccf 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -540,7 +540,11 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ // Display options (if we are not in print view) if (! (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1')) { - echo '
'; + echo ''; $url_params = array( 'db' => $db, 'table' => $table,