Fix bug where compose options could be added to wrong form

pull/5742/merge
Aleksander Machniak 7 years ago
parent 626010ed3b
commit ffb2de5505

@ -93,7 +93,7 @@ function rcube_elastic_ui()
*/ */
function setup() function setup()
{ {
var title, var title, form,
content_buttons = [], content_buttons = [],
is_framed = rcmail.is_framed(); is_framed = rcmail.is_framed();
@ -193,29 +193,33 @@ function rcube_elastic_ui()
$('[data-recipient-input]').each(function() { recipient_input(this); }); $('[data-recipient-input]').each(function() { recipient_input(this); });
$('.image-upload').each(function() { image_upload_input(this); }); $('.image-upload').each(function() { image_upload_input(this); });
// Show input elements with non-empty value // Mail compose features
// These event handlers need to be registered before rcmail 'init' event if (form = rcmail.gui_objects.messageform) {
$('#_cc, #_bcc, #_replyto, #_followupto', $('.compose-headers')).each(function() { form = $('form[name="' + form + '"]');
$(this).on('change', function() { // Show input elements with non-empty value
$('#compose' + $(this).attr('id'))[this.value ? 'removeClass' : 'addClass']('hidden'); // These event handlers need to be registered before rcmail 'init' event
$('#_cc, #_bcc, #_replyto, #_followupto', $('.compose-headers')).each(function() {
$(this).on('change', function() {
$('#compose' + $(this).attr('id'))[this.value ? 'removeClass' : 'addClass']('hidden');
});
}); });
});
// We put compose options for outside of the main form // We put compose options for outside of the main form
// Because IE/Edge does not support 'form' attribute we'll copy // Because IE/Edge does not support 'form' attribute we'll copy
// inputs into the main form hidden fields // inputs into the main form hidden fields
// TODO: Consider doing this for IE/Edge only, just set the 'form' attribute on others // TODO: Consider doing this for IE/Edge only, just set the 'form' attribute on others
$('#compose-options').find('textarea,input,select').each(function() { $('#compose-options').find('textarea,input,select').each(function() {
var hidden = $('<input>') var hidden = $('<input>')
.attr({type: 'hidden', name: $(this).attr('name')}) .attr({type: 'hidden', name: $(this).attr('name')})
.appendTo(rcmail.gui_objects.messageform); .appendTo(form);
$(this).attr('tabindex', 2) $(this).attr('tabindex', 2)
.on('change', function() { .on('change', function() {
hidden.val(this.type != 'checkbox' || this.checked ? $(this).val() : ''); hidden.val(this.type != 'checkbox' || this.checked ? $(this).val() : '');
}) })
.change(); .change();
}); });
}
// Add HTML/Plain tabs (switch) on top of textarea with TinyMCE editor // Add HTML/Plain tabs (switch) on top of textarea with TinyMCE editor
$('textarea[data-html-editor]').each(function() { html_editor_init(this); }); $('textarea[data-html-editor]').each(function() { html_editor_init(this); });

Loading…
Cancel
Save