diff --git a/ChangeLog b/ChangeLog index e02e54175..c4b93c7d2 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,13 @@ phpMyAdmin - Changelog $Id$ $Source$ +2002-03-23 Loïc Chapeaux + * config.inc.php3, lines 189-192; Documentation.html, lines 853-866; + libraries/common.lib.php3, lines 127-129; + libraries/display_tbl.lib.php3, lines 771-779; + libraries/functions.js, lines 300-398: improved the "mark row" feature so + it can be used with the "pointer" one. + 2002-03-22 Marc Delisle * finnish, norwegian updates * ### 2.2.5 released ### diff --git a/Documentation.html b/Documentation.html index dc6a49e45..983e20461 100755 --- a/Documentation.html +++ b/Documentation.html @@ -850,18 +850,18 @@

-
$cfgBrowsePointerColor string [HTML color]
+
+ $cfgBrowsePointerColor string [HTML color]
+ $cfgBrowseMarkerColor string [HTML color] +
- The color (HTML) used for the pointer in browse mode (does not work - with NS4). -

-
- -
$cfgBrowseMarkRow boolean
-
- If the value is 1, you can visually mark rows with the color in - $cfgBrowsePointerColor, by clicking on them. Works on browsers - that support 'onmousedown'. + The colors (HTML) used for the pointer and the marker in browse mode + (does not work with NS4).
+ The former feature enlights the row you're mouse is passing over and + the latter lets you visually mark/unmark rows by clicking on + them.
+ You can disable both of these features by emptying the convenient + directive.

