mirror of
https://github.com/moparisthebest/mail
synced 2024-11-26 10:52:17 -05:00
downloading parsed attachment in ui works
This commit is contained in:
parent
8d25527341
commit
5ad681e58d
@ -188,10 +188,6 @@ define(function(require) {
|
||||
}
|
||||
|
||||
function attachmentReady(err, gottenAttachment) {
|
||||
// parse uint8array to base to make it serializable for postMessage
|
||||
gottenAttachment.base64 = btoa(gottenAttachment.uint8Array);
|
||||
delete gottenAttachment.uint8Array;
|
||||
|
||||
attachments.push(gottenAttachment);
|
||||
itemCounter++;
|
||||
check();
|
||||
|
@ -34,9 +34,33 @@ define(['jquery', 'underscore', 'backbone', 'js/app-config'], function($, _, Bac
|
||||
$(this.el).html(this.template(params));
|
||||
this.renderBody();
|
||||
|
||||
// set download link for attachment button
|
||||
this.parseAttachments();
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
parseAttachments: function() {
|
||||
var attachments = this.model.attachments;
|
||||
if (!attachments) {
|
||||
// remove link if no attachments are present
|
||||
$(this.el).find('#attachmentItem').remove();
|
||||
return;
|
||||
}
|
||||
|
||||
var attmt = attachments[0];
|
||||
var blob = new Blob([attmt.uint8Array], {
|
||||
type: attmt.contentType
|
||||
});
|
||||
var url = window.URL.createObjectURL(blob);
|
||||
|
||||
// set download link
|
||||
$(this.el).find('#attachmentBtn').attr({
|
||||
href: url,
|
||||
download: attmt.fileName
|
||||
}).text(attmt.fileName);
|
||||
},
|
||||
|
||||
renderBody: function(tryHtml) {
|
||||
var page = $(this.el),
|
||||
emailBody = this.model.body;
|
||||
|
@ -28,6 +28,6 @@
|
||||
},
|
||||
"sandbox": {
|
||||
"pages": ["sandbox.html", "mail-content.html"],
|
||||
"content_security_policy": "sandbox allow-scripts; default-src 'self'; object-src 'none'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src *"
|
||||
"content_security_policy": "sandbox allow-scripts; default-src 'self'; object-src 'none'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src *; frame-src *"
|
||||
}
|
||||
}
|
@ -27,5 +27,9 @@
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li id="attachmentItem">
|
||||
<a id="attachmentBtn" data-role="button">Download Attachment</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div><!-- /content -->
|
Loading…
Reference in New Issue
Block a user