1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-13 18:14:07 +02:00

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;