diff --git a/config.inc.php3 b/config.inc.php3 index c5bf7db36..661e214e5 100755 --- a/config.inc.php3 +++ b/config.inc.php3 @@ -186,10 +186,9 @@ $cfgBgcolorOne = '#CCCCCC'; // table data row colour $cfgBgcolorTwo = '#DDDDDD'; // table data row colour, alternate $cfgBrowsePointerColor = '#CCFFCC'; // color of the pointer in browse mode // (blank for no pointer) -$cfgBrowseMarkRow = 0; // if set to 1, - // and $cfgBrowsePointerColor has a - // value, you can click on rows to - // visually mark them with this color +$cfgBrowseMarkerColor = '#FFCC99'; // color of the marker (visually marks row + // by clicking on it) in browse mode + // (blank for no marker) $cfgTextareaCols = 40; // textarea size (columns) in edit mode $cfgTextareaRows = 7; // textarea size (rows) in edit mode $cfgLimitChars = 50; // max field data length in browse mode diff --git a/libraries/common.lib.php3 b/libraries/common.lib.php3 index a7f16caf6..3148c4d41 100644 --- a/libraries/common.lib.php3 +++ b/libraries/common.lib.php3 @@ -124,8 +124,8 @@ if (!defined('PMA_COMMON_LIB_INCLUDED')){ if (!isset($cfgBrowsePointerColor)) { $cfgBrowsePointerColor = ''; } - if (!isset($cfgBrowseMarkRow)) { - $cfgBrowseMarkRow = 0; + if (!isset($cfgBrowseMarkerColor)) { + $cfgBrowseMarkerColor = ''; } if (!isset($cfgTextareaCols)) { $cfgTextareaCols = 40; @@ -552,8 +552,8 @@ if (!defined('PMA_COMMON_LIB_INCLUDED')){ // 'only_db' is empty for the current user... else { - // ... first checks whether the "safe_show_database" - // is on or not (if MYSQL supports this) + // ... first checks whether the "safe_show_database" is on or not + // (if MYSQL supports this) if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 32330) { $local_query = 'SHOW VARIABLES LIKE \'safe_show_database\''; diff --git a/libraries/display_tbl.lib.php3 b/libraries/display_tbl.lib.php3 index 59d0f3f3c..5f3aa04be 100644 --- a/libraries/display_tbl.lib.php3 +++ b/libraries/display_tbl.lib.php3 @@ -768,12 +768,13 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')){ if ($disp_direction == 'horizontal') { // loic1: pointer code part - if ($GLOBALS['cfgBrowsePointerColor'] == '') { - $on_mouse = ''; - } else if ($GLOBALS['cfgBrowseMarkRow'] == '1') { - $on_mouse = ' onmousedown="setPointer(this, \'' . $GLOBALS['cfgBrowsePointerColor'] . '\', \'' . $bgcolor . '\')"'; - } else { - $on_mouse = ' onmouseover="setPointer(this, \'' . $GLOBALS['cfgBrowsePointerColor'] . '\', \'' . $bgcolor . '\')" onmouseout="setPointer(this, \'' . $bgcolor . '\', \'' . $bgcolor . '\')"'; + $on_mouse = ''; + if ($GLOBALS['cfgBrowsePointerColor'] != '') { + $on_mouse = ' onmouseover="setPointer(this, \'over\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfgBrowsePointerColor'] . '\', \'' . $GLOBALS['cfgBrowseMarkerColor'] . '\')"' + . ' onmouseout="setPointer(this, \'out\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfgBrowsePointerColor'] . '\', \'' . $GLOBALS['cfgBrowseMarkerColor'] . '\')"'; + } + if ($GLOBALS['cfgBrowseMarkerColor'] != '') { + $on_mouse .= ' onmousedown="setPointer(this, \'click\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfgBrowsePointerColor'] . '\', \'' . $GLOBALS['cfgBrowseMarkerColor'] . '\')"'; } ?> > diff --git a/libraries/functions.js b/libraries/functions.js index 003f87d3e..cace77739 100644 --- a/libraries/functions.js +++ b/libraries/functions.js @@ -298,27 +298,28 @@ function checkTransmitDump(theForm, theAction) /** - * The global array below will be used inside the "setPointer()" function - */ -var markedRow = new Array(); - - -/** - * Sets/unsets the pointer in browse mode + * Sets/unsets the pointer and marker in browse mode * * @param object the table row - * @param object the color to use for this row - * @param object the background color + * @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 + * @param string the color to use for marking a row * * @return boolean whether pointer is set or not */ -function setPointer(theRow, thePointerColor, theNormalBgColor) +function setPointer(theRow, theAction, theDefaultColor, thePointerColor, theMarkColor) { var theCells = null; - if (thePointerColor == '' || typeof(theRow.style) == 'undefined') { + // 1. Pointer and mark feature are disabled or the browser can't get the + // row -> exits + if ((thePointerColor == '' && theMarkColor == '') + || typeof(theRow.style) == 'undefined') { 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'); } @@ -329,29 +330,69 @@ function setPointer(theRow, thePointerColor, theNormalBgColor) return false; } + // 3. Gets the current color... var rowCellsCnt = theCells.length; + var domDetect = null; var currentColor = null; var newColor = null; - // Opera does not return valid values with "getAttribute" + // 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' && typeof(theCells[0].getAttribute) != 'undefined') { + && typeof(theCells[0].getAttribute) != 'undefined') { currentColor = theCells[0].getAttribute('bgcolor'); - newColor = (currentColor.toLowerCase() == thePointerColor.toLowerCase()) - ? theNormalBgColor - : thePointerColor; - for (var c = 0; c < rowCellsCnt; c++) { - theCells[c].setAttribute('bgcolor', newColor, 0); - } // end for + domDetect = true; } + // 3.2 ... with other browsers else { currentColor = theCells[0].style.backgroundColor; - newColor = (currentColor.toLowerCase() == thePointerColor.toLowerCase()) - ? theNormalBgColor - : thePointerColor; - for (var c = 0; c < rowCellsCnt; c++) { - theCells[c].style.backgroundColor = newColor; + domDetect = false; + } // end 3 + + // 4. Defines the new color + // 4.1 Current color is the default one + if (currentColor == '' + || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) { + if (theAction == 'over' && thePointerColor != '') { + newColor = thePointerColor; + } + else if (theAction == 'click' && theMarkColor != '') { + newColor = theMarkColor; } } + // 4.1.2 Current color is the pointer one + else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()) { + if (theAction == 'out') { + newColor = theDefaultColor; + } + else if (theAction == 'click' && theMarkColor != '') { + newColor = theMarkColor; + } + } + // 4.1.3 Current color is the marker one + else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) { + if (theAction == 'click') { + newColor = (thePointerColor != '') + ? thePointerColor + : theDefaultColor; + } + } // end 4 + + // 5. Sets the new color... + if (newColor) { + var c = null; + // 5.1 ... with DOM compatible browsers except Opera + if (domDetect) { + for (c = 0; c < rowCellsCnt; c++) { + theCells[c].setAttribute('bgcolor', newColor, 0); + } // end for + } + // 5.2 ... with other browsers + else { + for (c = 0; c < rowCellsCnt; c++) { + theCells[c].style.backgroundColor = newColor; + } + } + } // end 5 return true; } // end of the 'setPointer()' function