if we have javascript available, use that to toggle more/less links. This is
[squirrelmail.git] / templates / default / js / default.js
index c7cbab66e65cc99b2404d9610ae61586e2a8717c..2c045a36cee40927268c903d03d28920bf239957 100644 (file)
@@ -12,10 +12,19 @@ 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) {
-    chkbox = document.getElementById(chkboxName);
+function row_click(chkboxName, event, formName, checkboxRealName, extra) {
+    var chkbox = document.getElementById(chkboxName);
     if (chkbox) {
         // initialize orig_row_color if not defined already
         if (!orig_row_colors[chkboxName]) {
@@ -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);
     }
 }
 
@@ -33,6 +44,7 @@ function row_click(chkboxName) {
  */
 function getCSSClass (theRow)
 {
+    var rowClass;
        // 3.1 ... with DOM compatible browsers except Opera that does not return
        //         valid values with "getAttribute"
        if (typeof(window.opera) == 'undefined'
@@ -65,7 +77,8 @@ function setCSSClass (obj, newClass) {
  * need to predefine the entire array
  */
 function rowOver(chkboxName) {
-    chkbox = document.getElementById(chkboxName);
+    var chkbox = document.getElementById(chkboxName);
+    var rowClass, rowNum, overClass, clickedClass;
     if (chkbox) {
         if (!orig_row_colors[chkboxName]) {
             rowClass = getCSSClass(chkbox.parentNode.parentNode);
@@ -91,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) {
-    TargetForm = document.getElementById(formname);
-    j = 0;
+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
@@ -213,7 +227,7 @@ function comp_in_new_form(comp_uri, button, myform, iWidth, iHeight) {
     }
     if (!iWidth) iWidth   =  640;
     if (!iHeight) iHeight =  550;
-    sArg = "width=" + iWidth + ",height=" + iHeight + ",scrollbars=yes,resizable=yes,status=yes";
+    var sArg = "width=" + iWidth + ",height=" + iHeight + ",scrollbars=yes,resizable=yes,status=yes";
     var newwin = window.open(comp_uri, "_blank", sArg);
 }
 
@@ -228,7 +242,7 @@ function comp_in_new(comp_uri, iWidth, iHeight) {
  * Reload the read_body screen on sending an mdn receipt
  */
 function sendMDN() {
-    mdnuri=window.location+'&sendreceipt=1';
+    var mdnuri=window.location+'&sendreceipt=1';
     window.location = mdnuri; 
 }
 
@@ -269,3 +283,23 @@ function checkForm(smaction) {
         }
     }
 }
+
+function printThis()
+{
+    parent.frames['right'].focus();
+    parent.frames['right'].print();
+}
+
+/* JS implementation of more/less links in To/CC. Could later be extended
+ * show/hide other interface items */
+function showhide (item, txtmore, txtless) {
+    var oTemp=document.getElementById("recpt_tail_" + item);
+    var oClick=document.getElementById("toggle_" + item);
+    if (oTemp.style.display=="inline") {
+        oTemp.style.display="none";
+        oClick.innerHTML=txtmore;
+    } else {
+        oTemp.style.display="inline";
+        oClick.innerHTML=txtless;
+    }
+}