Start implementing conditional Ajax (in results page)

This commit is contained in:
Marc Delisle
2011-01-22 09:50:12 -05:00
parent 3a739c1bee
commit 5464b54e17
5 changed files with 40 additions and 18 deletions

View File

@@ -172,11 +172,11 @@ $(document).ready(function() {
/**
* Trigger the appendAnchor event to prepare the first table for inline edit
*
* (see $GLOBALS['cfg']['AjaxEnable'])
* @memberOf jQuery
* @name sqlqueryresults_trigger
*/
$("#sqlqueryresults").trigger('appendAnchor');
$("#sqlqueryresults.ajax").trigger('appendAnchor');
/**
* Append the "Show/Hide query box" message to the query input form
@@ -264,11 +264,12 @@ $(document).ready(function() {
/**
* Paginate when we click any of the navigation buttons
* (only if the element has the ajax class, see $cfg['AjaxEnable'])
* @memberOf jQuery
* @name paginate_nav_button_click
* @uses PMA_ajaxShowMessage()
*/
$("input[name=navig]").live('click', function(event) {
$("input[name=navig].ajax").live('click', function(event) {
/** @lends jQuery */
event.preventDefault();
@@ -293,15 +294,22 @@ $(document).ready(function() {
* @name paginate_dropdown_change
*/
$("#pageselector").live('change', function(event) {
event.preventDefault();
PMA_ajaxShowMessage();
var $the_form = $(this).parent("form");
$.post($the_form.attr('action'), $the_form.serialize() + '&ajax_request=true', function(data) {
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
}) // end $.post()
// see $cfg['AjaxEnable']
if ($(this).hasClass('ajax')) {
event.preventDefault();
PMA_ajaxShowMessage();
$.post($the_form.attr('action'), $the_form.serialize() + '&ajax_request=true', function(data) {
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
}) // end $.post()
} else {
$the_form.submit();
}
})// end Paginate results with Page Selector
/**

View File

@@ -2201,8 +2201,11 @@ function PMA_pageselector($rows, $pageNow = 1, $nbTotalPage = 1,
$pageNowMinusRange = ($pageNow - $range);
$pageNowPlusRange = ($pageNow + $range);
$gotopage = $prompt
. ' <select id="pageselector" name="pos" >' . "\n";
$gotopage = $prompt . ' <select id="pageselector" ';
if ($GLOBALS['cfg']['AjaxEnable']) {
$gotopage .= ' class="ajax"';
}
$gotopage .= ' name="pos" >' . "\n";
if ($nbTotalPage < $showAll) {
$pages = range(1, $nbTotalPage);
} else {

View File

@@ -487,6 +487,13 @@ $cfg['ServerDefault'] = 1;
/*
* Other core phpMyAdmin settings
*/
/**
* whether Ajax behavior is active
*
* @global boolean $cfg['AjaxEnable']
*/
$cfg['AjaxEnable'] = true;
/**
* maximum number of db's displayed in left frame and database list
*

View File

@@ -228,7 +228,7 @@ function PMA_displayTableNavigationOneButton($caption, $title, $pos, $html_sql_q
<input type="hidden" name="pos" value="<?php echo $pos; ?>" />
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<?php echo $input_for_real_end; ?>
<input type="submit" name="navig" value="<?php echo $caption_output; ?>"<?php echo $title_output . $onclick; ?> />
<input type="submit" name="navig" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax" ' : '' ); ?> value="<?php echo $caption_output; ?>"<?php echo $title_output . $onclick; ?> />
</form>
</td>
<?php
@@ -303,7 +303,7 @@ onsubmit="return (checkFormElementInRange(this, 'session_max_rows', '<?php echo
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="submit" name="navig" value="<?php echo __('Show'); ?> :" />
<input type="submit" name="navig" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?> value="<?php echo __('Show'); ?> :" />
<input type="text" name="session_max_rows" size="3" value="<?php echo (($_SESSION['tmp_user_values']['max_rows'] != 'all') ? $_SESSION['tmp_user_values']['max_rows'] : $GLOBALS['cfg']['MaxRows']); ?>" class="textfield" onfocus="this.select()" />
<?php echo __('row(s) starting from row #') . "\n"; ?>
<input type="text" name="pos" size="6" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus="this.select()" />

12
sql.php
View File

@@ -730,7 +730,7 @@ if (0 == $num_rows || $is_affected) {
else {
//If we are retrieving the full value of a truncated field or the original
// value of a transformed field, show it here and exit
if( $GLOBALS['inline_edit'] == true) {
if( $GLOBALS['inline_edit'] == true && $GLOBALS['cfg']['AjaxEnable']) {
$row = PMA_DBI_fetch_row($result);
$extra_data = array();
$extra_data['value'] = $row[0];
@@ -750,7 +750,7 @@ else {
unset($message);
if( $GLOBALS['is_ajax_request'] != true) {
if( ! $GLOBALS['is_ajax_request'] || ! $GLOBALS['cfg']['AjaxEnable']) {
if (strlen($table)) {
require './libraries/tbl_common.php';
$url_query .= '&amp;goto=tbl_sql.php&amp;back=tbl_sql.php';
@@ -781,9 +781,13 @@ else {
$fields_cnt = count($fields_meta);
}
if( $GLOBALS['is_ajax_request'] != true ) {
if( ! $GLOBALS['is_ajax_request']) {
//begin the sqlqueryresults div here. container div
echo '<div id="sqlqueryresults">';
echo '<div id="sqlqueryresults"';
if ($GLOBALS['cfg']['AjaxEnable']) {
echo ' class="ajax"';
}
echo '>';
}
// Display previous update query (from tbl_replace)