[dev] [imp-patch] selection in folders page

Francois Marier francois at nit.ca
Tue Jul 27 14:28:38 PDT 2004


Here's a Javascript patch for IMP that applies on the Folders page.

It changes the checkbox image, in the column header, for a real
checkbox that performs a select all/none just like the one in the
Mailbox page of IMP.

Francois
-------------- next part --------------
diff -rpuN -X ../ignorelist ../build/imp/templates/folders/actions.inc imp/templates/folders/actions.inc
--- ../build/imp/templates/folders/actions.inc	Tue Dec 16 16:45:29 2003
+++ imp/templates/folders/actions.inc	Fri Jul 16 12:46:44 2004
@@ -1,5 +1,5 @@
 <tr class="item">
-  <td align="center"><?php echo Horde::img('checkbox.gif') ?></td>
+  <td align="left" nowrap="nowrap"><input type="checkbox" name="checkAll" onclick="toggleSelection()" <?php echo Horde::getAccessKeyAndTitle(_("Check _All/None")) ?>" /></td>
   <td align="left" nowrap="nowrap" width="89%">
     <select name="action_choose<?php echo ($i > 0) ? 1 : 0 ?>" onchange="chooseAction(<?php echo ($i > 0) ? 1 : 0 ?>); document.fmanager.action_choose<?php echo ($i > 0) ? 1 : 0 ?>.selectedIndex = 0;">
       <option selected="selected"><?php echo _("Choose Action:") ?></option>
diff -rpuN -X ../ignorelist ../build/imp/templates/folders/javascript.inc imp/templates/folders/javascript.inc
--- ../build/imp/templates/folders/javascript.inc	Fri Jul 16 12:56:55 2004
+++ imp/templates/folders/javascript.inc	Fri Jul 16 12:56:00 2004
@@ -162,6 +162,27 @@ function renameMailbox()
     document.fmanager.submit();
     return true;
 }
+
+function toggleSelection()
+{
+    var total = 0;
+    var checked = 0;
+    for (var i = 0; i < document.fmanager.elements.length; i++) {
+        if (document.fmanager.elements[i].name == "folder_list[]") {
+            total++;
+            if (document.fmanager.elements[i].checked) {
+                checked++;
+            }
+        }
+    }  
+    
+    var new_value = (total != checked);
+    for (var i = 0; i < document.fmanager.elements.length; i++) {
+        if (document.fmanager.elements[i].name == "folder_list[]") {
+            document.fmanager.elements[i].checked = new_value;
+        }
+    }  
+}
 
 //-->
 </script>


More information about the dev mailing list