From 203ee44470707bfe3af16f4ff4146896fa94e140 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 12 Sep 2008 08:27:46 -0400
Subject: [PATCH] Add link to open message in new window + tweaked some header styles

---
 program/localization/de_DE/labels.inc       |    1 
 CHANGELOG                                   |    1 
 skins/default/images/icons/extwin.png       |    0 
 skins/default/mail.css                      |   28 +++++++++++---
 program/localization/en_US/labels.inc       |    1 
 program/steps/mail/show.inc                 |   20 +++++----
 program/localization/de_CH/labels.inc       |    1 
 program/include/rcube_template.php          |   11 +++--
 skins/default/templates/messagepreview.html |    1 
 program/js/app.js                           |    9 ++++
 10 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index a5b68a7..cdb46a9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@
 ----------
 - Refactor drag & drop functionality. Don't rely on browser events anymore (#1484453)
 - Insert "virtual" folders in subscription list (#1484779)
+- Added link to open message in new window
 
 2008/09/05 (thomasb)
 ----------
diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index 1b61770..4441b0a 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -752,10 +752,13 @@
 
             // make valid href to specific buttons
             if (in_array($attrib['command'], rcmail::$main_tasks)) {
-                $attrib['href'] = Q(rcmail_url(null, null, $attrib['command']));
+                $attrib['href'] = rcmail_url(null, null, $attrib['command']);
             }
             else if (in_array($attrib['command'], $a_static_commands)) {
-                $attrib['href'] = Q(rcmail_url($attrib['command']));
+                $attrib['href'] = rcmail_url($attrib['command']);
+            }
+            else if ($attrib['command'] == 'permaurl' && !empty($this->env['permaurl'])) {
+                $attrib['href'] = $this->env['permaurl'];
             }
         }
 
@@ -817,11 +820,11 @@
             if ($attrib['label']) {
                 $btn_content .= ' '.$attrib['label'];
             }
