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$
$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>
* 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"
. '<table ';
. '<table id="table_results" ';
if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
echo 'border="1" cellpadding="2" cellspacing="0"';
} else {
@@ -1201,8 +1201,19 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
$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 . '\');" ';
}
} else {
$column_style .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
}// end if
// garvin: Wrap MIME-transformations. [MIME]
$default_function = 'default_function'; // default_function
@@ -1586,18 +1597,7 @@ function PMA_displayVerticalTable()
$bgcolor = ($row_no % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
}
$on_mouse = '';
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 '<tr>' . "\n";
echo $val;
$foo_counter = 0;

View File

@@ -375,7 +375,7 @@ var marked_row = new Array;
* Sets/unsets the pointer and marker in browse mode
*
* @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 default background color
* @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
*
* @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 default background color
* @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.)
*/
function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theDefaultColor2, thePointerColor, theMarkColor) {
function setVerticalPointer(theRow, theColNum, theAction, theDefaultColor1, theDefaultColor2, thePointerColor, theMarkColor) {
var theCells = null;
var tagSwitch = null;
// 1. Pointer and mark feature are disabled or the browser can't get the
// row -> exits
@@ -524,19 +525,25 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
return false;
}
// 2. Gets the current row and exits if the browser can't get it
if (typeof(document.getElementsByTagName) != 'undefined') {
theCells = theRow.getElementsByTagName('td');
}
else if (typeof(theRow.cells) != 'undefined') {
theCells = theRow.cells;
}
else {
tagSwitch = 'tag';
} else if (typeof(document.getElementById('table_results')) != 'undefined') {
tagSwitch = 'cells';
} else {
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...
var rowCellsCnt = theCells.length;
var rowCnt = theRows.length;
var domDetect = null;
var currentColor = 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
// valid values with "getAttribute"
if (typeof(window.opera) == 'undefined'
&& typeof(theCells[0].getAttribute) != 'undefined') {
currentColor = theCells[0].getAttribute('bgcolor');
&& typeof(theCells[theColNum].getAttribute) != 'undefined') {
currentColor = theCells[theColNum].getAttribute('bgcolor');
domDetect = true;
}
// 3.2 ... with other browsers
@@ -555,11 +562,23 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
var c = null;
// 5.1 ... with DOM compatible browsers except Opera
for (c = 0; c < rowCellsCnt; c++) {
if (domDetect) {
currentColor = theCells[c].getAttribute('bgcolor');
for (c = 0; c < rowCnt; c++) {
if (tagSwitch == 'tag') {
Cells = theRows[c].getElementsByTagName('td');
} else if (tagSwitch == 'cells') {
Cells = theRows[c].cells;
}
if (c == 0) {
Cell = Cells[theColNum + 1];
} 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
@@ -571,17 +590,16 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
newColor = thePointerColor;
} else if (theAction == 'click' && theMarkColor != '') {
newColor = theMarkColor;
// marked_row[theRowNum] = true;
marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
marked_row[theColNum] = (typeof(marked_row[theColNum]) == 'undefined' || !marked_row[theColNum])
? true
: null;
}
}
// 4.1.2 Current color is the pointer one
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 (c % 2) {
if (theColNum % 2) {
newColor = theDefaultColor1;
} else {
newColor = theDefaultColor2;
@@ -589,10 +607,7 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
}
else if (theAction == 'click' && theMarkColor != '') {
newColor = theMarkColor;
// marked_row[theRowNum] = true;
marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
? true
: null;
marked_row[theColNum] = null;
}
}
// 4.1.3 Current color is the marker one
@@ -600,8 +615,8 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
if (theAction == 'click') {
newColor = (thePointerColor != '')
? thePointerColor
: ((c % 2) ? theDefaultColor1 : theDefaultColor2);
marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
: ((theColNum % 2) ? theDefaultColor1 : theDefaultColor2);
marked_row[theColNum] = (typeof(marked_row[theColNum]) == 'undefined' || !marked_row[theColNum])
? true
: null;
}
@@ -610,11 +625,11 @@ function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theD
// 5. Sets the new color...
if (newColor) {
if (domDetect) {
theCells[c].setAttribute('bgcolor', newColor, 0);
Cell.setAttribute('bgcolor', newColor, 0);
}
// 5.2 ... with other browsers
else {
theCells[c].style.backgroundColor = newColor;
Cell.style.backgroundColor = newColor;
}
} // end 5
} // end for