Rewrite smart upload button to work in IE (#5410)

pull/5393/head^2
Aleksander Machniak 8 years ago
parent 820d614c79
commit c88a88fb0b

@ -1631,57 +1631,56 @@ function rcmail_compose_attachment_form($attrib)
{ {
global $RCMAIL; global $RCMAIL;
// set defaults
$attrib += array('id' => 'rcmUploadbox', 'buttons' => 'yes');
// Get filesize, enable upload progress bar // Get filesize, enable upload progress bar
$max_filesize = $RCMAIL->upload_init(); $max_filesize = $RCMAIL->upload_init();
$hint = html::div('hint', $RCMAIL->gettext(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize)))); $hint = html::div('hint', $RCMAIL->gettext(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize))));
$event = rcmail_output::JS_OBJECT_NAME . ".command('send-attachment', this.form)";
$form_id = $attrib['id'] . 'Frm'; if ($attrib['mode'] == 'hint') {
$form_attr = array( return $hint;
}
// set defaults
$attrib += array('id' => 'rcmUploadbox', 'buttons' => 'yes');
$event = rcmail_output::JS_OBJECT_NAME . ".command('send-attachment', this.form)";
$form_id = $attrib['id'] . 'Frm';
$input_attr = array('id' => $attrib['id'] . 'Input');
$form_attr = array(
'id' => $form_id, 'id' => $form_id,
'name' => 'uploadform', 'name' => 'uploadform',
'method' => 'post', 'method' => 'post',
'enctype' => 'multipart/form-data' 'enctype' => 'multipart/form-data'
); );
$RCMAIL->output->add_gui_object('uploadform', $form_id); if ($attrib['mode'] == 'smart') {
unset($attrib['buttons']);
if (rcube_utils::get_boolean($attrib['smart-button'])) { $form_attr['class'] = 'smart-upload';
$form = $RCMAIL->output->form_tag($form_attr, "\n"); $input_attr += array(
$RCMAIL->output->add_footer($form);
$input_attrs = $attrib + array(
// Note: Chrome sometimes executes onchange event on Cancel, make sure a file was selected // Note: Chrome sometimes executes onchange event on Cancel, make sure a file was selected
'onchange' => "if ((this.files && this.files.length) || (!this.files && this.value)) $event", 'onchange' => "if ((this.files && this.files.length) || (!this.files && this.value)) $event",
'form' => $form_id,
'class' => 'smart-upload', 'class' => 'smart-upload',
'tabindex' => '-1', 'tabindex' => '-1',
); );
}
$label_attrs = array( $content = rcmail_compose_attachment_field($input_attr);
'for' => $attrib['id'],
'id' => $attrib['id'] . 'btn',
'tabindex' => $attrib['tabindex'],
'onkeypress' => 'if (event.keyCode == 13) this.click()',
);
return $hint . rcmail_compose_attachment_field($input_attrs) if ($attrib['mode'] != 'smart') {
. html::label($label_attrs, $RCMAIL->gettext('addattachment')); $content = html::div(null, $content);
$content .= $hint;
} }
$button = new html_inputfield(array('type' => 'button'));
$content = html::div(null, rcmail_compose_attachment_field()) . $hint;
if (rcube_utils::get_boolean($attrib['buttons'])) { if (rcube_utils::get_boolean($attrib['buttons'])) {
$button = new html_inputfield(array('type' => 'button'));
$content .= html::div('buttons', $content .= html::div('buttons',
$button->show($RCMAIL->gettext('close'), array('class' => 'button', 'onclick' => "$('#$attrib[id]').hide()")) . ' ' . $button->show($RCMAIL->gettext('close'), array('class' => 'button', 'onclick' => "$('#$attrib[id]').hide()")) . ' ' .
$button->show($RCMAIL->gettext('upload'), array('class' => 'button mainaction', 'onclick' => $event)) $button->show($RCMAIL->gettext('upload'), array('class' => 'button mainaction', 'onclick' => $event))
); );
} }
$RCMAIL->output->add_gui_object('uploadform', $form_id);
return html::div($attrib, $RCMAIL->output->form_tag($form_attr, $content)); return html::div($attrib, $RCMAIL->output->form_tag($form_attr, $content));
} }