-            $link_attrib = array('href', 'onclick', 'onmouseover', 'onmouseout', 'onmousedown', 'onmouseup', 'title');
+            $link_attrib = array('href', 'onclick', 'onmouseover', 'onmouseout', 'onmousedown', 'onmouseup', 'title', 'target');
         }
         else if ($attrib['type']=='link') {
             $btn_content = $attrib['label'] ? $attrib['label'] : $attrib['command'];
-            $link_attrib = array('href', 'onclick', 'title', 'id', 'class', 'style', 'tabindex');
+            $link_attrib = array('href', 'onclick', 'title', 'id', 'class', 'style', 'tabindex', 'target');
         }
         else if ($attrib['type']=='input') {
             $attrib['type'] = 'button';
diff --git a/program/js/app.js b/program/js/app.js
index b724287..a6d88aa 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -122,6 +122,9 @@
     // enable general commands
     this.enable_command('logout', 'mail', 'addressbook', 'settings', true);
     
+    if (this.env.permaurl)
+      this.enable_command('permaurl', true);
+    
     switch (this.task)
       {
       case 'mail':
@@ -529,6 +532,12 @@
         this.switch_task(command);
         break;
 
+      case 'permaurl':
+        if (obj && obj.href && obj.target)
+          return true;
+        else if (this.env.permaurl)
+          parent.location.href = this.env.permaurl;
+          break;
 
       // misc list commands
       case 'list':
diff --git a/program/localization/de_CH/labels.inc b/program/localization/de_CH/labels.inc
index 31410a8..761b6c0 100644
--- a/program/localization/de_CH/labels.inc
+++ b/program/localization/de_CH/labels.inc
@@ -130,6 +130,7 @@
 $labels['unlimited'] = 'unlimitiert';
 $labels['quicksearch'] = 'Schnellsuche';
 $labels['resetsearch'] = 'Löschen';
+$labels['openinextwin'] = 'In neuem Fenster öffnen';
 $labels['compose'] = 'Neue Nachricht verfassen';
 $labels['savemessage'] = 'Nachricht speichern';
 $labels['sendmessage'] = 'Nachricht jetzt senden';
diff --git a/program/localization/de_DE/labels.inc b/program/localization/de_DE/labels.inc
index 89c28d8..5d202e3 100644
--- a/program/localization/de_DE/labels.inc
+++ b/program/localization/de_DE/labels.inc
@@ -129,6 +129,7 @@
 $labels['unlimited'] = 'unbegrenzt';
 $labels['quicksearch'] = 'Schnellsuche';
 $labels['resetsearch'] = 'Suche zurücksetzen';
+$labels['openinextwin'] = 'In neuem Fenster öffnen';
 $labels['compose'] = 'Neue Nachricht verfassen';
 $labels['savemessage'] = 'Nachricht speichern';
 $labels['sendmessage'] = 'Nachricht jetzt senden';
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 6b503ff..7e538c2 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -160,6 +160,7 @@
 $labels['quicksearch']  = 'Quick search';
 $labels['resetsearch']  = 'Reset search';
 
+$labels['openinextwin'] = 'Open in new window';
 
 // message compose
 $labels['compose']        = 'Compose a message';
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 256561e..0b15c98 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -80,6 +80,7 @@
   $OUTPUT->set_env('uid', $MESSAGE->uid);
   $OUTPUT->set_env('safemode', $MESSAGE->is_safe);
   $OUTPUT->set_env('sender', $MESSAGE->sender['string']);
+  $OUTPUT->set_env('permaurl', rcmail_url('show', array('_uid' => $MESSAGE->uid, '_mbox' => $mbox_name)));
   
   // check for unset disposition notification
   if ($MESSAGE->headers->mdn_to &&
@@ -152,14 +153,15 @@
         $ol .= html::tag('li', null, sprintf("%s (%s)", Q($attach_prop->filename), Q(show_bytes($attach_prop->size))));
       }
       else {
-	if (rc_strlen($attach_prop->filename) > 50) {
-          $filename = rc_substr($attach_prop->filename, 0, 25) . '...' . rc_substr($attach_prop->filename, strlen($attach_prop->filename)-20, 20);
-	  $title = $attach_prop->filename;
-	} else {
-	  $filename = $attach_prop->filename;
-	  $title = '';
-	}
-		  
+        if (rc_strlen($attach_prop->filename) > 50) {
+          $filename = abbreviate_string($attach_prop->filename, 50);
+          $title = $attach_prop->filename;
+      }
+      else {
+        $filename = $attach_prop->filename;
+        $title = '';
+      }
+
         $ol .= html::tag('li', null,
           html::a(array(
             'href' => $MESSAGE->get_part_url($attach_prop->mime_id),
@@ -168,7 +170,7 @@
               JS_OBJECT_NAME,
               $attach_prop->mime_id,
               $attach_prop->mimetype),
-	    'title' => Q($title),  
+              'title' => Q($title),
             ),
             Q($filename)));
       }
diff --git a/skins/default/images/icons/extwin.png b/skins/default/images/icons/extwin.png
new file mode 100644
index 0000000..1ab4d77
--- /dev/null
+++ b/skins/default/images/icons/extwin.png
Binary files differ
diff --git a/skins/default/mail.css b/skins/default/mail.css
index 7f76ed8..1502bd2 100644
--- a/skins/default/mail.css
+++ b/skins/default/mail.css
@@ -632,6 +632,7 @@
 
 div.messageheaderbox
 {
+  position: relative;
   margin: 6px 8px 0px 8px;
   border: 1px solid #ccc;
 }
@@ -649,6 +650,11 @@
   margin: 6px 8px;
   background-color: #F4F4F4;
   border: 1px solid #ccc;
+}
+
+#messageframe table.headers-table
+{
+  border-bottom: 1px solid #ccc;
 }
 
 table.headers-table tr td
@@ -813,6 +819,15 @@
   color: #333333;
 }
 
+#messageviewlink
+{
+  position: absolute;
+  top: 1px;
+  right: 1px;
+  width: 15px;
+  height: 15px;
+  border: 0;
+}
 
 /** message compose styles */
 
@@ -978,19 +993,20 @@
   margin-top: 4px;
 }
 
-.more-headers
+table.headers-table tr td.more-headers
 {
   cursor: pointer;
   width: 100%;
-  height: 6px;
+  height: 8px;
+  border-bottom: 0;
 }
 
-.show-headers
+td.show-headers
 {
   background: url(images/icons/down_small.gif) no-repeat center;
 }
 
-.hide-headers
+td.hide-headers
 {
   background: url(images/icons/up_small.gif) no-repeat center;
 }
@@ -1004,7 +1020,7 @@
 #headers-source
 {
   margin: 0 5px;
-  width: 100%;
+  padding: 0.5em;
   height: 145px;
   background: white;
   overflow: auto;
@@ -1013,7 +1029,7 @@
   border: 1px solid #999999;
   display: none;
   text-align: left;
-  color: #666666;
+  color: #333;
 }
 
 font.bold
diff --git a/skins/default/templates/messagepreview.html b/skins/default/templates/messagepreview.html
index e08f2c7..24848bb 100644
--- a/skins/default/templates/messagepreview.html
+++ b/skins/default/templates/messagepreview.html
@@ -8,6 +8,7 @@
 <body class="iframe">
 
 <div class="messageheaderbox">
+<roundcube:button command="permaurl" image="/images/icons/extwin.png" width="15" height="15" title="openinextwin" id="messageviewlink" target="_blank" />
 <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" />
 </div>

--
Gitblit v1.9.1