From e5686f4a011ea0110bf49ae1d56aa749c75ffc76 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 12 Sep 2008 08:13:13 -0400
Subject: [PATCH] - Added vertical splitter for folders list resizing - Added possibility to view all headers in message view - Fixed splitter drag/resize on Opera (#1485170) - debug console css fixes for IE

---
 skins/default/common.css                  |    8 
 CHANGELOG                                 |    6 
 program/js/common.js                      |   26 +-
 skins/default/mail.css                    |  127 +++++++++--
 skins/default/templates/message.html      |   10 +
 program/steps/mail/headers.inc            |   39 +++
 program/localization/en_GB/labels.inc     |    2 
 skins/default/splitter.js                 |  112 +++++++----
 skins/default/templates/mail.html         |   49 +++-
 skins/default/images/icons/down_small.gif |    0 
 program/include/rcube_imap.php            |   17 +
 skins/default/images/icons/up_small.gif   |    0 
 program/steps/mail/func.inc               |   10 
 program/localization/en_US/labels.inc     |    2 
 skins/default/templates/addressbook.html  |   15 +
 program/include/rcube_template.php        |    4 
 program/js/app.js                         |   58 +++++
 skins/default/addresses.css               |   87 ++++---
 18 files changed, 423 insertions(+), 149 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 2b86f3d..a5b68a7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,12 @@
 CHANGELOG RoundCube Webmail
 ---------------------------
 
+2008/09/12 (alec)
+----------
+- Added vertical splitter for folders list resizing
+- Added possibility to view all headers in message view
+- Fixed splitter drag/resize on Opera (#1485170)
+
 2008/09/12 (thomasb)
 ----------
 - Refactor drag & drop functionality. Don't rely on browser events anymore (#1484453)
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 8a7ad2c..1b5ec16 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -1371,6 +1371,23 @@
 
     return $body;    
     }
+
+
+  /**
+   * Returns the message headers as string
+   *
+   * @param int  Message UID
+   * @return string Message headers string
+   */
+  function &get_raw_headers($uid)
+    {
+    if (!($msg_id = $this->_uid2id($uid)))
+      return FALSE;
+
+    $headers = iil_C_FetchPartHeader($this->conn, $this->mailbox, $msg_id, NULL);
+
+    return $headers;    
+    }
     
 
   /**
diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index 9f94194..1b61770 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -320,9 +320,9 @@
 
         // add debug console
         if ($this->config['debug_level'] & 8) {
-            $this->add_footer('<div style="position:absolute;top:5px;left:5px;width:400px;padding:0.2em;background:white;opacity:0.8;z-index:9000">
+            $this->add_footer('<div style="position:absolute;top:5px;left:5px;width:405px;padding:2px;background:white;opacity:0.8;filter:alpha(opacity=80);z-index:9000">
                 <a href="#toggle" onclick="con=document.getElementById(\'dbgconsole\');con.style.display=(con.style.display==\'none\'?\'block\':\'none\');return false">console</a>
-                <form action="/" name="debugform"><textarea name="console" id="dbgconsole" rows="20" cols="40" wrap="off" style="display:none;width:400px;border:none;font-size:x-small"></textarea></form></div>'
+                <form action="/" name="debugform" style="display:inline"><textarea name="console" id="dbgconsole" rows="20" cols="40" wrap="off" style="display:none;width:400px;border:none;font-size:x-small"></textarea></form></div>'
             );
         }
         $output = $this->parse_with_globals($output);
diff --git a/program/js/app.js b/program/js/app.js
index 36072e3..b724287 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -159,7 +159,7 @@
         
         if (this.env.action=='show' || this.env.action=='preview')
           {
-          this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'mark', 'viewsource', 'print', 'load-attachment', true);
+          this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'mark', 'viewsource', 'print', 'load-attachment', 'load-headers', true);
           if (this.env.next_uid)
             {
             this.enable_command('nextmessage', true);
@@ -510,7 +510,6 @@
         return false;
      }
 
-
     // process command
     switch (command)
       {
@@ -551,6 +550,11 @@
           this.list_contacts(props);
           this.enable_command('add', (this.env.address_sources && !this.env.address_sources[props].readonly));
           }
+        break;
+
+
+      case 'load-headers':
+        this.load_headers(obj);
         break;
 
 
@@ -3654,6 +3658,54 @@
     }
 
 
+  // display fetched raw headers
+  this.set_headers = function(content)
+    {
+    if (this.gui_objects.all_headers_row && this.gui_objects.all_headers_box && content)
+      {
+      var box = this.gui_objects.all_headers_box;
+      box.innerHTML = content;
+      box.style.display = 'block';
+
+      if (this.env.framed && parent.rcmail)
+	parent.rcmail.set_busy(false);
+      else
+        this.set_busy(false);
+      }
+    };
+
+  // display all-headers row and fetch raw message headers
+  this.load_headers = function(elem)
+    {
+    if (!this.gui_objects.all_headers_row || !this.gui_objects.all_headers_box || !this.env.uid)
+      return;
+    
+    this.set_classname(elem, 'show-headers', false);
+    this.set_classname(elem, 'hide-headers', true);
+    this.gui_objects.all_headers_row.style.display = bw.ie ? 'block' : 'table-row';
+    elem.onclick = function() { rcmail.hide_headers(elem); }
+
+    // fetch headers only once
+    if (!this.gui_objects.all_headers_box.innerHTML)
+      {
+      this.set_busy(true, 'loading');
+      this.http_post('headers', '_uid='+this.env.uid);
+      }
+    }
+
+
+  // hide all-headers row
+  this.hide_headers = function(elem)
+    {
+    if (!this.gui_objects.all_headers_row || !this.gui_objects.all_headers_box)
+      return;
+
+    this.set_classname(elem, 'hide-headers', false);
+    this.set_classname(elem, 'show-headers', true);
+    this.gui_objects.all_headers_row.style.display = 'none';
+    elem.onclick = function() { rcmail.load_headers(elem); }
+    }
+
 
   /********************************************************/
   /*********        remote request methods        *********/
@@ -3760,7 +3812,7 @@
     }
 
     if (request_obj.__lock)
