bug #959320, broken vertical row highlighting. major rework of

setvertical pointer-function; should hopefully be still cross-browser.
Confirmed working in MSIE6 and Firefox 0.8.
This commit is contained in:
Garvin Hicking
2004-06-04 08:04:38 +00:00
parent 60861e3f3f
commit 68ca109fe0
3 changed files with 70 additions and 50 deletions

View File

@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2004-06-04 Garvin Hicking <me@supergarv.de>
* Bug #959320: Broken row highlighting in vertical
browsing mode fixed. The pointer will now highlight
columns as expected and unmark the row after unclicking.
2004-06-03 Alexander M. Turek <me@derrabus.de> 2004-06-03 Alexander M. Turek <me@derrabus.de>
* header.inc.php: Undefined variable. * header.inc.php: Undefined variable.

View File

@@ -587,7 +587,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
} }
echo '<!-- Results table -->' . "\n" echo '<!-- Results table -->' . "\n"
. '<table '; . '<table id="table_results" ';
if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') { if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
echo 'border="1" cellpadding="2" cellspacing="0"'; echo 'border="1" cellpadding="2" cellspacing="0"';
} else { } else {
@@ -1201,8 +1201,19 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
$column_style = ''; $column_style = '';
} }
//$column_style .= ' onmousedown="if (document.getElementById(\'id_rows_to_delete' . $row_no . '\')) { document.getElementById(\'id_rows_to_delete' . $row_no . '\').checked = (document.getElementById(\'id_rows_to_delete' . $row_no . '\').checked ? false : true); }" '; if ($disp_direction == 'vertical' && (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1'))) {
if ($GLOBALS['cfg']['BrowsePointerColor'] != '') {
$column_style .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
. ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
}
if ($GLOBALS['cfg']['BrowseMarkerColor'] != '') {
$column_style .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\'); setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');"';
} else {
$column_style .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" '; $column_style .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
}
} else {
$column_style .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
}// end if
// garvin: Wrap MIME-transformations. [MIME] // garvin: Wrap MIME-transformations. [MIME]
$default_function = 'default_function'; // default_function $default_function = 'default_function'; // default_function
@@ -1586,18 +1597,7 @@ function PMA_displayVerticalTable()
$bgcolor = ($row_no % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']; $bgcolor = ($row_no % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
} }
$on_mouse = ''; echo '<tr>' . "\n";
if (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1')) {
if ($GLOBALS['cfg']['BrowsePointerColor'] != '') {
$on_mouse = ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
. ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
}
if ($GLOBALS['cfg']['BrowseMarkerColor'] != '') {
$on_mouse .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
}
} // end if
echo '<tr ' . $on_mouse . '>' . "\n";
echo $val; echo $val;
$foo_counter = 0; $foo_counter = 0;

View File

