Robin Elfrink wrote:

> 1. Internet Explorer has a problem with width and height. I tried to set
> the 'expression' css attributes from JavaScript but IE gave errors. Can
> anybody help me to do this from JavaScript:
> 
> width:
> expression((parseInt(document.documentElement.clientWidth)-240)+'px');
>   height:
> expression((parseInt(document.documentElement.clientHeight)-125)+'px');
> 
> [125 should be replaced with 125 plus mailcontframe.offsetHeight]

This is still a problem. Internet Explorer 7 does the right thing,
though. It may have something to do with top and bottom being set both.
Internet Explorer is bad, bad, bad.


> 2. Clicking on an attachment within the preview pane does nothing. I
> have not yet taken time to investigate this.

Fixed, the 'load-attachment' command had to be enabled.


> 3. I probably should scroll the preview pane to the top when inserting
> new content.

Fixed.


> 4. The selected message in the message list should be scrolled in to
> view. I think I saw something in the DOM docs about that.

Fixed.



Other changes:

- The preview option is user-configurable, instead of global.
- 'preview' hook moved to 'this.select_row' instead of 'single click',
so 'cursor key down' etc. work as well.
- The preview window is scrolled up if a different message is inserted.
- The selected row is scolled into viewable space after selection.


If somebody can help me fix the problem with positioning in Internet
Explorer, I will post the complete patch to the Trac system so whoever
has the powers can include it in SVN if wanted.


Robin
Index: program/include/main.inc
===================================================================
--- program/include/main.inc    (revision 335)
+++ program/include/main.inc    (working copy)
@@ -1170,6 +1170,7 @@
         'charsetselector' => 'rcmail_charset_selector',
         'searchform' => 'rcmail_search_form',
         'receiptcheckbox' => 'rcmail_receipt_checkbox',
+        'preview' => 'rcmail_message_preview',
         
         // ADDRESS BOOK
         'addresslist' => 'rcmail_contacts_list',
Index: program/localization/nl_NL/labels.inc
===================================================================
--- program/localization/nl_NL/labels.inc       (revision 335)
+++ program/localization/nl_NL/labels.inc       (working copy)
@@ -202,6 +202,7 @@
 $labels['pagesize']  = 'Rijen per pagina';
 $labels['signature'] = 'Onderschrift';
 $labels['dstactive']  = 'Zomertijd';
+$labels['preview'] = 'Voorbeeldvenster';
 
 $labels['folder']  = 'Map';
 $labels['folders']  = 'Mappen';
Index: program/localization/en_US/labels.inc
===================================================================
--- program/localization/en_US/labels.inc       (revision 335)
+++ program/localization/en_US/labels.inc       (working copy)
@@ -201,6 +201,7 @@
 $labels['pagesize']  = 'Rows per page';
 $labels['signature'] = 'Signature';
 $labels['dstactive']  = 'Daylight savings';
+$labels['preview'] = 'Preview message';
 
 $labels['folder']  = 'Folder';
 $labels['folders']  = 'Folders';
Index: program/js/app.js
===================================================================
--- program/js/app.js   (revision 335)
+++ program/js/app.js   (working copy)
@@ -126,7 +126,7 @@
           }
 
         // enable mail commands
-        this.enable_command('list', 'checkmail', 'compose', 'add-contact', 
'search', 'reset-search', true);
+        this.enable_command('list', 'checkmail', 'compose', 'add-contact', 
'search', 'reset-search', 'load-attachment', true);
         
         if (this.env.action=='show')
           {
@@ -758,6 +758,7 @@
           var input_pagesize = rcube_find_object('_pagesize');
           var input_name  = rcube_find_object('_name');
           var input_email = rcube_find_object('_email');
+          var input_preview = rcube_find_object('_preview');
 
           // user prefs
           if (input_pagesize && isNaN(input_pagesize.value))
@@ -1438,6 +1439,8 @@
 
     this.last_selected = id;
     this.set_classname(this.list_rows[id].obj, 'focused', true);        
+    if (this.env.preview)
+      this.show_preview(id);
   };
 
   this.shift_select = function(id, control) {
@@ -1502,6 +1505,31 @@
 
     return true;  
     };
