From bb1ed2740d5d576d0f43b9d6ad9557948dbc2805 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 09 Oct 2015 04:53:52 -0400
Subject: [PATCH] Display attachment size in compose (#1484774)

---
 CHANGELOG                          |    1 +
 program/steps/mail/attachments.inc |    3 ++-
 program/steps/mail/compose.inc     |    6 +++++-
 skins/larry/mail.css               |    4 ++++
 4 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 040abb9..03af71e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Display attachment size in compose (#1484774)
 - Added possibility to drag-n-drop attachments from mail preview to compose window
 - Implemented mail messages searching with predefined date interval
 - PGP encryption support via Mailvelope integration
diff --git a/program/steps/mail/attachments.inc b/program/steps/mail/attachments.inc
index c39b25c..fe2f845 100644
--- a/program/steps/mail/attachments.inc
+++ b/program/steps/mail/attachments.inc
@@ -203,7 +203,8 @@
         'aria-label' => $RCMAIL->gettext('delete') . ' ' . $attachment['name'],
     ), $button);
 
-    $content .= rcube::Q($attachment['name']);
+    $content .= sprintf('%s <span class="attachment-size">(%s)</span>',
+        rcube::Q($attachment['name']), $RCMAIL->show_bytes($attachment['size']));
 
     $RCMAIL->output->command('add2attachment_list', "rcmfile$id", array(
         'html'      => $content,
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 0e61e26..86e33fc 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -385,6 +385,7 @@
                     'group'    => $COMPOSE_ID,
                     'name'     => $filename,
                     'mimetype' => rcube_mime::file_content_type($attach, $filename),
+                    'size'     => filesize($attach),
                     'path'     => $attach,
                 );
             }
@@ -1557,6 +1558,9 @@
                 continue;
             }
 
+            $content = sprintf('%s <span class="attachment-size">(%s)</span>',
+                rcube::Q($a_prop['name']), $RCMAIL->show_bytes($a_prop['size']));
+
             $out .= html::tag('li', array(
                     'id'          => 'rcmfile'.$id,
                     'class'       => rcube_utils::file2class($a_prop['mimetype'], $a_prop['name']),
@@ -1571,7 +1575,7 @@
                         'aria-label'   => $RCMAIL->gettext('delete') . ' ' . $a_prop['name'],
                     ),
                     $button
-                ) . rcube::Q($a_prop['name'])
+                ) . $content
             );
 
             $jslist['rcmfile'.$id] = array(
diff --git a/skins/larry/mail.css b/skins/larry/mail.css
index 3dc93d2..969cb1f 100644
--- a/skins/larry/mail.css
+++ b/skins/larry/mail.css
@@ -1366,6 +1366,10 @@
 	-webkit-box-shadow: 0 0 5px 2px rgba(71,135,177, 0.9);
 }
 
+#compose-attachments .attachment-size {
+	color: #888;
+}
+
 #composeview-bottom .formbuttons.floating {
 	position: absolute;
 	width: auto;

--
Gitblit v1.9.1