@@ -375,7 +375,7 @@ var marked_row = new Array;
* Sets/unsets the pointer and marker in browse mode * Sets/unsets the pointer and marker in browse mode
* *
* @param object the table row * @param object the table row
* @param interger the row number * @param integer the row number
* @param string the action calling this script (over, out or click) * @param string the action calling this script (over, out or click)
* @param string the default background color * @param string the default background color
* @param string the color to use for mouseover * @param string the color to use for mouseover
@@ -504,7 +504,7 @@ function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerCol
* Sets/unsets the pointer and marker in vertical browse mode * Sets/unsets the pointer and marker in vertical browse mode
* *
* @param object the table row * @param object the table row
* @param interger the row number * @param integer the column number
* @param string the action calling this script (over, out or click) * @param string the action calling this script (over, out or click)
* @param string the default background color * @param string the default background color
* @param string the color to use for mouseover * @param string the color to use for mouseover
@@ -514,8 +514,9 @@ function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerCol
* *
* @author Garvin Hicking <me@supergarv.de> (rewrite of setPointer.) * @author Garvin Hicking <me@supergarv.de> (rewrite of setPointer.)
*/ */
function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theDefaultColor2, thePointerColor, theMarkColor) { function setVerticalPointer(theRow, theColNum, theAction, theDefaultColor1, theDefaultColor2, thePointerColor, theMarkColor) {
var theCells = null; var theCells = null;
var tagSwitch = null;
// 1. Pointer and mark feature are disabled or the browser can't get the // 1. Pointer and mark feature are disabled or the browser can't get the
// row -> exits // row -> exits
@@ -524,19 +525,25 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
return false; return false;
} }
// 2. Gets the current row and exits if the browser can't get it
if (typeof(document.getElementsByTagName) != 'undefined') { if (typeof(document.getElementsByTagName) != 'undefined') {
theCells = theRow.getElementsByTagName('td'); tagSwitch = 'tag';
} } else if (typeof(document.getElementById('table_results')) != 'undefined') {
else if (typeof(theRow.cells) != 'undefined') { tagSwitch = 'cells';
theCells = theRow.cells; } else {
}
else {
return false; return false;
} }
// 2. Gets the current row and exits if the browser can't get it
if (tagSwitch == 'tag') {
theRows = document.getElementById('table_results').getElementsByTagName('tr');
theCells = theRows[1].getElementsByTagName('td');
} else if (tagSwitch == 'cells') {
theRows = document.getElementById('table_results').rows;
theCells = theRows[1].cells;
}
// 3. Gets the current color... // 3. Gets the current color...
var rowCellsCnt = theCells.length; var rowCnt = theRows.length;
var domDetect = null; var domDetect = null;
var currentColor = null; var currentColor = null;
var newColor = null; var newColor = null;
@@ -544,8 +551,8 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
// 3.1 ... with DOM compatible browsers except Opera that does not return // 3.1 ... with DOM compatible browsers except Opera that does not return
// valid values with "getAttribute" // valid values with "getAttribute"
if (typeof(window.opera) == 'undefined' if (typeof(window.opera) == 'undefined'
&& typeof(theCells[0].getAttribute) != 'undefined') { && typeof(theCells[theColNum].getAttribute) != 'undefined') {
currentColor = theCells[0].getAttribute('bgcolor'); currentColor = theCells[theColNum].getAttribute('bgcolor');
domDetect = true; domDetect = true;
} }
// 3.2 ... with other browsers // 3.2 ... with other browsers
@@ -555,11 +562,23 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
var c = null; var c = null;
// 5.1 ... with DOM compatible browsers except Opera // 5.1 ... with DOM compatible browsers except Opera
for (c = 0; c < rowCellsCnt; c++) { for (c = 0; c < rowCnt; c++) {
if (domDetect) { if (tagSwitch == 'tag') {
currentColor = theCells[c].getAttribute('bgcolor'); Cells = theRows[c].getElementsByTagName('td');
} else if (tagSwitch == 'cells') {
Cells = theRows[c].cells;
}
if (c == 0) {
Cell = Cells[theColNum + 1];
} else { } else {
currentColor = theCells[c].style.backgroundColor; Cell = Cells[theColNum];
}
if (domDetect) {
currentColor = Cell.getAttribute('bgcolor');
} else {
currentColor = Cell.style.backgroundColor;
} }
// 4. Defines the new color // 4. Defines the new color
@@ -571,17 +590,16 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
newColor = thePointerColor; newColor = thePointerColor;
} else if (theAction == 'click' && theMarkColor != '') { } else if (theAction == 'click' && theMarkColor != '') {
newColor = theMarkColor; newColor = theMarkColor;
// marked_row[theRowNum] = true; marked_row[theColNum] = (typeof(marked_row[theColNum]) == 'undefined' || !marked_row[theColNum])
marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
? true ? true
: null; : null;
} }
} }
// 4.1.2 Current color is the pointer one // 4.1.2 Current color is the pointer one
else if (currentColor.toLowerCase() == thePointerColor.toLowerCase() else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
&& (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) { && (typeof(marked_row[theColNum]) == 'undefined' || !marked_row[theColNum])) {
if (theAction == 'out') { if (theAction == 'out') {
if (c % 2) { if (theColNum % 2) {
newColor = theDefaultColor1; newColor = theDefaultColor1;
} else { } else {
newColor = theDefaultColor2; newColor = theDefaultColor2;
@@ -589,10 +607,7 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
} }
else if (theAction == 'click' && theMarkColor != '') { else if (theAction == 'click' && theMarkColor != '') {
newColor = theMarkColor; newColor = theMarkColor;
// marked_row[theRowNum] = true; marked_row[theColNum] = null;
marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
? true
: null;
} }
} }
// 4.1.3 Current color is the marker one // 4.1.3 Current color is the marker one
@@ -600,8 +615,8 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
if (theAction == 'click') { if (theAction == 'click') {
newColor = (thePointerColor != '') newColor = (thePointerColor != '')
? thePointerColor ? thePointerColor
: ((c % 2) ? theDefaultColor1 : theDefaultColor2); : ((theColNum % 2) ? theDefaultColor1 : theDefaultColor2);
marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum]) marked_row[theColNum] = (typeof(marked_row[theColNum]) == 'undefined' || !marked_row[theColNum])
? true ? true
: null; : null;
} }
@@ -610,11 +625,11 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
// 5. Sets the new color... // 5. Sets the new color...
if (newColor) { if (newColor) {
if (domDetect) { if (domDetect) {
theCells[c].setAttribute('bgcolor', newColor, 0); Cell.setAttribute('bgcolor', newColor, 0);
} }
// 5.2 ... with other browsers // 5.2 ... with other browsers
else { else {
theCells[c].style.backgroundColor = newColor; Cell.style.backgroundColor = newColor;
} }
} // end 5 } // end 5
} // end for } // end for