Refactoring JavaScript, reduces bandwidth usage on message list when fancy highlighti...
[squirrelmail.git] / functions / page_header.php
index 09af08955c8e2903eae6f6328d1e07189c8c099f..424d420a7f563a3c23ab8e740118363fae10ac86 100644 (file)
@@ -273,7 +273,22 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
 var marked_row = 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
+ */
+function row_click(chkboxName) {
+    chkbox = document.getElementById(chkboxName);
+    if (chkbox) { 
+        chkbox.checked = (chkbox.checked ? false : true); 
+    }
+}
+
+
+
+/*
  * Sets/unsets the pointer and marker in browse mode
  *
  * @param   object    the table row
@@ -355,7 +370,7 @@ function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerCol
             // performed. Then the checkbox would get deactived, even though we need 
             // it activated. Maybe there is a way to detect if the row was clicked, 
             // and not an item therein...
-            document.getElementById('msg[' + theRowNum + ']').checked = true;
+            //document.getElementById('msg[' + theRowNum + ']').checked = true;
         }
     }
     // 4.1.2 Current color is the pointer one
@@ -367,7 +382,7 @@ function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerCol
         else if (theAction == 'click' && theMarkColor != '') {
             newColor              = theMarkColor;
             marked_row[theRowNum] = true;
-            document.getElementById('msg[' + theRowNum + ']').checked = true;
+            //document.getElementById('msg[' + theRowNum + ']').checked = true;
         }
     }
     // 4.1.3 Current color is the marker one
@@ -379,7 +394,7 @@ function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerCol
             marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                   ? true
                                   : null;
-            document.getElementById('msg[' + theRowNum + ']').checked = false;
+            //document.getElementById('msg[' + theRowNum + ']').checked = false;
         }
     } // end 4
 
@@ -404,7 +419,25 @@ function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerCol
 } // end of the 'setPointer()' function
 EOS;
             $js = "\n".'<script language="JavaScript" type="text/javascript">' .
-                        "\n<!--\n" . $js . "// -->\n</script>\n";
+                        "\n<!--\n" . $js;
+            if ($compose_new_win == '1') {
+                if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
+                    $compose_width = '640';
+                }
+                if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
+                    $compose_height = '550';
+                }
+                $js .= "\nfunction comp_in_new(comp_uri) {\n".
+                     "       if (!comp_uri) {\n".
+                     '           comp_uri = "'.$compose_uri."\";\n".
+                     '       }'. "\n".
+                     '    var newwin = window.open(comp_uri' .
+                     ', "_blank",'.
+                     '"width='.$compose_width. ',height='.$compose_height.
+                     ',scrollbars=yes,resizable=yes,status=yes");'."\n".
+                     "}\n\n";
+            }
+            $js .= "// -->\n</script>\n";
             $onload = '';
             displayHtmlHeader ('SquirrelMail', $js);
             break;
@@ -511,9 +544,12 @@ EOS;
     if (!$hide_sm_attributions)
     {
         echo html_tag( 'td', '', 'right' ) ."\n";
-        if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/';
-        if (!isset($provider_name)) $provider_name= 'SquirrelMail';
-        echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
+        if (empty($provider_uri)) {
+            echo '<a href="about.php">SquirrelMail</a>';
+        } else {
+            if (empty($provider_name)) $provider_name= 'SquirrelMail';
+            echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>';
+        }
         echo "</td>\n";
     }
     echo "   </tr>\n".