From 241fc4ef6ce4343b0c95eba46f51877abd6cd8b5 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 25 Jan 2011 17:13:57 +0100 Subject: [PATCH] Ctrl+Up and Down in edit and in-place edit --- adminer/edit.inc.php | 2 +- adminer/select.inc.php | 2 +- adminer/static/editing.js | 27 --------------------------- adminer/static/functions.js | 31 +++++++++++++++++++++++++++++++ changes.txt | 2 +- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/adminer/edit.inc.php b/adminer/edit.inc.php index d88108be..9617cb84 100644 --- a/adminer/edit.inc.php +++ b/adminer/edit.inc.php @@ -67,7 +67,7 @@ if ($_POST["save"]) {
\n"; + echo "\n"; foreach ($fields as $name => $field) { echo "
" . $adminer->fieldName($field); $default = $_GET["set"][bracket_escape($name)]; diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 0b4e40d0..143cfe55 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -251,7 +251,7 @@ if (!$columns) { } else { $backward_keys = $adminer->backwardKeys($TABLE, $table_name); - echo "\n"; + echo "
\n"; echo "" . (!$group && $select ? "" : "
" . lang('edit') . ""); $names = array(); $functions = array(); diff --git a/adminer/static/editing.js b/adminer/static/editing.js index 03006d1d..9d4b9446 100644 --- a/adminer/static/editing.js +++ b/adminer/static/editing.js @@ -240,33 +240,6 @@ function editingLengthBlur(edit) { edit.style.display = 'none'; } -/** Find node position -* @param Node -* @return number -*/ -function nodePosition(el) { - var pos = 0; - while (el = el.previousSibling) { - pos++; - } - return pos; -} - -/** Change focus by Ctrl+Up or Down -* @param KeyboardEvent -* @return boolean -*/ -function editingKeydown(event) { - var target = event.target || event.srcElement; - if ((event.keyCode == 40 || event.keyCode == 38) && event.ctrlKey && !event.altKey && !event.metaKey) { // shiftKey allowed - if ((el = target.parentNode.parentNode[(event.keyCode == 40 ? 'nextSibling' : 'previousSibling')]) && (el = el.childNodes[nodePosition(target.parentNode)]) && (el = el.childNodes[nodePosition(target)])) { - el.focus(); - } - return false; - } - return true; -} - /** Show or hide selected table column * @param boolean * @param number diff --git a/adminer/static/functions.js b/adminer/static/functions.js index 8905713d..64a2ce2f 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -107,6 +107,18 @@ function setHtml(id, html) { } } +/** Find node position +* @param Node +* @return number +*/ +function nodePosition(el) { + var pos = 0; + while (el = el.previousSibling) { + pos++; + } + return pos; +} + /** Go to the specified page * @param string * @param string @@ -177,6 +189,25 @@ function textareaKeypress(target, event, tab, button) { +/** Change focus by Ctrl+Up or Ctrl+Down +* @param KeyboardEvent +* @return boolean +*/ +function editingKeydown(event) { + if ((event.keyCode == 40 || event.keyCode == 38) && event.ctrlKey && !event.altKey && !event.metaKey) { // shiftKey allowed + var target = event.target || event.srcElement; + var sibling = (event.keyCode == 40 ? 'nextSibling' : 'previousSibling'); + var el = target.parentNode.parentNode[sibling]; + if (el && (/^tr$/i.test(el.tagName) || (el = el[sibling])) && /^tr$/i.test(el.tagName) && (el = el.childNodes[nodePosition(target.parentNode)]) && (el = el.childNodes[nodePosition(target)])) { + el.focus(); + } + return false; + } + return true; +} + + + /** Create AJAX request * @param string * @param function (text) diff --git a/changes.txt b/changes.txt index c1fbaa30..a29ec7e4 100644 --- a/changes.txt +++ b/changes.txt @@ -7,7 +7,7 @@ History: edit all MS SQL: auto primary and foreign key SQLite: display 0 Create table default data type: int -Create table keyboard shortcuts: Ctrl+Up, Ctrl+Down +Focus upper/lower fields by Ctrl+Up/Ctrl+Down Homepage customization Use IN for search in numeric fields (Editor) Use password input for _md5 and _sha1 fields (Editor)