Index: betterselect.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/betterselect/betterselect.js,v
retrieving revision 1.1
diff -u -p -r1.1 betterselect.js
--- betterselect.js	30 May 2008 17:37:25 -0000	1.1
+++ betterselect.js	19 Jun 2008 04:33:48 -0000
@@ -1,5 +1,53 @@
-$(document).ready(function() {
-  $('.better-select .form-checkboxes input[@type="checkbox"]').click(function(){
-    this.checked ? $(this).parent().parent().addClass('hilight') : $(this).parent().parent().removeClass('hilight');
-  });
-});
+// $Id: $
+
+Drupal.betterselect = {
+  // Auto attach.
+  autoAttach: function() {
+    var checkboxes = $('.better-select .form-checkboxes input[@type="checkbox"]');
+    checkboxes.each(function(i) {
+      $(this).click(function(event) {
+        // Give an active state.
+        Drupal.betterselect.check(this);
+        
+        // Add power user functionality for mass checking.
+        if (event.shiftKey && i > 0) {
+          var check;
+          var start = false;
+          for (var e = 0; e < checkboxes.length; e++) {
+            check = checkboxes[e];
+            
+            // Find where we need to start checking and set a flag when ready.
+            if (check.checked) {
+              start = true;
+            }
+            
+            if (start) {
+              // Check checkboxes above the clicked checkbox.
+              if (e < i  && !check.checked) {
+                Drupal.betterselect.check(check, true);
+              } 
+              // Uncheck checkboxes below the clicked checkbox.
+              else if (e > i && check.checked) {
+                Drupal.betterselect.check(check, false);
+              }
+            }
+          }
+          
+          // If the user clicked a checkbox in the middle, we allow them to "scale down" 
+          // the mass selection and we keep this one active.
+          if (!this.checked) {
+            Drupal.betterselect.check(this, true);
+          }
+        }
+      });
+    });
+  },
+  
+  // Handle checking a checkbox.
+  check: function(element, checked) {
+    element.checked = typeof(checked) != 'undefined' ? checked : element.checked;
+    element.checked ? $(element).parent().parent().addClass('hilight') : $(element).parent().parent().removeClass('hilight');
+  }
+}
+
+$(document).ready(Drupal.betterselect.autoAttach);
