summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2010-01-09 23:49:11 +0000
committerJannis Leidel <jannis@leidel.info>2010-01-09 23:49:11 +0000
commit9ec29cf1dccb2973b9bccc60942d64cfc4207861 (patch)
tree9d14e59e3a49b941b4a096b34259846f0e407b3a
parent73d8abf3d5d443fcf244c50da67b655eaea735a7 (diff)
Fixed #11697 - Allow shift clicking for selecting multiple action checkboxes in the admin changelist. Thanks buriy and Sean Brant.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12155 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--AUTHORS1
-rw-r--r--django/contrib/admin/media/js/actions.js22
2 files changed, 21 insertions, 2 deletions
diff --git a/AUTHORS b/AUTHORS
index d508d9584d..55211a6790 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -78,6 +78,7 @@ answer newbie questions, and generally made Django that much better:
Matt Boersma <matt@sprout.org>
boobsd@gmail.com
Matías Bordese
+ Sean Brant
Andrew Brehaut <http://brehaut.net/blog>
brut.alll@gmail.com
btoll@bestweb.net
diff --git a/django/contrib/admin/media/js/actions.js b/django/contrib/admin/media/js/actions.js
index 87b2e1b84e..658f0156be 100644
--- a/django/contrib/admin/media/js/actions.js
+++ b/django/contrib/admin/media/js/actions.js
@@ -4,6 +4,7 @@ var Actions = {
counterContainer = document.getElementsBySelector('span.action_counter');
actionCheckboxes = document.getElementsBySelector('tr input.action-select');
selectAll = document.getElementById('action-toggle');
+ lastChecked = null;
for(var i = 0; i < counterContainer.length; i++) {
counterContainer[i].style.display = 'inline';
}
@@ -15,7 +16,24 @@ var Actions = {
});
}
for(var i = 0; i < actionCheckboxes.length; i++) {
- addEvent(actionCheckboxes[i], 'click', function() {
+ addEvent(actionCheckboxes[i], 'click', function(e) {
+ if (!e) { var e = window.event; }
+ var target = e.target ? e.target : e.srcElement;
+ if (lastChecked && lastChecked != target && e.shiftKey == true) {
+ var inrange = false;
+ lastChecked.checked = target.checked;
+ Actions.toggleRow(lastChecked.parentNode.parentNode, target.checked);
+ for (var i = 0; i < actionCheckboxes.length; i++) {
+ if (actionCheckboxes[i] == lastChecked || actionCheckboxes[i] == target) {
+ inrange = (inrange) ? false : true;
+ }
+ if (inrange) {
+ actionCheckboxes[i].checked = target.checked;
+ Actions.toggleRow(actionCheckboxes[i].parentNode.parentNode, target.checked);
+ }
+ }
+ }
+ lastChecked = target;
Actions.counter();
});
}
@@ -28,7 +46,6 @@ var Actions = {
if (target.className == 'action-select') {
var tr = target.parentNode.parentNode;
Actions.toggleRow(tr, target.checked);
- Actions.checked();
}
});
}
@@ -59,6 +76,7 @@ var Actions = {
for(var i = 0; i < counterSpans.length; i++) {
counterSpans[i].innerHTML = counter;
}
+ selectAll.checked = (counter == actionCheckboxes.length);
}
};