-        this.set_busy(false);
+      this.set_busy(false);
 
     console.log(request_obj.get_text());
 
diff --git a/program/js/common.js b/program/js/common.js
index 209ce10..063657f 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -253,23 +253,28 @@
     var obj;
 
     obj = document.createElement('DIV');
+
     with(obj)
       {
       id = this.name;
       with(style)
         {
-        position = 'absolute';
+	position = 'absolute';
         visibility = (vis) ? (vis==2) ? 'inherit' : 'visible' : 'hidden';
         left = l+'px';
         top = t+'px';
-        if(w) width = w+'px';
-        if(h) height = h+'px';
+        if (w)
+	  width = w.toString().match(/\%$/) ? w : w+'px';
+        if (h)
+	  height = h.toString().match(/\%$/) ? h : h+'px';
         if(z) zIndex = z;
-        }
+	}
       }
-      
-    if(parent) parent.appendChild(obj);
-    else document.body.appendChild(obj);
+
+    if (parent)
+      parent.appendChild(obj);
+    else
+      document.body.appendChild(obj);
 
     this.elm = obj;
     };
@@ -496,7 +501,7 @@
 
 
 // return the absolute position of an object within the document
-function rcube_get_object_pos(obj)
+function rcube_get_object_pos(obj, relative)
   {
   if(typeof(obj)=='string')
     obj = rcube_find_object(obj);
@@ -506,7 +511,7 @@
   var iX = (bw.layers) ? obj.x : obj.offsetLeft;
   var iY = (bw.layers) ? obj.y : obj.offsetTop;
 
-  if(bw.ie || bw.mz)
+  if(!relative && (bw.ie || bw.mz))
     {
     var elm = obj.offsetParent;
     while(elm && elm!=null)
@@ -598,8 +603,9 @@
   this.log = function(msg)
   {
     box = rcube_find_object('console');
+
     if (box)
-      if (msg[msg.length-1]=='\n')
+      if (msg.charAt(msg.length-1)=='\n')
         box.value += msg+'--------------------------------------\n';
       else
         box.value += msg+'\n--------------------------------------\n';
diff --git a/program/localization/en_GB/labels.inc b/program/localization/en_GB/labels.inc
index 75ffea5..82d06b0 100644
--- a/program/localization/en_GB/labels.inc
+++ b/program/localization/en_GB/labels.inc
@@ -128,7 +128,7 @@
 $labels['resetsearch'] = 'Reset search';
 $labels['compose'] = 'Compose a message';
 $labels['savemessage'] = 'Save this draft';
-$labels['sendmessage'] = 'Send the message now';
+$labels['sendmessage'] = 'Send now';
 $labels['addattachment'] = 'Attach a file';
 $labels['charset'] = 'Charset';
 $labels['editortype'] = 'Editor type';
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 565cdc4..6b503ff 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -164,7 +164,7 @@
 // message compose
 $labels['compose']        = 'Compose a message';
 $labels['savemessage']    = 'Save this draft';
-$labels['sendmessage']    = 'Send the message now';
+$labels['sendmessage']    = 'Send now';
 $labels['addattachment']  = 'Attach a file';
 $labels['charset']        = 'Charset';
 $labels['editortype']     = 'Editor type';
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 54abb24..7de78a1 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -740,7 +740,7 @@
 
   // show these headers
   $standard_headers = array('subject', 'from', 'organization', 'to', 'cc', 'bcc', 'replyto', 'date');
-  
+
   foreach ($standard_headers as $hkey)
     {
     if (!$headers[$hkey])
@@ -771,6 +771,14 @@
     $header_count++;
     }
 
+  // all headers division
+  $out .= "\n".'<tr><td colspan="2" class="more-headers show-headers"
+	onclick="return '.JS_OBJECT_NAME.'.command(\'load-headers\', \'\', this)"></td></tr>';
+  $out .= "\n".'<tr id="all-headers"><td colspan="2" class="all"><div id="headers-source"></div></td></tr>';
+
+  $OUTPUT->add_gui_object('all_headers_row', 'all-headers');
+  $OUTPUT->add_gui_object('all_headers_box', 'headers-source');
+
   $out .= "\n</table>\n\n";
 
   return $header_count ? $out : '';  
diff --git a/program/steps/mail/headers.inc b/program/steps/mail/headers.inc
new file mode 100644
index 0000000..653fb96
--- /dev/null
+++ b/program/steps/mail/headers.inc
@@ -0,0 +1,39 @@
+<?php
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/mail/headers.inc                                        |
+ |                                                                       |
+ | This file is part of the RoundCube Webmail client                     |
+ | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
+ | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ | PURPOSE:                                                              |
+ |   Fetch message headers in raw format for display                     |
+ |                                                                       |
+ +-----------------------------------------------------------------------+
+ | Author: Aleksander Machniak <alec@alec.pl>                            |
+ +-----------------------------------------------------------------------+
+
+ $Id: mark.inc 1580 2008-06-30 09:36:18Z alec $
+
+*/
+
+if ($uid = get_input_value('_uid', RCUBE_INPUT_POST))
+{
+  $source = $IMAP->get_raw_headers($uid);
+
+  if ($source)
+    {
+    $source = htmlspecialchars(trim($source));
+    $source = preg_replace('/\t/', '&nbsp;&nbsp;&nbsp;&nbsp;', $source);
+    $source = preg_replace('/^([a-z0-9_:-]+)/im', '<font class="bold">'.'\1'.'</font>', $source);
+    $source = preg_replace('/\r?\n/', '<br />', $source);
+    
+    $OUTPUT->command('set_headers', $source);
+    $OUTPUT->send();
+    }
+}
+  
+exit;
+
+?>
diff --git a/skins/default/addresses.css b/skins/default/addresses.css
index 8ae2987..051b0a0 100644
--- a/skins/default/addresses.css
+++ b/skins/default/addresses.css
@@ -1,6 +1,5 @@
 /***** RoundCube|Mail address book task styles *****/
 
-
 #abooktoolbar
 {
   position: absolute;
@@ -18,7 +17,7 @@
 {
   position: absolute;
   bottom: 16px;
-  left: 185px;
+  left: 190px;
   width: 240px;
   height: 20px;
   text-align: left;
@@ -30,38 +29,63 @@
   color: #333333;
 }
 
-#directorylist, #addresslist, #importbox
+#mainscreen
+{
+  position: absolute;
+  top: 85px;
+  right: 20px;
+  bottom: 40px;
+  left: 200px;
+  /* css hack for IE */
+  width: expression((parseInt(document.documentElement.clientWidth)-220)+'px');
+  height: expression((parseInt(document.documentElement.clientHeight)-125)+'px');
+}
+
+#directorylist
 {
   position: absolute;
   top: 85px;
   bottom: 40px;
+  left: 20px;
+  width: 170px;
   border: 1px solid #999999;
   background-color: #F9F9F9;
+  overflow: hidden;
+  /* css hack for IE */
+  height: expression((parseInt(document.documentElement.clientHeight)-125)+'px');  
+}
+
+#addresslist
+{
+  position: absolute;
+  top: 0px;
+  bottom: 0px;
+  border: 1px solid #999999;
+  background-color: #F9F9F9;
+  overflow: auto;
+  /* css hack for IE */
+  height: expression(parseInt(this.parentNode.offsetHeight)+'px');
+}
+
+#importbox
+{
+  position: absolute;
+  top: 85px;
+  bottom: 40px;
+  left: 20px;
+  right: 20px;
+  border: 1px solid #999999;
+  background-color: #F9F9F9;
+  padding-bottom: 4ex;
   overflow: auto;
   /* css hack for IE */
   height: expression((parseInt(document.documentElement.clientHeight)-135)+'px');  
 }
 
-#directorylist
-{
-  left: 20px;
-  width: 170px;
-  overflow: hidden;
-}
-
 #addresslist
 {
-  left: 200px;
+  left: 0px;
   width: 340px;
-}
-
-#importbox
-{
-  left: 20px;
-  right: 40px;
-  height: auto;
-  bottom: auto;
-  padding-bottom: 4ex;
 }
 
 #importbox a
@@ -129,29 +153,16 @@
 #contacts-box
 {
   position: absolute;
-  top: 85px;
+  top: 0px;
   left: 555px;
-  right: 20px;
-  bottom: 40px;
+  right: 0px;
+  bottom: 0px;
   border: 1px solid #999999;
   overflow: hidden;
   /* css hack for IE */
-  width: expression((parseInt(document.documentElement.clientWidth)-45-document.getElementById('addresslist').offsetLeft-document.getElementById('addresslist').offsetWidth)+'px');
-  height: expression((parseInt(document.documentElement.clientHeight)-135)+'px');
+  height: expression(parseInt(this.parentNode.offsetHeight)+'px');
+  width: expression((parseInt(this.parentNode.offsetWidth)-555)+'px');
 }
-
-
-#addressviewsplitter
-{
-  background-position: 4px center;
-}
-
-#addressviewsplitter .splitterLine
-{
-  margin-left: 3px;
-  width: 6px;
-}
-
 
 body.iframe,
 #contact-frame
diff --git a/skins/default/common.css b/skins/default/common.css
index c9a641f..a5b73b0 100644
--- a/skins/default/common.css
+++ b/skins/default/common.css
@@ -194,6 +194,8 @@
   right: 200px;
   z-index: 5000;
   opacity: 0.85;
+  /* IE */
+  filter: alpha(opacity=85);
 }
 
 #message div
@@ -237,8 +239,10 @@
 
 .splitter
 {
+  user-select: none;
+  -moz-user-select: none;
+  -khtml-user-select: none;
   position: absolute;
-  padding: 2px;
   background: url(images/dimple.png) center no-repeat;
 }
 
@@ -251,7 +255,7 @@
 .splitter-v
 {
   cursor: e-resize;
-  background-position: 1px center;
+  background-position: 2px center;
 }
 
 .boxtitle
diff --git a/skins/default/images/icons/down_small.gif b/skins/default/images/icons/down_small.gif
new file mode 100644
index 0000000..f865893
--- /dev/null
+++ b/skins/default/images/icons/down_small.gif
Binary files differ
diff --git a/skins/default/images/icons/up_small.gif b/skins/default/images/icons/up_small.gif
new file mode 100644
index 0000000..40deb89
--- /dev/null
+++ b/skins/default/images/icons/up_small.gif
Binary files differ
diff --git a/skins/default/mail.css b/skins/default/mail.css
index 7807ca2..7f76ed8 100644
--- a/skins/default/mail.css
+++ b/skins/default/mail.css
@@ -146,6 +146,30 @@
   color: #333333;
 }
 
+#mainscreen 
+{
+  position: absolute;
+  top: 85px;
+  right: 20px;
+  bottom: 40px;
+  left: 20px;
+  /* css hack for IE */
+  width: expression((parseInt(document.documentElement.clientWidth)-40)+'px');
+  height: expression((parseInt(document.documentElement.clientHeight)-125)+'px');
+}
+
+#mailrightcontainer
+{
+  position: absolute;
+  top: 0px;
+  left: 170px;
+  bottom: 0px;
+  right: 0px;
+  /* css hack for IE */
+  width: expression((parseInt(this.parentNode.offsetWidth)-170)+'px');
+  height: expression(parseInt(this.parentNode.offsetHeight)+'px');
+}
+	  
 #messagepartcontainer
 {
   position: absolute;
@@ -161,42 +185,37 @@
 #mailcontframe
 {
   position: absolute;
-  top: 85px;
-  left: 200px;
-  right: 20px;
-  bottom: 40px;
+  width: 100%;
+  top: 0px;
+  bottom: 0px;
   border: 1px solid #999999;
   background-color: #F9F9F9;
   overflow: auto;
   /* css hack for IE */
-  width: expression((parseInt(document.documentElement.clientWidth)-220)+'px');
-  height: expression((parseInt(document.documentElement.clientHeight)-125)+'px');
+  height: expression(parseInt(this.parentNode.offsetHeight)+'px');
 }
 
 #mailpreviewframe
 {
   position: absolute;
-  top: 305px;
-  left: 200px;
-  right: 20px;
-  bottom: 40px;
+  width: 100%;
+  top: 205px;
+  bottom: 0px;
   border: 1px solid #999999;
   background-color: #F9F9F9;
   /* css hack for IE */
-  width: expression((parseInt(document.documentElement.clientWidth)-220)+'px');
-  height: expression((parseInt(document.documentElement.clientHeight)-135-document.getElementById('mailcontframe').offsetHeight)+'px');
+  height: expression((parseInt(this.parentNode.offsetHeight)-205)+'px');
 }
 
 #messagecontframe
 {
-  position: absolute;
+  position: relative;
   top: 0px;
   left: 0px;
   right: 0px;
   bottom: 0px;
-  /* css hack for IE */
-  width: expression((parseInt(document.documentElement.clientWidth)-220)+'px');
-  height: expression((parseInt(document.documentElement.clientHeight)-135-document.getElementById('mailcontframe').offsetHeight)+'px');
+  width: 100%;
+  height: 100%;
 }
 
 #messagepartframe
@@ -253,15 +272,15 @@
 #mailboxlist-container
 {
   position: absolute;
-  top: 85px;
-  left: 20px;
-  width: 170px;
-  bottom: 40px;
+  top: 0px;
+  left: 0px;
+  width: 160px;
+  bottom: 0px;
   border: 1px solid #999;
   background-color: #F9F9F9;
   overflow: auto;
   /* css hack for IE */
-  height: expression((parseInt(document.documentElement.clientHeight)-125)+'px');
+  height: expression(parseInt(this.parentNode.offsetHeight)+'px');
 }
 
 #mailboxlist
@@ -599,15 +618,14 @@
 #messageframe
 {
   position: absolute;
-  top: 85px;
-  left: 200px;
-  right: 20px;
-  bottom: 40px;
+  top: 0px;
+  left: 0px;
+  right: 0px;
+  bottom: 0px;
   border: 1px solid #999;
   background-color: #FFF;
   overflow: auto;
   /* css hack for IE */
-  /* margin-bottom: 10px; */
   width: expression((parseInt(document.documentElement.clientWidth)-220)+'px');
   height: expression((parseInt(document.documentElement.clientHeight)-125)+'px');
 }
@@ -641,7 +659,7 @@
 
 table.headers-table td.header-title
 {
-  width: 80px;
+  width: 85px;
   color: #666666;
   font-weight: bold;
   text-align: right;
@@ -651,8 +669,18 @@
 
 table.headers-table tr td.subject
 {
-  width: 95%;
+  width: 90%;
   font-weight: bold;
+}
+
+table.headers-table tr td.all
+{
+  width: 100%;
+  color: #666666;
+  text-align: left;
+  padding-right: 10px;
+  vertical-align: center;
+  text-align: center;
 }
 
 #attachment-list
@@ -949,3 +977,46 @@
 {
   margin-top: 4px;
 }
+
+.more-headers
+{
+  cursor: pointer;
+  width: 100%;
+  height: 6px;
+}
+
+.show-headers
+{
+  background: url(images/icons/down_small.gif) no-repeat center;
+}
+
+.hide-headers
+{
+  background: url(images/icons/up_small.gif) no-repeat center;
+}
+
+#all-headers
+{
+  height: 150px;
+  display: none;
+}
+
+#headers-source
+{
+  margin: 0 5px;
+  width: 100%;
+  height: 145px;
+  background: white;
+  overflow: auto;
+  font-size: 11px;
+  white-space: nowrap;
+  border: 1px solid #999999;
+  display: none;
+  text-align: left;
+  color: #666666;
+}
+
+font.bold
+{
+  font-weight: bold;
+}
diff --git a/skins/default/splitter.js b/skins/default/splitter.js
index 31862ce..4391ae9 100644
--- a/skins/default/splitter.js
+++ b/skins/default/splitter.js
@@ -11,40 +11,48 @@
   this.id = attrib.id ? attrib.id : this.p1id + '_' + this.p2id + '_splitter';
   this.orientation = attrib.orientation;
   this.horizontal = (this.orientation == 'horizontal' || this.orientation == 'h');
-  this.offset_1 = bw.ie ? 0 : -1;
-  this.offset_2 = bw.ie ? -2 : 1;
-  this.pos = 0;
+  this.offset = bw.ie6 ? 2 : 0;
+  this.pos = attrib.start ? attrib.start * 1 : 0;
+  this.relative = attrib.relative ? true : false;
+  this.drag_active = false;
 
   this.init = function()
     {
     this.p1 = document.getElementById(this.p1id);
     this.p2 = document.getElementById(this.p2id);
-    
+
     // create and position the handle for this splitter
-    this.p1pos = rcube_get_object_pos(this.p1);
-    this.p2pos = rcube_get_object_pos(this.p2);
-    var top = this.p1pos.y + this.p1.offsetHeight;
-    var height = this.p2pos.y - this.p1pos.y - this.p1.offsetHeight;
-    var left = this.p1pos.x + this.p1.offsetWidth;
-    var width = this.p2pos.x - this.p1pos.x - this.p1.offsetWidth;
+    this.p1pos = rcube_get_object_pos(this.p1, this.relative);
+    this.p2pos = rcube_get_object_pos(this.p2, this.relative);
     
     if (this.horizontal)
-      this.layer = new rcube_layer(this.id, {x: this.p1pos.x, y: top, height: height, width: this.p1.offsetWidth, vis: 1});
+      {
+      var top = this.p1pos.y + this.p1.offsetHeight;
+      this.layer = new rcube_layer(this.id, {x: 0, y: top, height: 10, 
+    	    width: '100%', vis: 1, parent: this.p1.parentNode});
+      }
     else
-      this.layer = new rcube_layer(this.id, {x: left, y: this.p1pos.y, width: width, height: this.p1.offsetHeight, vis: 1});
+      {
+      var left = this.p1pos.x + this.p1.offsetWidth;
+      this.layer = new rcube_layer(this.id, {x: left, y: 0, width: 10, 
+    	    height: '100%', vis: 1,  parent: this.p1.parentNode});
+      }
 
     this.elm = this.layer.elm;
     this.elm.className = 'splitter '+(this.horizontal ? 'splitter-h' : 'splitter-v');
+    this.elm.unselectable = 'on';
 
     // add the mouse event listeners
     rcube_event.add_listener({element: this.elm, event:'mousedown', object:this, method:'onDragStart'});
-    rcube_event.add_listener({element: window, event:'resize', object:this, method:'onResize'});
+    if (bw.ie)
+      rcube_event.add_listener({element: window, event:'resize', object:this, method:'onResize'});
 
     // read saved position from cookie
     var cookie = bw.get_cookie(this.id);
     if (cookie)
       {
       var param = cookie.split(':');
+
       for (var i=0, p; i<param.length; i++)
         {
         p = param[i].split('=');
@@ -52,6 +60,11 @@
         }
 
       this.resize();
+      }
+    else if (this.pos)
+      {
+      this.resize();
+      this.set_cookie();
       }
     };
 
@@ -61,17 +74,22 @@
    */
   this.resize = function()
     {
-     if (this.horizontal)
+    if (this.horizontal)
       {
-      this.p1.style.height = Math.floor(this.pos - this.p1pos.y - this.layer.height / 2 + this.offset_1) + 'px';
-      this.p2.style.top = Math.ceil(this.pos + (this.layer.height / 2 + this.offset_2)) + 'px';
-      this.layer.move(this.layer.x, Math.round(this.pos - this.layer.height / 2 + 1));
+      var lh = this.layer.height - this.offset * 2;
+      this.p1.style.height = Math.floor(this.pos - this.p1pos.y - lh / 2) + 'px';
+      this.p2.style.top = Math.ceil(this.pos + lh / 2) + 'px';
+      this.layer.move(this.layer.x, Math.round(this.pos - lh / 2 + 1));	     
+      if (bw.ie)
+        this.p2.style.height = (parseInt(this.p2.parentNode.offsetHeight) - parseInt(this.p2.style.top))+'px';
       }
     else
       {
-      this.p1.style.width = Math.floor(this.pos - this.p1pos.x - this.layer.width / 2 + this.offset_1) + 'px';
-      this.p2.style.left = Math.ceil(this.pos + this.layer.width / 2 + this.offset_2) + 'px';
+      this.p1.style.width = Math.floor(this.pos - this.p1pos.x - this.layer.width / 2) + 'px';
+      this.p2.style.left = Math.ceil(this.pos + this.layer.width / 2) + 'px';
       this.layer.move(Math.round(this.pos - this.layer.width / 2 + 1), this.layer.y);
+      if (bw.ie)
+        this.p2.style.width = (parseInt(this.p2.parentNode.offsetWidth) - parseInt(this.p2.style.left))+'px';
       }
     };
 
@@ -80,9 +98,10 @@
    */
   this.onDragStart = function(e)
     {
-    this.p1pos = rcube_get_object_pos(this.p1);
-    this.p2pos = rcube_get_object_pos(this.p2);
-
+    this.p1pos = rcube_get_object_pos(this.p1, this.relative);
+    this.p2pos = rcube_get_object_pos(this.p2, this.relative);
+    this.drag_active = true;
+    
     // start listening to mousemove events
     rcube_event.add_listener({element:document, event:'mousemove', object:this, method:'onDrag'});
     rcube_event.add_listener({element:document, event:'mouseup', object:this, method:'onDragStop'});
@@ -106,6 +125,7 @@
         var s = this;
         var id = iframes[n].id;
         this.iframe_events[n] = function(e){ e._rc_pos_offset = rcube_get_object_pos(document.getElementById(id)); return s.onDrag(e); }
+
         if (iframedoc.addEventListener)
           iframedoc.addEventListener('mousemove', this.iframe_events[n], false);
         else if (iframes[n].attachEvent)
@@ -124,10 +144,20 @@
   this.onDrag = function(e)
     {
     var pos = rcube_event.get_mouse_pos(e);
+
+    if (!this.drag_active) return false;
+
     if (e._rc_pos_offset)
       {
       pos.x += e._rc_pos_offset.x;
       pos.y += e._rc_pos_offset.y;
+      }
+
+    if (this.relative)
+      {
+      var parent = rcube_get_object_pos(this.p1.parentNode);
+      pos.x -= parent.x;
+      pos.y -= parent.y;
       }
 
     if (this.horizontal)
@@ -147,8 +177,8 @@
         }
       }
 
-    this.p1pos = rcube_get_object_pos(this.p1);
-    this.p2pos = rcube_get_object_pos(this.p2);
+    this.p1pos = rcube_get_object_pos(this.p1, this.relative);
+    this.p2pos = rcube_get_object_pos(this.p2, this.relative);
     return false;
     };
 
@@ -160,6 +190,8 @@
     // cancel the listening for drag events
     rcube_event.remove_listener({element:document, event:'mousemove', object:this, method:'onDrag'});
     rcube_event.remove_listener({element:document, event:'mouseup', object:this, method:'onDragStop'});
+    this.drag_active = false;
+
     var iframes = document.getElementsByTagName('IFRAME');
 
     for (var n in iframes)
@@ -176,39 +208,37 @@
         if (this.iframe_events[n]) {
           if (iframedoc.removeEventListener)
             iframedoc.removeEventListener('mousemove', this.iframe_events[n], false);
-          else if (iframedoc.detachEvent)
+	  else if (iframedoc.detachEvent)
             iframedoc.detachEvent('onmousemove', this.iframe_events[n]);
           else
             iframedoc['onmousemove'] = null;
-        }
+          }
 
         rcube_event.remove_listener({element:iframedoc, event:'mouseup', object:this, method:'onDragStop'});
         }
       }
 
