| | |
| | | type: 'GET', |
| | | url: this.url('get', { '_mbox': this.env.mailbox, '_uid': this.env.uid, '_part': this.env.pgp_mime_part }), |
| | | error: function(o, status, err) { |
| | | ref.hide_message(msgkey); |
| | | ref.http_error(o, status, err, lock); |
| | | ref.http_error(o, status, err, msgid); |
| | | }, |
| | | success: function(data) { |
| | | ref.mailvelope_display_container(selector, data, keyring, msgid); |
| | |
| | | } |
| | | } |
| | | else if (action == 'compose' && window.mailvelope) { |
| | | this.enable_command('compose-encrypted', true); |
| | | if (this.env.pgp_mime_message) { |
| | | // fetch PGP/Mime part and open load into Mailvelope editor |
| | | var lock = this.set_busy(true, this.get_label('loadingdata')); |
| | | $.ajax({ |
| | | type: 'GET', |
| | | url: this.url('get', this.env.pgp_mime_message), |
| | | error: function(o, status, err) { |
| | | ref.http_error(o, status, err, lock); |
| | | ref.enable_command('compose-encrypted', true); |
| | | }, |
| | | success: function(data) { |
| | | ref.set_busy(false, null, lock); |
| | | ref.compose_encrypted({ quotedMail: data }); |
| | | ref.enable_command('compose-encrypted', true); |
| | | } |
| | | }); |
| | | } |
| | | else { |
| | | // enable encrypted compose toggle |
| | | this.enable_command('compose-encrypted', true); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // handler for the 'compose-encrypt' command |
| | | // handler for the 'compose-encrypted' command |
| | | this.compose_encrypted = function(props) |
| | | { |
| | | var container = $('#' + this.env.composebody).parent(); |
| | |
| | | // embed Mailvelope editor container |
| | | else { |
| | | var options = { predefinedText: $('#' + this.env.composebody).val() }; |
| | | if (props.quotedMail) { |
| | | options = { quotedMail: props.quotedMail, quotedMailIndent: false }; |
| | | } |
| | | if (this.env.compose_mode == 'reply') { |
| | | options.quotedMailIndent = true; |
| | | options.quotedMailHeader = this.env.compose_reply_header; |
| | | } |
| | | |
| | | mailvelope.createEditorContainer('#' + container.attr('id'), ref.mailvelope_keyring, options).then(function(editor) { |
| | | ref.mailvelope_editor = editor; |
| | | ref.compose_skip_unsavedcheck = true; |
| | |
| | | |
| | | container.addClass('mailvelope'); |
| | | $('#' + ref.env.composebody).hide(); |
| | | |
| | | // notify user about loosing attachments |
| | | if (ref.env.attachments && !$.isEmptyObject(ref.env.attachments)) { |
| | | alert(ref.get_label('encryptnoattachments')); |
| | | |
| | | $.each(ref.env.attachments, function(name, attach) { |
| | | ref.remove_from_attachment_list(name); |
| | | }); |
| | | } |
| | | }).catch(function(err) { |
| | | console.error(err); |
| | | }); |