Improved the "mark row" feature so it can be used with the "pointer" one

This commit is contained in:
Loïc Chapeaux
2002-03-23 11:12:30 +00:00
parent c8bc6ac992
commit 4fafc30ea4
6 changed files with 97 additions and 49 deletions

View File

@@ -5,6 +5,13 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2002-03-23 Lo<4C>c Chapeaux <lolo@phpheaven.net>
* 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 <lem9@users.sourceforge.net> 2002-03-22 Marc Delisle <lem9@users.sourceforge.net>
* finnish, norwegian updates * finnish, norwegian updates
* ### 2.2.5 released ### * ### 2.2.5 released ###

View File

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

View File

@@ -186,10 +186,9 @@ $cfgBgcolorOne = '#CCCCCC'; // table data row colour
$cfgBgcolorTwo = '#DDDDDD'; // table data row colour, alternate $cfgBgcolorTwo = '#DDDDDD'; // table data row colour, alternate
$cfgBrowsePointerColor = '#CCFFCC'; // color of the pointer in browse mode $cfgBrowsePointerColor = '#CCFFCC'; // color of the pointer in browse mode
// (blank for no pointer) // (blank for no pointer)
$cfgBrowseMarkRow = 0; // if set to 1, $cfgBrowseMarkerColor = '#FFCC99'; // color of the marker (visually marks row
// and $cfgBrowsePointerColor has a // by clicking on it) in browse mode
// value, you can click on rows to // (blank for no marker)
// visually mark them with this color
$cfgTextareaCols = 40; // textarea size (columns) in edit mode $cfgTextareaCols = 40; // textarea size (columns) in edit mode
$cfgTextareaRows = 7; // textarea size (rows) in edit mode $cfgTextareaRows = 7; // textarea size (rows) in edit mode
$cfgLimitChars = 50; // max field data length in browse mode $cfgLimitChars = 50; // max field data length in browse mode

View File

@@ -124,8 +124,8 @@ if (!defined('PMA_COMMON_LIB_INCLUDED')){
if (!isset($cfgBrowsePointerColor)) { if (!isset($cfgBrowsePointerColor)) {
$cfgBrowsePointerColor = ''; $cfgBrowsePointerColor = '';
} }
if (!isset($cfgBrowseMarkRow)) { if (!isset($cfgBrowseMarkerColor)) {
$cfgBrowseMarkRow = 0; $cfgBrowseMarkerColor = '';
} }
if (!isset($cfgTextareaCols)) { if (!isset($cfgTextareaCols)) {
$cfgTextareaCols = 40; $cfgTextareaCols = 40;
@@ -552,8 +552,8 @@ if (!defined('PMA_COMMON_LIB_INCLUDED')){
// 'only_db' is empty for the current user... // 'only_db' is empty for the current user...
else { else {
// ... first checks whether the "safe_show_database" // ... first checks whether the "safe_show_database" is on or not
// is on or not (if MYSQL supports this) // (if MYSQL supports this)
if (defined('PMA_MYSQL_INT_VERSION') && if (defined('PMA_MYSQL_INT_VERSION') &&
PMA_MYSQL_INT_VERSION >= 32330) { PMA_MYSQL_INT_VERSION >= 32330) {
$local_query = 'SHOW VARIABLES LIKE \'safe_show_database\''; $local_query = 'SHOW VARIABLES LIKE \'safe_show_database\'';

View File

@@ -768,12 +768,13 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')){
if ($disp_direction == 'horizontal') { if ($disp_direction == 'horizontal') {
// loic1: pointer code part // loic1: pointer code part
if ($GLOBALS['cfgBrowsePointerColor'] == '') { $on_mouse = '';
$on_mouse = ''; if ($GLOBALS['cfgBrowsePointerColor'] != '') {
} else if ($GLOBALS['cfgBrowseMarkRow'] == '1') { $on_mouse = ' onmouseover="setPointer(this, \'over\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfgBrowsePointerColor'] . '\', \'' . $GLOBALS['cfgBrowseMarkerColor'] . '\')"'
$on_mouse = ' onmousedown="setPointer(this, \'' . $GLOBALS['cfgBrowsePointerColor'] . '\', \'' . $bgcolor . '\')"'; . ' onmouseout="setPointer(this, \'out\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfgBrowsePointerColor'] . '\', \'' . $GLOBALS['cfgBrowseMarkerColor'] . '\')"';
} else { }
$on_mouse = ' onmouseover="setPointer(this, \'' . $GLOBALS['cfgBrowsePointerColor'] . '\', \'' . $bgcolor . '\')" onmouseout="setPointer(this, \'' . $bgcolor . '\', \'' . $bgcolor . '\')"'; if ($GLOBALS['cfgBrowseMarkerColor'] != '') {
$on_mouse .= ' onmousedown="setPointer(this, \'click\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfgBrowsePointerColor'] . '\', \'' . $GLOBALS['cfgBrowseMarkerColor'] . '\')"';
} }
?> ?>
<tr<?php echo $on_mouse; ?>> <tr<?php echo $on_mouse; ?>>

View File

@@ -298,27 +298,28 @@ function checkTransmitDump(theForm, theAction)
/** /**
* The global array below will be used inside the "setPointer()" function * Sets/unsets the pointer and marker in browse mode
*/
var markedRow = new Array();
/**
* Sets/unsets the pointer in browse mode
* *
* @param object the table row * @param object the table row
* @param object the color to use for this row * @param string the action calling this script (over, out or click)
* @param object the background color * @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 * @return boolean whether pointer is set or not
*/ */
function setPointer(theRow, thePointerColor, theNormalBgColor) function setPointer(theRow, theAction, theDefaultColor, thePointerColor, theMarkColor)
{ {
var theCells = null; 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; 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'); theCells = theRow.getElementsByTagName('td');
} }
@@ -329,29 +330,69 @@ function setPointer(theRow, thePointerColor, theNormalBgColor)
return false; return false;
} }
// 3. Gets the current color...
var rowCellsCnt = theCells.length; var rowCellsCnt = theCells.length;
var domDetect = null;
var currentColor = null; var currentColor = null;
var newColor = 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' 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'); currentColor = theCells[0].getAttribute('bgcolor');
newColor = (currentColor.toLowerCase() == thePointerColor.toLowerCase()) domDetect = true;
? theNormalBgColor
: thePointerColor;
for (var c = 0; c < rowCellsCnt; c++) {
theCells[c].setAttribute('bgcolor', newColor, 0);
} // end for
} }
// 3.2 ... with other browsers
else { else {
currentColor = theCells[0].style.backgroundColor; currentColor = theCells[0].style.backgroundColor;
newColor = (currentColor.toLowerCase() == thePointerColor.toLowerCase()) domDetect = false;
? theNormalBgColor } // end 3
: thePointerColor;
for (var c = 0; c < rowCellsCnt; c++) { // 4. Defines the new color
theCells[c].style.backgroundColor = newColor; // 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; return true;
} // end of the 'setPointer()' function } // end of the 'setPointer()' function