summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-03-06 11:11:37 +0100
committerAleksander Machniak <alec@alec.pl>2013-03-06 11:11:37 +0100
commitbc2c4380b5b754a3b13cc7d6663b2b81d2577e2e (patch)
tree7a3c360113d21a5f7c6d0e90b252ce5965dd3589 /program
parentac37746c2ae187edaf38c7a660213e216f90b035 (diff)
Add attachment menu with Open and Download options (#1488975)
Diffstat (limited to 'program')
-rw-r--r--program/include/rcmail_output_html.php4
-rw-r--r--program/js/app.js21
-rw-r--r--program/localization/en_US/labels.inc1
-rw-r--r--program/steps/mail/show.inc23
4 files changed, 33 insertions, 16 deletions
diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php
index 2babe1cbb..ade2bd4a4 100644
--- a/program/include/rcmail_output_html.php
+++ b/program/include/rcmail_output_html.php
@@ -1175,6 +1175,10 @@ class rcmail_output_html extends rcmail_output
$out = sprintf('<a%s>%s</a>', $attrib_str, $btn_content);
}
+ if ($attrib['wrapper']) {
+ $out = html::tag($attrib['wrapper'], null, $out);
+ }
+
return $out;
}
diff --git a/program/js/app.js b/program/js/app.js
index 4011fa593..55c71d776 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -179,7 +179,8 @@ function rcube_webmail()
}
// enable general commands
- this.enable_command('close', 'logout', 'mail', 'addressbook', 'settings', 'save-pref', 'compose', 'undo', 'about', 'switch-task', true);
+ this.enable_command('close', 'logout', 'mail', 'addressbook', 'settings', 'save-pref',
+ 'compose', 'undo', 'about', 'switch-task', 'menu-open', 'menu-save', true);
if (this.env.permaurl)
this.enable_command('permaurl', 'extwin', true);
@@ -211,7 +212,7 @@ function rcube_webmail()
this.gui_objects.messagelist.parentNode.onmousedown = function(e){ return p.click_on_list(e); };
this.message_list.init();
- this.enable_command('toggle_status', 'toggle_flag', 'menu-open', 'menu-save', 'sort', true);
+ this.enable_command('toggle_status', 'toggle_flag', 'sort', true);
// load messages
this.command('list');
@@ -227,7 +228,7 @@ function rcube_webmail()
this.env.message_commands = ['show', 'reply', 'reply-all', 'reply-list',
'moveto', 'copy', 'delete', 'open', 'mark', 'edit', 'viewsource',
- 'print', 'load-attachment', 'show-headers', 'hide-headers', 'download',
+ 'print', 'load-attachment', 'download-attachment', 'show-headers', 'hide-headers', 'download',
'forward', 'forward-inline', 'forward-attachment'];
if (this.env.action == 'show' || this.env.action == 'preview') {
@@ -608,6 +609,11 @@ function rcube_webmail()
break;
case 'menu-open':
+ if (props && props.menu == 'attachmentmenu') {
+ var mimetype = this.env.attachments[props.id];
+ this.enable_command('open-attachment', mimetype && this.env.mimetypes && $.inArray(mimetype, this.env.mimetypes) >= 0);
+ }
+
case 'menu-save':
this.triggerEvent(command, {props:props});
return false;
@@ -833,11 +839,14 @@ function rcube_webmail()
break;
case 'load-attachment':
- var qstring = '_mbox='+urlencode(this.env.mailbox)+'&_uid='+this.env.uid+'&_part='+props.part;
+ case 'open-attachment':
+ case 'download-attachment':
+ var qstring = '_mbox='+urlencode(this.env.mailbox)+'&_uid='+this.env.uid+'&_part='+props,
+ mimetype = this.env.attachments[props];
// open attachment in frame if it's of a supported mimetype
- if (this.env.uid && props.mimetype && this.env.mimetypes && $.inArray(props.mimetype, this.env.mimetypes) >= 0) {
- var attachment_win = window.open(this.env.comm_path+'&_action=get&'+qstring+'&_frame=1', 'rcubemailattachment'+this.env.uid+props.part);
+ if (command != 'download-attachment' && mimetype && this.env.mimetypes && $.inArray(mimetype, this.env.mimetypes) >= 0) {
+ var attachment_win = window.open(this.env.comm_path+'&_action=get&'+qstring+'&_frame=1', 'rcubemailattachment'+this.env.uid+props);
if (attachment_win) {
setTimeout(function(){ attachment_win.focus(); }, 10);
break;
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 0750e7848..61a13e9ab 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -64,6 +64,7 @@ $labels['copy'] = 'Copy';
$labels['move'] = 'Move';
$labels['moveto'] = 'Move to...';
$labels['download'] = 'Download';
+$labels['open'] = 'Open';
$labels['showattachment'] = 'Show';
$labels['showanyway'] = 'Show it anyway';
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 437dbaafa..87555cbbe 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -147,6 +147,7 @@ function rcmail_message_attachments($attrib)
global $PRINT_MODE, $MESSAGE, $RCMAIL;
$out = $ol = '';
+ $attachments = array();
if (sizeof($MESSAGE->attachments)) {
foreach ($MESSAGE->attachments as $attach_prop) {
@@ -165,21 +166,23 @@ function rcmail_message_attachments($attrib)
$title = '';
}
- $ol .= html::tag('li', rcmail_filetype2classname($attach_prop->mimetype, $filename),
- html::a(array(
+ $mimetype = rcmail_fix_mimetype($attach_prop->mimetype);
+ $class = rcmail_filetype2classname($mimetype, $filename);
+ $id = 'attach' . $attach_prop->mime_id;
+ $link = html::a(array(
'href' => $MESSAGE->get_part_url($attach_prop->mime_id, false),
- 'onclick' => sprintf(
- 'return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)',
- JS_OBJECT_NAME,
- $attach_prop->mime_id,
- rcmail_fix_mimetype($attach_prop->mimetype)),
- 'title' => Q($title),
- ),
- Q($filename)));
+ 'onclick' => sprintf('return %s.command(\'load-attachment\',\'%s\',this)',
+ JS_OBJECT_NAME, $attach_prop->mime_id),
+ 'title' => Q($title),
+ ), Q($filename));
+ $ol .= html::tag('li', array('class' => $class, 'id' => $id), $link);
+
+ $attachments[$attach_prop->mime_id] = $mimetype;
}
}
$out = html::tag('ul', $attrib, $ol, html::$common_attrib);
+ $RCMAIL->output->set_env('attachments', $attachments);
}
return $out;