-    // save state in cookie
-    var exp = new Date();
-    exp.setYear(exp.getFullYear() + 1);
-    bw.set_cookie(this.id, 'pos='+this.pos, exp);
-
-    // Firefox 3 will initiate its built in drag-and-drop on the divider 
-    // widget if it already has focus when a second drag event starts 
-    this.p1.focus();
-    this.p1.blur();
+    this.set_cookie();
 
     return bw.safari ? true : rcube_event.cancel(e);
     };
-
   /**
    * Handler for window resize events
    */
   this.onResize = function(e)
     {
-    this.p1pos = rcube_get_object_pos(this.p1);
-    this.p2pos = rcube_get_object_pos(this.p2);
-    var height = this.horizontal ? this.p2pos.y - this.p1pos.y - this.p1.offsetHeight : this.p1.offsetHeight;
-    var width = this.horizontal ? this.p1.offsetWidth : this.p2pos.x - this.p1pos.x - this.p1.offsetWidth;
-    this.layer.resize(width, height);
+    if (this.horizontal)
+      this.p2.style.height = (parseInt(this.p2.parentNode.offsetHeight) - parseInt(this.p2.style.top))+'px';
+    else
+      this.p2.style.width = (parseInt(this.p2.parentNode.offsetWidth) - parseInt(this.p2.style.left))+'px';
     };
 