+
+
+  // when user clicks on a row
+  this.show_preview = function(id, safe)
+    {
+    var add_url = '';
+    var target = window;
+    var contentframe = rcube_find_object('mailcontframe');
+    var previewpane = rcube_find_object('previewpane');
+
+    if (id && contentframe && previewpane)
+      {
+      rcmail.set_busy(true, 'loading');
+      if (previewpane.style.display=='none')
+        {
+        contentframe.style.height = (contentframe.offsetHeight/2) + 'px';
+        previewpane.style.top = 
(contentframe.offsetTop+contentframe.offsetHeight) + 'px';
+        previewpane.style.display = 'block';
+        var message = rcube_find_object('rcmrow' + id);
+        message.scrollIntoView();
+        }
+      var url = '_action=preview&_uid='+id;
+      rcmail.http_request('preview', url, true);
+      }
+    };
     
 
   // when user doble-clicks on a row
@@ -3569,6 +3597,12 @@
       case 'expunge':
         this.enable_command('select-all', 'select-none', 'expunge', 
this.env.messagecount ? true : false);
         break;      
+
+      case 'preview':
+        var previewpane = rcube_find_object('previewpane');
+        previewpane.innerHTML = request_obj.get_text();
+               previewpane.scrollTop = 0;
+        break;
       }
 
     request_obj.reset();
Index: program/steps/settings/func.inc
===================================================================
--- program/steps/settings/func.inc     (revision 335)
+++ program/steps/settings/func.inc     (working copy)
@@ -49,7 +49,8 @@
   $a_show_cols = array('language'   => array('type' => 'text'),
                        'pagesize'   => array('type' => 'text'),
                        'timezone'   => array('type' => 'text'),
-                       'prettydate' => array('type' => 'text'));
+                       'prettydate' => array('type' => 'text'),
+                       'preview'    => array('type' => 'text'));
                        
   // show language selection
   $a_lang = rcube_list_languages();
@@ -144,7 +145,16 @@
                   rep_specialchars_output(rcube_label('prettydate')),
                   $input_prettydate->show($CONFIG['prettydate']?1:0));
 
+  // show preview window selection
+  $field_id = 'rcmfd_preview';
+  $input_preview = new checkbox(array('name' => '_preview', 'id' => $field_id, 
'value' => 1));
 
+  $out .= sprintf("<tr><td class=\"title\"><label 
for=\"%s\">%s</label></td><td>%s</td></tr>\n",
+                  $field_id,
+                  rep_specialchars_output(rcube_label('preview')),
+                  $input_preview->show($CONFIG['preview']?1:0));
+
+
   $out .= "\n</table>$form_end";
 
   return $out;  
@@ -219,4 +229,4 @@
   }
 
 
-?>
\ No newline at end of file
+?>
Index: program/steps/settings/save_prefs.inc
===================================================================
--- program/steps/settings/save_prefs.inc       (revision 335)
+++ program/steps/settings/save_prefs.inc       (working copy)
@@ -28,6 +28,7 @@
 $a_user_prefs['dst_active'] = isset($_POST['_dst_active']) ? TRUE : FALSE;
 $a_user_prefs['pagesize'] = is_numeric($_POST['_pagesize']) ? 
(int)$_POST['_pagesize'] : $CONFIG['pagesize'];
 $a_user_prefs['prefer_html'] = isset($_POST['_prefer_html']) ? TRUE : FALSE;
+$a_user_prefs['preview'] = isset($_POST['_preview']) ? TRUE : FALSE;
 
 // MM: Date format toggle (Pretty / Standard)
 $a_user_prefs['prettydate'] = isset($_POST['_pretty_date']) ? TRUE : FALSE;