@ -181,6 +181,7 @@ input.mainaction {
font-weight: bold; font-weight: bold;
} }
form.smart-upload,
input.smart-upload { input.smart-upload {
visibility: hidden; visibility: hidden;
width: 1px; width: 1px;
@ -190,11 +191,6 @@ input.smart-upload {
/** link buttons **/ /** link buttons **/
input.smart-upload + label {
cursor: pointer;
}
input.smart-upload + label,
a.button, a.button,
.buttongroup { .buttongroup {
display: inline-block; display: inline-block;
@ -218,8 +214,6 @@ a.button,
white-space: nowrap; white-space: nowrap;
} }
input.smart-upload:focus + label,
input.smart-upload + label:focus,
a.button:focus, a.button:focus,
input.button:focus { input.button:focus {
border-color: #4fadd5; border-color: #4fadd5;

@ -30,7 +30,7 @@
<a href="#languages" class="dropbuttontip" id="spellmenulink" onclick="UI.toggle_popup('spellmenu',event);return false" aria-haspopup="true" aria-expanded="false" tabindex="2">Select Spell Language</a> <a href="#languages" class="dropbuttontip" id="spellmenulink" onclick="UI.toggle_popup('spellmenu',event);return false" aria-haspopup="true" aria-expanded="false" tabindex="2">Select Spell Language</a>
</span> </span>
<roundcube:endif /> <roundcube:endif />
<roundcube:button name="addattachment" type="link" class="button attach" label="attach" title="addattachment" onclick="$('#uploadformbtn').click(); return false" aria-haspopup="true" aria-expanded="false" tabindex="2" /> <roundcube:button name="addattachment" type="link" class="button attach" label="attach" title="addattachment" onclick="$('#uploadformInput').click()" aria-haspopup="true" aria-expanded="false" tabindex="2" />
<roundcube:button command="insert-sig" type="link" class="button insertsig disabled" classAct="button insertsig" label="signature" title="insertsignature" tabindex="2" /> <roundcube:button command="insert-sig" type="link" class="button insertsig disabled" classAct="button insertsig" label="signature" title="insertsignature" tabindex="2" />
<a href="#responses" class="button responses" label="responses" title="<roundcube:label name='insertresponse' />" id="responsesmenulink" unselectable="on" onmousedown="return false" onclick="UI.toggle_popup('responsesmenu',event);return false" tabindex="2" aria-haspopup="true" aria-expanded="false" aria-owns="textresponsesmenu"><roundcube:label name="responses" /></a> <a href="#responses" class="button responses" label="responses" title="<roundcube:label name='insertresponse' />" id="responsesmenulink" unselectable="on" onmousedown="return false" onclick="UI.toggle_popup('responsesmenu',event);return false" tabindex="2" aria-haspopup="true" aria-expanded="false" aria-owns="textresponsesmenu"><roundcube:label name="responses" /></a>
<roundcube:button command="compose-encrypted" type="link" class="button encrypt disabled" classAct="button encrypt" classSel="button encrypt selected" label="encrypt" title="encryptmessagemailvelope" tabindex="2" style="display:none" /> <roundcube:button command="compose-encrypted" type="link" class="button encrypt disabled" classAct="button encrypt" classSel="button encrypt selected" label="encrypt" title="encryptmessagemailvelope" tabindex="2" style="display:none" />
@ -176,7 +176,8 @@
<div id="compose-attachments" class="rightcol" role="region" aria-labelledby="aria-label-composeattachments"> <div id="compose-attachments" class="rightcol" role="region" aria-labelledby="aria-label-composeattachments">
<h2 id="aria-label-composeattachments" class="voice"><roundcube:label name="attachments" /></h2> <h2 id="aria-label-composeattachments" class="voice"><roundcube:label name="attachments" /></h2>
<div style="text-align:center; margin-bottom:10px"> <div style="text-align:center; margin-bottom:10px">
<roundcube:object name="composeAttachmentForm" id="uploadform" smart-button="yes" tabindex="1" /> <roundcube:object name="composeAttachmentForm" mode="hint" />
<a class="button" tabindex="1" href="#" onclick="$('#uploadformInput').click()"><roundcube:label name="addattachment" /></a>
</div> </div>
<roundcube:object name="composeAttachmentList" id="attachment-list" class="attachmentslist" tabindex="1" /> <roundcube:object name="composeAttachmentList" id="attachment-list" class="attachmentslist" tabindex="1" />
<roundcube:object name="fileDropArea" id="compose-attachments" /> <roundcube:object name="fileDropArea" id="compose-attachments" />
@ -198,6 +199,8 @@
</div><!-- end mainscreen --> </div><!-- end mainscreen -->
<roundcube:object name="composeAttachmentForm" id="uploadform" mode="smart" />
<div id="spellmenu" class="popupmenu" aria-hidden="true"></div> <div id="spellmenu" class="popupmenu" aria-hidden="true"></div>
<div id="responsesmenu" class="popupmenu" aria-hidden="true"> <div id="responsesmenu" class="popupmenu" aria-hidden="true">

Loading…
Cancel
Save