]> git.joonet.de Git - adminer.git/commitdiff
Shift+click on checkbox to select consecutive rows (thanks to Alexander Loonar)
authorJakub Vrana <jakub@vrana.cz>
Wed, 13 Jun 2012 19:21:21 +0000 (12:21 -0700)
committerJakub Vrana <jakub@vrana.cz>
Wed, 13 Jun 2012 19:21:21 +0000 (12:21 -0700)
adminer/static/functions.js
changes.txt

index fd62cd035f841f03034455ce2bb3395e020c7efe..8dbf4c1880278db3579835f21014e8fd7a2ff919 100644 (file)
@@ -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;
index 90b21d716a46293bb6907f48d933818b5007fcc9..14e14b78b0732ad4b285db96a207b23cf3b68fa0 100644 (file)
@@ -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