+  this.set_cookie = function()
+    {
+    // save state in cookie
+    var exp = new Date();
+    exp.setYear(exp.getFullYear() + 1);
+    bw.set_cookie(this.id, 'pos='+this.pos, exp);
+    }
+
   }  // end class rcube_splitter
diff --git a/skins/default/templates/addressbook.html b/skins/default/templates/addressbook.html
index 3f8e460..df5f20a 100644
--- a/skins/default/templates/addressbook.html
+++ b/skins/default/templates/addressbook.html
@@ -24,26 +24,31 @@
 </div>
 
 <roundcube:if condition="config:ldap_public" />
+
 <div id="directorylist">
 <div id="groups-title"><roundcube:label name="groups" /></div>
 <roundcube:object name="directorylist" id="directories-list" />
 </div>
 
 <roundcube:else />
+
 <style type="text/css">
-#addresslist { left:20px; width:440px }
-#contacts-box { left:475px }
-#abookcountbar { left:20px }
+#abookcountbar { left: 20px;}
+#mainscreen { left:20px; /* IE hack */ width:expression((parseInt(document.documentElement.clientWidth)-40)+'px') }
+#addresslist { width:245px }
+#contacts-box { left:255px; /* IE hack */ width:expression((parseInt(mainscreen.offsetWidth)-255)+'px') }
 </style>
 
 <roundcube:endif />
