Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #11697 - Allow shift clicking for selecting multiple action che…

…ckboxes 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
  • Loading branch information...
commit 9ec29cf1dccb2973b9bccc60942d64cfc4207861 1 parent 73d8abf
Jannis Leidel authored January 09, 2010
1  AUTHORS
@@ -78,6 +78,7 @@ answer newbie questions, and generally made Django that much better:
78 78
     Matt Boersma <matt@sprout.org>
79 79
     boobsd@gmail.com
80 80
     Matías Bordese
  81
+    Sean Brant
81 82
     Andrew Brehaut <http://brehaut.net/blog>
82 83
     brut.alll@gmail.com
83 84
     btoll@bestweb.net
22  django/contrib/admin/media/js/actions.js
@@ -4,6 +4,7 @@ var Actions = {
4 4
         counterContainer = document.getElementsBySelector('span.action_counter');
5 5
         actionCheckboxes = document.getElementsBySelector('tr input.action-select');
6 6
         selectAll = document.getElementById('action-toggle');
  7
+        lastChecked = null;
7 8
         for(var i = 0; i < counterContainer.length; i++) {
8 9
             counterContainer[i].style.display = 'inline';
9 10
         }
@@ -15,7 +16,24 @@ var Actions = {
15 16
             });
16 17
         }
17 18
         for(var i = 0; i < actionCheckboxes.length; i++) {
18  
-            addEvent(actionCheckboxes[i], 'click', function() {
  19
+            addEvent(actionCheckboxes[i], 'click', function(e) {
  20
+                if (!e) { var e = window.event; }
  21
+                var target = e.target ? e.target : e.srcElement;
  22
+                if (lastChecked && lastChecked != target && e.shiftKey == true) {
  23
+                    var inrange = false;
  24
+                    lastChecked.checked = target.checked;
  25
+                    Actions.toggleRow(lastChecked.parentNode.parentNode, target.checked);
  26
+                    for (var i = 0; i < actionCheckboxes.length; i++) {
  27
+                        if (actionCheckboxes[i] == lastChecked || actionCheckboxes[i] == target) {
  28
+                            inrange = (inrange) ? false : true;
  29
+                        }
  30
+                        if (inrange) {
  31
+                            actionCheckboxes[i].checked = target.checked;
  32
+                            Actions.toggleRow(actionCheckboxes[i].parentNode.parentNode, target.checked);
  33
+                        }
  34
+                    }
  35
+                }
  36
+                lastChecked = target;
19 37
                 Actions.counter();
20 38
             });
21 39
         }
@@ -28,7 +46,6 @@ var Actions = {
28 46
                 if (target.className == 'action-select') {
29 47
                     var tr = target.parentNode.parentNode;
30 48
                     Actions.toggleRow(tr, target.checked);
31  
-                    Actions.checked();
32 49
                 }
33 50
             });
34 51
         }
@@ -59,6 +76,7 @@ var Actions = {
59 76
         for(var i = 0; i < counterSpans.length; i++) {
60 77
             counterSpans[i].innerHTML = counter;
61 78
         }
  79
+        selectAll.checked = (counter == actionCheckboxes.length);
62 80
     }
63 81
 };
64 82
 

0 notes on commit 9ec29cf

Please sign in to comment.
Something went wrong with that request. Please try again.