]> git.joonet.de Git - adminer.git/commitdiff
Create table keyboard shortcuts: Ctrl+Up, Ctrl+Down
authorJakub Vrana <jakub@vrana.cz>
Tue, 25 Jan 2011 14:26:13 +0000 (15:26 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 25 Jan 2011 14:26:13 +0000 (15:26 +0100)
adminer/include/editing.inc.php
adminer/static/editing.js
changes.txt

index 97936e3c94b42ed741cce7147595f87d13862219..b5ee145fb4891b3522a11cc0e4770a705afb3a5f 100644 (file)
@@ -231,7 +231,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $allowed = 0, $forei
 <?php } ?>
 <td><?php echo "<input type='image' name='add[" . (support("move_col") ? 0 : count($fields)) . "]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>"; ?><script type="text/javascript">row_count = <?php echo count($fields); ?>;</script>
 </thead>
-<?php
+<tbody onkeydown="return editingKeydown(event);"><?php // no newline for JavaScript
        foreach ($fields as $i => $field) {
                $i++;
                $orig = $field[($_POST ? "orig" : "field")];
index 9d4b94463108a5efd65803ace8472d7dba35d698..03006d1d77c1c02a07e4e1029ef575fc664a63b1 100644 (file)
@@ -240,6 +240,33 @@ 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
index 2d1676e6c16c04924cd0ab83073d3c841bdc55b1..fd9d508c3720386a7faa8d14ba9fc4aff081dc33 100644 (file)
@@ -7,6 +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
 Homepage customization
 Use IN for search in numeric fields (Editor)
 Work without session.use_cookies (bug #3138640)