+
+<div id="mainscreen">
 
 <div id="addresslist">
 <roundcube:object name="addresslist" id="contacts-table" class="records-table" cellspacing="0" summary="Contacts list" />
 </div>
 
 <script type="text/javascript">
-  var addrviewsplit = new rcube_splitter({id:'addressviewsplitter', p1: 'addresslist', p2: 'contacts-box', orientation: 'v'});
+  var addrviewsplit = new rcube_splitter({id:'addressviewsplitter', p1: 'addresslist', p2: 'contacts-box', orientation: 'v', relative: true, start: 250});
   rcmail.add_onload('addrviewsplit.init()');
 </script>
 
@@ -51,6 +56,8 @@
 <roundcube:object name="addressframe" id="contact-frame" width="100%" height="100%" frameborder="0" src="/watermark.html" />
 </div>
 
+</div>
+
 <div id="abookcountbar">
 <roundcube:button command="firstpage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstpage" />
 <roundcube:button command="previouspage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previouspage" />
diff --git a/skins/default/templates/mail.html b/skins/default/templates/mail.html
index 7b6037b..3d2068d 100644
--- a/skins/default/templates/mail.html
+++ b/skins/default/templates/mail.html
@@ -47,17 +47,19 @@
 <roundcube:include file="/includes/taskbar.html" />
 <roundcube:include file="/includes/header.html" />
 
