Use Option key for Safari for moving (bug #1094137), move key handler function to separate file so we have only one, make movement work correctly in vertical display of properties.

This commit is contained in:
Michal Čihař
2005-01-07 11:48:45 +00:00
parent 4de30d4066
commit 479635e791
7 changed files with 88 additions and 107 deletions

View File

@@ -5,6 +5,13 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2005-01-07 Michal Čihař <michal@cihar.com>
* Documentation.html, tbl_change.php, tbl_properties.inc.php,
libraries/functions.js, libraries/tbl_change.js,
libraries/keyhandler.js: Use Option key for Safari for moving (bug
#1094137), move key handler function to separate file so we have only
one, make movement work correctly in vertical display of properties.
2005-01-06 Marc Delisle <lem9@users.sourceforge.net> 2005-01-06 Marc Delisle <lem9@users.sourceforge.net>
* tbl_change.php: removed old PHP3-workaround that caused problems * tbl_change.php: removed old PHP3-workaround that caused problems
with field names like '000' with field names like '000'

View File

@@ -1540,7 +1540,7 @@ Defaults to FALSE (drop-down). <br />
<b>$cfg['CtrlArrowsMoving'] </b>boolean<br /> <b>$cfg['CtrlArrowsMoving'] </b>boolean<br />
</dt> </dt>
<dd> <dd>
Enable Ctrl+Arrows moving between fields when editing? Enable Ctrl+Arrows (Option+Arrows in Safari) moving between fields when editing?
<br /><br /> <br /><br />
</dd> </dd>
@@ -3572,7 +3572,7 @@ To create a new, empty mimetype please see libraries/transformations/template_ge
[6.16] How can I simply move in page with plenty editing fields? [6.16] How can I simply move in page with plenty editing fields?
</h4> </h4>
<p> <p>
You can use Ctrl+arrows for moving on most pages with plenty editing You can use Ctrl+arrows (Option+Arrows in Safari) for moving on most pages with plenty editing
fields (table structure changes, row editing, etc.) (must be enabled in fields (table structure changes, row editing, etc.) (must be enabled in
configuration - see. <a href="#CtrlArrowsMoving">$cfg['CtrlArrowsMoving']</a>). You can also have a look configuration - see. <a href="#CtrlArrowsMoving">$cfg['CtrlArrowsMoving']</a>). You can also have a look
at the directive <a href="#DefaultPropDisplay">$cfg['DefaultPropDisplay']</a> ('vertical') and see if this at the directive <a href="#DefaultPropDisplay">$cfg['DefaultPropDisplay']</a> ('vertical') and see if this

View File

@@ -745,48 +745,6 @@ function setSelectOptions(the_form, the_select, do_check)
return true; return true;
} // end of the 'setSelectOptions()' function } // end of the 'setSelectOptions()' function
/**
* Allows moving around inputs/select by Ctrl+arrows
*
* @param object event data
*/
function onKeyDownArrowsHandler(e) {
e = e||window.event;
var o = (e.srcElement||e.target);
if (!o) return;
if (o.tagName != "TEXTAREA" && o.tagName != "INPUT" && o.tagName != "SELECT") return;
if (!e.ctrlKey) return;
if (!o.id) return;
var pos = o.id.split("_");
if (pos[0] != "field" || typeof pos[2] == "undefined") return;
var x = pos[2], y=pos[1];
// skip non existent fields
for (i=0; i<10; i++)
{
switch(e.keyCode) {
case 38: y--; break; // up
case 40: y++; break; // down
case 37: x--; break; // left
case 39: x++; break; // right
default: return;
}
var id = "field_" + y + "_" + x;
var nO = document.getElementById(id);
if (nO) break;
}
if (!nO) return;
nO.focus();
if (nO.tagName != 'SELECT') {
nO.select();
}
e.returnValue = false;
}
/** /**
* Inserts multiple fields. * Inserts multiple fields.
* *

59
libraries/keyhandler.js Normal file
View File

@@ -0,0 +1,59 @@
/**
* Allows moving around inputs/select by Ctrl+arrows
*
* @param object event data
*/
function onKeyDownArrowsHandler(e) {
e = e||window.event;
var o = (e.srcElement||e.target);
if (!o) return;
if (o.tagName != "TEXTAREA" && o.tagName != "INPUT" && o.tagName != "SELECT") return;
if (navigator.userAgent.toLowerCase().indexOf('aplewebkit/') != -1) {
if (e.ctrlKey || e.shiftKey || !e.altKey) return;
} else {
if (!e.ctrlKey || e.shiftKey || e.altKey) return;
}
if (!o.id) return;
var pos = o.id.split("_");
if (pos[0] != "field" || typeof pos[2] == "undefined") return;
var x = pos[2], y=pos[1];
// skip non existent fields
for (i=0; i<10; i++)
{
if (switch_movement) {
switch(e.keyCode) {
case 38: x--; break; // up
case 40: x++; break; // down
case 37: y--; break; // left
case 39: y++; break; // right
default: return;
}
} else {
switch(e.keyCode) {
case 38: y--; break; // up
case 40: y++; break; // down
case 37: x--; break; // left
case 39: x++; break; // right
default: return;
}
}
var id = "field_" + y + "_" + x;
var nO = document.getElementById(id);
if (!nO) {
var id = "field_" + y + "_" + x + "_0";
var nO = document.getElementById(id);
}
if (nO) break;
}
if (!nO) return;
nO.focus();
if (nO.tagName != 'SELECT') {
nO.select();
}
e.returnValue = false;
}

View File

@@ -69,53 +69,6 @@ function unNullify(urlField, multi_edit)
return true; return true;
} // end of the 'unNullify()' function } // end of the 'unNullify()' function
/**
* Allows moving around inputs/select by Ctrl+arrows
*
* @param object event data
*/
function onKeyDownArrowsHandler(e) {
e = e||window.event;
var o = (e.srcElement||e.target);
if (!o) return;
if (o.tagName != "TEXTAREA" && o.tagName != "INPUT" && o.tagName != "SELECT") return;
if (!e.ctrlKey || e.shiftKey || e.altKey) return;
if (!o.id) return;
var pos = o.id.split("_");
if (pos[0] != "field" || typeof pos[2] == "undefined") return;
var x = pos[2], y=pos[1];
// skip non existent fields
for (i=0; i<10; i++)
{
switch(e.keyCode) {
case 38: y--; break; // up
case 40: y++; break; // down
case 37: x--; break; // left
case 39: x++; break; // right
default: return;
}
var id = "field_" + y + "_" + x;
var nO = document.getElementById(id);
if (!nO) {
var id = "field_" + y + "_" + x + "_0";
var nO = document.getElementById(id);
}
if (nO) break;
}
if (!nO) return;
nO.focus();
if (nO.tagName != 'SELECT') {
nO.select();
}
e.returnValue = false;
}
var day; var day;
var month; var month;
var year; var year;

