Hi,

I managed to spend some time on my preview pane, to make it work in the
current SVN revision 361.

Two options were added to config/main.inc.php:

// Enable preview pane
$rcmail_config['enable_preview'] = FALSE;

// display preview pane if enabled
$rcmail_config['preview'] = FALSE;



Some issues that I have:

- Attachment filenames are gone, even though the preview pane displays
them correctly.
- There should be a 'view source' button if a message is previewed.



Robin
Index: config/main.inc.php.dist
===================================================================
--- config/main.inc.php.dist    (revision 361)
+++ config/main.inc.php.dist    (working copy)
@@ -171,6 +171,9 @@
 // Leave empty for default set of Google spell check languages
 $rcmail_config['spellcheck_languages'] = NULL;
 
+// Enable preview pane
+$rcmail_config['enable_preview'] = FALSE;
+
 // path to a text file which will be added to each sent message
 // paths are relative to the RoundCube root folder
 $rcmail_config['generic_message_footer'] = '';
@@ -216,6 +219,9 @@
 // prefer displaying HTML messages
 $rcmail_config['prefer_html'] = TRUE;
 
+// display preview pane if enabled
+$rcmail_config['preview'] = FALSE;
+
 // show pretty dates as standard
 $rcmail_config['prettydate'] = TRUE;
 
Index: program/include/main.inc
===================================================================
--- program/include/main.inc    (revision 361)
+++ program/include/main.inc    (working copy)
@@ -1200,6 +1200,7 @@
         'editorselector' => 'rcmail_editor_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 361)
+++ 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 361)
+++ program/localization/en_US/labels.inc       (working copy)
@@ -207,6 +207,7 @@
 $labels['dstactive']  = 'Daylight savings';
 $labels['htmleditor'] = 'Compose HTML messages';
 $labels['htmlsignature'] = 'HTML signature';
+$labels['preview'] = 'Preview message';
 
 $labels['autosavedraft']  = 'Automatically save draft';
 $labels['everynminutes']  = 'every $n minutes';
Index: program/js/app.js
===================================================================
--- program/js/app.js   (revision 361)
+++ program/js/app.js   (working copy)
@@ -135,7 +135,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')
           {
@@ -552,6 +552,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))
@@ -1039,6 +1040,8 @@
       this.enable_command('show', 'reply', 'reply-all', 'forward', 'print', 
selected);
       this.enable_command('delete', 'moveto', list.selection.length>0 ? true : 
false);
       }
+    if (selected && this.env.enable_preview && this.env.preview)
+      this.show_preview(list.selection[0]);
    };
 
 
@@ -1067,6 +1070,30 @@
   /*********************************************************/
 
 
+  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
   this.show_message = function(id, safe)
     {
@@ -3115,6 +3142,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 361)
+++ program/steps/settings/func.inc     (working copy)
@@ -155,6 +155,17 @@
                   rep_specialchars_output(rcube_label('htmleditor')),
                   $input_htmleditor->show($CONFIG['htmleditor']?1:0));
 
+  // Show option for preview pane
+  if ($CONFIG['enable_preview'])
+    {
+    $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));
+    }
+
   if (!empty($CONFIG['drafts_mbox']))
     {
     $field_id = 'rcmfd_autosave';
@@ -242,4 +253,4 @@
   }
 
 
-?>
\ No newline at end of file
+?>
Index: program/steps/settings/save_prefs.inc
===================================================================
--- program/steps/settings/save_prefs.inc       (revision 361)
+++ program/steps/settings/save_prefs.inc       (working copy)
@@ -29,8 +29,11 @@
 $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['htmleditor'] = isset($_POST['_htmleditor']) ? TRUE : FALSE;
+if ($CONFIG['enable_preview'])
+  $a_user_prefs['preview'] = isset($_POST['_preview']) ? TRUE : FALSE;
 $a_user_prefs['draft_autosave'] = isset($_POST['_draft_autosave']) ? 
intval($_POST['_draft_autosave']) : 0;
 
+
 // MM: Date format toggle (Pretty / Standard)
 $a_user_prefs['prettydate'] = isset($_POST['_pretty_date']) ? TRUE : FALSE;
 
Index: program/steps/mail/show.inc
===================================================================
--- program/steps/mail/show.inc (revision 361)
+++ 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 361)
+++ program/steps/mail/func.inc (working copy)
@@ -480,6 +480,8 @@
   $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);
+  if ($CONFIG['enable_preview'])
+    $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/templates/mail.html
===================================================================
--- skins/default/templates/mail.html   (revision 361)
+++ 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/mail.css
===================================================================
--- skins/default/mail.css      (revision 361)
+++ skins/default/mail.css      (working copy)
@@ -120,7 +120,30 @@
   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');
+  height: expression((
+    parseInt(document.documentElement.clientHeight) -
+    parseInt(document.getElementById('mailcontframe').clientHeight) - 
125)+'px');
+}
 
+body > div#previewpane
+{
+  height: auto;
+}
+
 #messagepartframe
 {
   border: 1px solid #999999;
Index: index.php
===================================================================
--- index.php   (revision 361)
+++ index.php   (working copy)
@@ -262,7 +262,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