+<div id="mainscreen">
+
 <div id="mailboxlist-container">
 <h3 id="mailboxlist-header"><roundcube:label name="mailboxlist" /></h3>
 <roundcube:object name="mailboxlist" id="mailboxlist" maxlength="16" />
 </div>
 
-<div id="mailboxcontrols">
-<roundcube:label name="folder" />:&nbsp;
-<roundcube:button command="expunge" label="compact" classAct="active" />&nbsp;
-<roundcube:button command="purge" label="empty" classAct="active" />&nbsp;
-</div>
+<script type="text/javascript">
+  var mailviewsplitv = new rcube_splitter({id:'mailviewsplitterv', p1: 'mailboxlist-container', p2: 'mailrightcontainer', orientation: 'v', relative: true, start: 165});
+  rcmail.add_onload('mailviewsplitv.init()');
+</script>
 
+<div id="mailrightcontainer">
 
 <div id="mailcontframe">
 <roundcube:object name="messages"
@@ -74,21 +76,32 @@
 </div>
 
 <roundcube:if condition="config:preview_pane == true" />
+
 <script type="text/javascript">
-  var mailviewsplit = new rcube_splitter({id:'mailviewsplitter', p1: 'mailcontframe', p2: 'mailpreviewframe', orientation: 'h'});
+  var mailviewsplit = new rcube_splitter({id:'mailviewsplitter', p1: 'mailcontframe', p2: 'mailpreviewframe', orientation: 'h', relative: true, start: 200});
   rcmail.add_onload('mailviewsplit.init()');
 </script>
