Permalink
Browse files

Shift+click on checkbox to select consecutive rows (thanks to Alexand…

…er Loonar)
  • Loading branch information...
1 parent 4a6c72c commit 97566acd7536cbb8778a1e820b1351d637cf541d @vrana committed Jun 13, 2012
Showing with 40 additions and 5 deletions.
  1. +38 −4 adminer/static/functions.js
  2. +2 −1 changes.txt
@@ -106,10 +106,11 @@ function tableClick(event) {
var click = (!window.getSelection || getSelection().isCollapsed);
var el = event.target || event.srcElement;
while (!/^tr$/i.test(el.tagName)) {
- if (/^table$/i.test(el.tagName)) {
- return;
- }
- if (/^(a|input|textarea)$/i.test(el.tagName)) {
+ if (/^(table|a|input|textarea)$/i.test(el.tagName)) {
+ if (el.type != 'checkbox') {
+ return;
+ }
+ checkboxClick(event, el);
click = false;
}
el = el.parentNode;
@@ -122,6 +123,39 @@ function tableClick(event) {
trCheck(el);
}
+var lastChecked;
+
+/** Shift-click on checkbox for multiple selection.
+ * @param MouseEvent
+ * @param HTMLInputElement
+ */
+function checkboxClick(event, el) {
+ if (!el.name) {
+ return;
+ }
+ if (event.shiftKey && (!lastChecked || lastChecked.name == el.name)) {
+ var checked = (lastChecked ? lastChecked.checked : true);
+ var inputs = el.parentNode.parentNode.parentNode.getElementsByTagName('input');
+ var checking = !lastChecked;
+ for (var i=0; i < inputs.length; i++) {
+ var input = inputs[i];
+ if (input.name === el.name) {
+ if (checking) {
+ input.checked = checked;
+ trCheck(input);
+ }
+ if (input === el || input === lastChecked) {
+ if (checking) {
+ break;
+ }
+ checking = true;
+ }
+ }
+ }
+ }
+ lastChecked = el;
+}
+
/** Set HTML code of an element
* @param string
* @param string undefined to set parentNode to &nbsp;
View
@@ -1,7 +1,8 @@
Adminer 3.4.0-dev:
-Print current time next to executed SQL queries
Highlight code in SQL command by CodeMirror
Link to descending order
+Shift+click on checkbox to select consecutive rows
+Print current time next to executed SQL queries
Warn about selecting data without index
Allow specifying database in login form
Link to original table in EXPLAIN of SELECT * FROM table t

0 comments on commit 97566ac

Please sign in to comment.