@@ -48,4 +49,4 @@
 // overwrite action variable  
 $OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, 
$_action));  
 
-?>
\ No newline at end of file
+?>
Index: program/steps/mail/show.inc
===================================================================
--- program/steps/mail/show.inc (revision 335)
+++ program/steps/mail/show.inc (working copy)
@@ -171,6 +171,8 @@
 
 if ($_action=='print')
   parse_template('printmessage');
+else if ($_action=='preview')
+  parse_template('previewmessage');
 else
   parse_template('message');
-?>
\ No newline at end of file
+?>
Index: program/steps/mail/func.inc
===================================================================
--- program/steps/mail/func.inc (revision 335)
+++ program/steps/mail/func.inc (working copy)
@@ -480,6 +480,7 @@
   $javascript .= sprintf("%s.set_env('pagecount', %d);\n", $JS_OBJECT_NAME, 
ceil($message_count/$IMAP->page_size));
   $javascript .= sprintf("%s.set_env('sort_col', '%s');\n", $JS_OBJECT_NAME, 
$sort_col);
   $javascript .= sprintf("%s.set_env('sort_order', '%s');\n", $JS_OBJECT_NAME, 
$sort_order);
+  $javascript .= sprintf("%s.set_env('preview', '%s');\n", $JS_OBJECT_NAME, 
$CONFIG['preview']);
   
   if ($attrib['messageicon'])
     $javascript .= sprintf("%s.set_env('messageicon', '%s%s');\n", 
$JS_OBJECT_NAME, $skin_path, $attrib['messageicon']);
Index: skins/default/mail.css
===================================================================
--- skins/default/mail.css      (revision 335)
+++ skins/default/mail.css      (working copy)
@@ -120,7 +120,23 @@
   height: 
expression((parseInt(document.documentElement.clientHeight)-125)+'px');
 }
 
+#previewpane
+{
+  position: absolute;
+  display: none;
+  top: 85px;
+  left: 200px;
+  right: 40px;
+  bottom: 40px;
+  border: 1px solid #999999;
+  border-top: none;
+  background-color: #F9F9F9;
+  overflow: auto;
+  /* css hack for IE */
+  width: expression((parseInt(document.documentElement.clientWidth)-240)+'px');
+}
 
+
 #messagepartframe
 {
   border: 1px solid #999999;
Index: skins/default/templates/mail.html
===================================================================
--- skins/default/templates/mail.html   (revision 335)
+++ skins/default/templates/mail.html   (working copy)
@@ -52,6 +52,8 @@
   attachmentIcon="/images/icons/attachment.png" />
 </div>
 
+<div id="previewpane" style="display: none;"></div>
+
 <div id="listcontrols">
 <roundcube:label name="select" />:&nbsp;
 <roundcube:button command="select-all" label="all" classAct="active" />&nbsp;
Index: skins/default/templates/previewmessage.html
===================================================================
--- skins/default/templates/previewmessage.html (revision 0)
+++ skins/default/templates/previewmessage.html (revision 0)
@@ -0,0 +1,4 @@
+<roundcube:object name="messageHeaders" class="headers-table" cellspacing="0" 
cellpadding="2" addicon="/images/icons/plus.gif" summary="Message headers" />
+<roundcube:object name="messageAttachments" id="attachment-list" />
+<roundcube:object name="blockedObjects" id="remote-objects-message" />
+<roundcube:object name="messageBody" id="messagebody" showImages="true" />
Index: index.php
===================================================================
--- index.php   (revision 335)
+++ index.php   (working copy)
@@ -241,7 +241,7 @@
   {
   include_once('program/steps/mail/func.inc');
   
-  if ($_action=='show' || $_action=='print')
+  if ($_action=='show' || $_action=='print' || $_action=='preview')
     include('program/steps/mail/show.inc');
 
   if ($_action=='get')

Reply via email to