Shift+click on checkbox to select consecutive rows (thanks to Alexander Loonar)

This commit is contained in:
Jakub Vrana 2012-06-13 12:21:21 -07:00
parent 4a6c72cd1c
commit 97566acd75
2 changed files with 40 additions and 5 deletions

View 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;

View 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