+
 <div id="mailpreviewframe">
 <roundcube:object name="messagecontentframe" id="messagecontframe" width="100%" height="100%" frameborder="0" src="/watermark.html" />
 </div>
 
 <style type="text/css">
-#mailcontframe {
-  bottom: auto;
-  height: 208px;
-}
+#mailcontframe { height: 195px; }
 </style>
+
 <roundcube:endif />
+
+</div>
+
+</div>
+
+<div id="mailboxcontrols">
+<roundcube:label name="folder" />:&nbsp;
+<roundcube:button command="expunge" label="compact" classAct="active" />&nbsp;
+<roundcube:button command="purge" label="empty" classAct="active" />&nbsp;
+</div>
+
 
 <div id="listcontrols">
 <roundcube:label name="select" />:&nbsp;
@@ -98,6 +111,14 @@
 <roundcube:if condition="env:quota" />
 <roundcube:label name="quota" />: <roundcube:object name="quotaDisplay" display="image" width="120" id="quotadisplay" />
 <roundcube:endif />
+</div>
+
+<div id="messagecountbar">
+<roundcube:button command="firstpage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstmessages" />
+<roundcube:button command="previouspage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previousmessages" />
+&nbsp;<roundcube:object name="messageCountDisplay" />&nbsp;
+<roundcube:button command="nextpage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextmessages" />
+<roundcube:button command="lastpage" imageSel="/images/buttons/last_sel.png" imageAct="/images/buttons/last_act.png" imagePas="/images/buttons/last_pas.png" width="11" height="11" title="lastmessages" />
 </div>
 
 <div id="messagetoolbar">