View File

@@ -148,8 +148,10 @@ $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5)
<?php if ($cfg['CtrlArrowsMoving']) { ?> <?php if ($cfg['CtrlArrowsMoving']) { ?>
<!-- Set on key handler for moving using by Ctrl+arrows --> <!-- Set on key handler for moving using by Ctrl+arrows -->
<script src="libraries/keyhandler.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
<!-- <!--
var switch_movement = 0;
document.onkeydown = onKeyDownArrowsHandler; document.onkeydown = onKeyDownArrowsHandler;
// --> // -->
</script> </script>

View File

@@ -13,8 +13,10 @@ require_once('./libraries/mysql_charsets.lib.php');
?> ?>
<?php if ($cfg['CtrlArrowsMoving']) { ?> <?php if ($cfg['CtrlArrowsMoving']) { ?>
<!-- Set on key handler for moving using by Ctrl+arrows --> <!-- Set on key handler for moving using by Ctrl+arrows -->
<script src="libraries/keyhandler.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
<!-- <!--
var switch_movement = <?php echo $cfg['DefaultPropDisplay'] == 'horizontal' ? '0' : '1'; ?>;
document.onkeydown = onKeyDownArrowsHandler; document.onkeydown = onKeyDownArrowsHandler;
// --> // -->
</script> </script>