Make toggle_all JavaScript fxn globally usable
[squirrelmail.git] / templates / default / js / default.js
index 2c9af1d2676d6901ff9eafe7bb5c361f8cbfeeed..b3a3c096c2c8a950122e7f6e5083c43bc07a9057 100644 (file)
@@ -12,9 +12,18 @@ var orig_row_colors = new Array();
  * (un)Checks checkbox for the row that the current table cell is in
  * when it gets clicked.
  *
- * @param   string   the name of the checkbox that should be (un)checked
+ * @param string                  The (internal) name of the checkbox
+ *                                that should be (un)checked
+ * @param JavaScript event object The JavaScript event associated
+ *                                with this mouse click
+ * @param string                  The name of the encapsulating form
+ * @param string                  The (real) name of the checkbox
+ *                                that should be (un)checked
+ * @param string                  Any extra JavaScript (that will
+ *                                be executed herein if non-empty);
+ *                                must be valid JavaScript expression(s)
  */
-function row_click(chkboxName) {
+function row_click(chkboxName, event, formName, checkboxRealName, extra) {
     var chkbox = document.getElementById(chkboxName);
     if (chkbox) {
         // initialize orig_row_color if not defined already
@@ -24,6 +33,8 @@ function row_click(chkboxName) {
                 orig_row_colors[chkboxName] = orig_row_colors[chkboxName].substring(8, orig_row_colors[chkboxName].length);
         }
         chkbox.checked = (chkbox.checked ? false : true);
+
+        if (extra != '') eval(extra);
     }
 }
 
@@ -93,14 +104,15 @@ function rowOver(chkboxName) {
  * when it gets clicked.
  *
  * @param   string   the id of the form where all checkboxes should be (un)checked
+ * @param   string   the first three characters of target checkboxes, if any
  * @param   boolean  use fancy row coloring when a checkbox is checked
  * @param   string   new color of the checked rows
  */
-function toggle_all(formname, fancy) {
+function toggle_all(formname, name_prefix, fancy) {
     var TargetForm = document.getElementById(formname);
     var j = 0;
     for (var i = 0; i < TargetForm.elements.length; i++) {
-        if (TargetForm.elements[i].type == 'checkbox' && TargetForm.elements[i].name.substring(0,3) == 'msg') {
+        if (TargetForm.elements[i].type == 'checkbox' && (name_prefix == '' || TargetForm.elements[i].name.substring(0,3) == name_prefix)) {
             if (fancy) {
                 array_key = TargetForm.elements[i].getAttribute('id');
                 // initialize orig_row_color if not defined already