@@ -122,14 +143,6 @@
 
 <div id="quicksearchbar">
 <roundcube:object name="searchform" type="search" results="5" id="quicksearchbox" /><roundcube:button command="reset-search" id="searchreset" image="/images/icons/reset.gif" title="resetsearch" />
-</div>
-
-<div id="messagecountbar">
-<roundcube:button command="firstpage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstmessages" />
-<roundcube:button command="previouspage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previousmessages" />
-&nbsp;<roundcube:object name="messageCountDisplay" />&nbsp;
-<roundcube:button command="nextpage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextmessages" />
-<roundcube:button command="lastpage" imageSel="/images/buttons/last_sel.png" imageAct="/images/buttons/last_act.png" imagePas="/images/buttons/last_pas.png" width="11" height="11" title="lastmessages" />
 </div>
 
 <script type="text/javascript">
diff --git a/skins/default/templates/message.html b/skins/default/templates/message.html
index dc8dab7..ccd23eb 100644
--- a/skins/default/templates/message.html
+++ b/skins/default/templates/message.html
@@ -4,6 +4,7 @@
 <title><roundcube:object name="pagetitle" /></title>
 <roundcube:include file="/includes/links.html" />
 <link rel="stylesheet" type="text/css" href="/mail.css" />
+<script type="text/javascript" src="/splitter.js"></script>
 </head>
 <body>
 
@@ -30,6 +31,8 @@
 <roundcube:object name="mailboxlist" type="select" noSelection="moveto" maxlength="25" onchange="rcmail.command('moveto', this.options[this.selectedIndex].value)" class="mboxlist" />
 </div>
 
+<div id="mainscreen">
+
 <div id="mailboxlist-container">
 <div id="mailboxlist-header"><roundcube:label name="mailboxlist" /></div>
 <roundcube:object name="mailboxlist" id="mailboxlist" maxlength="16" />
@@ -45,5 +48,12 @@
 
 </div>
 
+</div>
+
+<script type="text/javascript">
+    var mailviewsplitv = new rcube_splitter({id:'mailviewsplitterv', p1: 'mailboxlist-container', p2: 'messageframe', orientation: 'v', relative: true, start: 165});
+    rcmail.add_onload('mailviewsplitv.init()');
+</script>
+
 </body>
 </html>

--
Gitblit v1.9.1