summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-05-03 08:18:40 +0000
committeralecpl <alec@alec.pl>2011-05-03 08:18:40 +0000
commit7fc056c3ffadefc48bb9f6f91f1ef783c253f5fb (patch)
tree2ec211e5135f67d6bed04d3a66dfea103908d31f /program
parent4d7fbd508aa50df367f9f055d95f22b697dab5f9 (diff)
- Enable multiselection for attachments uploading in capable browsers (#1485969)
Diffstat (limited to 'program')
-rw-r--r--program/include/html.php2
-rw-r--r--program/js/app.js27
-rw-r--r--program/steps/mail/compose.inc4
3 files changed, 16 insertions, 17 deletions
diff --git a/program/include/html.php b/program/include/html.php
index 34536e4c6..8f932ce2c 100644
--- a/program/include/html.php
+++ b/program/include/html.php
@@ -271,7 +271,7 @@ class html_inputfield extends html
protected $type = 'text';
protected $allowed = array('type','name','value','size','tabindex',
'autocomplete','checked','onchange','onclick','disabled','readonly',
- 'spellcheck','results','maxlength','src');
+ 'spellcheck','results','maxlength','src','multiple');
/**
* Object constructor
diff --git a/program/js/app.js b/program/js/app.js
index e83f33715..3da2eca56 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -473,13 +473,13 @@ function rcube_webmail()
// trigger plugin hooks
this.triggerEvent('actionbefore', {props:props, action:command});
- var event_ret = this.triggerEvent('before'+command, props);
- if (event_ret !== undefined) {
+ var ret = this.triggerEvent('before'+command, props);
+ if (ret !== undefined) {
// abort if one the handlers returned false
- if (event_ret === false)
+ if (ret === false)
return false;
else
- props = event_ret;
+ props = ret;
}
// process internal command
@@ -3171,16 +3171,12 @@ function rcube_webmail()
if (!form)
return false;
- // get file input fields
- var send = false;
- for (var n=0; n<form.elements.length; n++)
- if (form.elements[n].type=='file' && form.elements[n].value) {
- send = true;
- break;
- }
+ // get file input field, count files on capable browser
+ var field = $('input[type=file]', form).get(0),
+ files = field.files ? field.files.length : field.value ? 1 : 0;
// create hidden iframe and post upload form
- if (send) {
+ if (files) {
var frame_name = this.async_upload_form(form, 'upload', function(e) {
var d, content = '';
try {
@@ -3203,7 +3199,7 @@ function rcube_webmail()
});
// display upload indicator and cancel button
- var content = this.get_label('uploading'),
+ var content = this.get_label('uploading' + (files > 1 ? 'many' : '')),
ts = frame_name.replace(/^rcmupload/, '');
if (this.env.loadingicon)
@@ -3225,8 +3221,7 @@ function rcube_webmail()
if (!this.gui_objects.attachmentlist)
return false;
- var li = $('<li>').attr('id', name).html(att.html);
- var indicator;
+ var indicator, li = $('<li>').attr('id', name).html(att.html);
// replace indicator's li
if (upload_id && (indicator = document.getElementById(upload_id))) {
@@ -3253,7 +3248,7 @@ function rcube_webmail()
return false;
var list = this.gui_objects.attachmentlist.getElementsByTagName("li");
- for (i=0;i<list.length;i++)
+ for (i=0; i<list.length; i++)
if (list[i].id == name)
this.gui_objects.attachmentlist.removeChild(list[i]);
};
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 3f2390491..2357c52d8 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -1148,6 +1148,8 @@ function rcmail_compose_attachment_form($attrib)
$max_postsize = parse_bytes(ini_get('post_max_size'));
if ($max_postsize && $max_postsize < $max_filesize)
$max_filesize = $max_postsize;
+
+ $OUTPUT->set_env('max_filesize', $max_filesize);
$max_filesize = show_bytes($max_filesize);
$button = new html_inputfield(array('type' => 'button'));
@@ -1172,6 +1174,8 @@ function rcmail_compose_attachment_field($attrib)
{
$attrib['type'] = 'file';
$attrib['name'] = '_attachments[]';
+ $attrib['multiple'] = 'multiple';
+
$field = new html_inputfield($attrib);
return $field->show();
}