Moving documentation from source code to README
[squirrelmail.git] / functions / mailbox_display.php
index 9e0b1c9332a2a46e8e724260aee1032953b2eaac..06f101386b9b29fe7e3307b284c2af224f090466 100644 (file)
@@ -99,7 +99,8 @@ function printMessageInfo($aMsg) {
         $show_recipient_instead,    /* show recipient name instead of default identity */
         $use_icons,                 /* indicates to use icons or text markers */
         $icon_theme,                /* icons theming */
-        $javascript_on;
+        $javascript_on,
+        $fancy_index_highlite;
 
     $color_string = $color[4];
 
@@ -299,6 +300,7 @@ function printMessageInfo($aMsg) {
     if (!isset($hlt_color)) {
         $hlt_color = $color_string;
     }
+
     $col = 0;
     $sSubject = str_replace(' ', ' ', decodeHeader($sSubject));
     $subject = processSubject($sSubject, $iIndent);
@@ -309,21 +311,39 @@ function printMessageInfo($aMsg) {
 
     // this stuff does the auto row highlighting on mouseover
     //
-    if ($javascript_on) {
+    if ($javascript_on && $fancy_index_highlite) {
+
         $mouseoverColor = $color[5];
-        $clickedColor = $color[2];
+
+        // set this to an empty string to turn off extra 
+        // highlighting of checked rows
+        //
+        //$clickedColor = '';
+        if (!empty($color[16]))
+           $clickedColor = $color[16];
+        else
+           $clickedColor = $color[2];
+
         $row_extra .= ' onmouseover="setPointer(this, ' . $t . ', \'over\', \'' . $hlt_color . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');" onmouseout="setPointer(this, ' . $t . ', \'out\', \'' . $hlt_color . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');" onmousedown="setPointer(this, ' . $t . ', \'click\', \'' . $hlt_color . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');"';
+
     }
 
 
-    echo html_tag( 'tr','','','',$row_extra) . "\n";
+    if ($javascript_on && $fancy_index_highlite)
+        echo "<script language='javascript' type='text/javascript'>\n<!--\n"
+           . "orig_row_colors[" . $t . "] = '" . $hlt_color . "';\n//-->\n</script>";
+    echo html_tag( 'tr', '', '', '', $row_extra) . "\n";
 
 
     // this does the auto-checking of the checkbox no matter 
     // where on the row you click
     //
-    if ($javascript_on)
-        $javascript_auto_click = ' onMouseDown="if (document.getElementById(msg[' . $t . '])) { document.getElementById(msg[' . $t . ']).checked = (document.getElementById(msg[' . $t . ']).checked ? false : true); }"';
+    $javascript_auto_click = '';
+    $checkbox_javascript = '';
+    if ($javascript_on && $fancy_index_highlite) {
+        $javascript_auto_click = ' onMouseDown="row_click(\'msg[' . $t . ']\')"';
+        $checkbox_javascript = ' onClick="this.checked = !this.checked;"';
+    }
 
 
     if (sizeof($index_order)) {
@@ -337,7 +357,7 @@ function printMessageInfo($aMsg) {
         // care of this; just skip it
         //
         $show_label_columns = array();
-        if (!$javascript_on) {
+        if (!($javascript_on && $fancy_index_highlite)) {
             $get_next_two = 0;
             $last_order_part = 0;
             $last_last_order_part = 0;
@@ -373,9 +393,9 @@ function printMessageInfo($aMsg) {
             switch ($index_order_part) {
             case 1: /* checkbox */
                 echo html_tag( 'td',
-                    addCheckBox("msg[$t]", $checkall, $iId),
+                    addCheckBox("msg[$t]", $checkall, $iId, $checkbox_javascript),
                             'center',
-                            $hlt_color );
+                            $hlt_color, $javascript_auto_click);
                 break;
             case 2: /* from */
                 if ($senderAddress != $senderName) {
@@ -409,6 +429,15 @@ function printMessageInfo($aMsg) {
                 $td_str .= '<a href="read_body.php?mailbox='.$urlMailbox
                         .  '&amp;passed_id='. $iId
                         .  '&amp;startMessage='.$start_msg.$searchstr.'"';
+
+                // don't highlight the row or check the checkbox 
+                // when clicking subject link (when fancy highlighting is on)
+                //
+                // parentNode property is DOM Level 1
+                //
+                if ($javascript_on && $fancy_index_highlite)
+                    $td_str .= ' onmousedown="row_click(\'msg[' . $t . ']\'); setPointer(this.' . (empty($bold) ? '' : 'parentNode.') . 'parentNode.parentNode, ' . $t . ', \'click\', \'' . $hlt_color . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');"';
+
                 $td_str .= ' ' .concat_hook_function('subject_link', array($start_msg, $searchstr));
                 if ($subject != $sSubject) {
                     $title = get_html_translation_table(HTML_SPECIALCHARS);
@@ -1489,9 +1518,18 @@ function ShowSortButton($aMailbox, $Down, $Up ) {
  * @param array $aMailbox
  */
 function get_selectall_link($aMailbox) {
-    global $checkall, $javascript_on;
+    global $checkall, $javascript_on, $fancy_index_highlite, $color;
     global $PHP_SELF;
 
+    // set this to an empty string to turn off extra 
+    // highlighting of checked rows
+    //
+    //$clickedColor = '';
+    if (!empty($color[16]))
+       $clickedColor = $color[16];
+    else
+       $clickedColor = $color[2];
+
     $result = '';
     if ($javascript_on) {
         $safe_name = preg_replace("/[^0-9A-Za-z_]/", '_', $aMailbox['NAME']);
@@ -1499,12 +1537,14 @@ function get_selectall_link($aMailbox) {
         $form_name = "FormMsgs" . $safe_name;
         $result = '<script language="JavaScript" type="text/javascript">'
                 . "\n<!-- \n"
+                . "var orig_row_colors = new Array();\n"
                 . "function " . $func_name . "() {\n"
                 . "  for (var i = 0; i < document." . $form_name . ".elements.length; i++) {\n"
                 . "    if(document." . $form_name . ".elements[i].type == 'checkbox' && "
                 . "       document." . $form_name . ".elements[i].name.substring(0,3) == 'msg'){\n"
                 . "      document." . $form_name . ".elements[i].checked = "
                 . "        !(document." . $form_name . ".elements[i].checked);\n"
+                . ($fancy_index_highlite ? "      setPointer(document." . $form_name . ".elements[i].parentNode.parentNode, document." . $form_name . ".elements[i].name.substring(4, document." . $form_name . ".elements[i].name.length - 1), 'click', orig_row_colors[document." . $form_name . ".elements[i].name.substring(4, document." . $form_name . ".elements[i].name.length - 1)], orig_row_colors[document." . $form_name . ".elements[i].name.substring(4, document." . $form_name . ".elements[i].name.length - 1)], '" . $clickedColor . "');\n" : '')
                 . "    }\n"
                 . "  }\n"
                 . "}\n"