mirror of
https://github.com/moparisthebest/mail
synced 2024-11-29 20:32:15 -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) {
|
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);
|
attachments.push(gottenAttachment);
|
||||||
itemCounter++;
|
itemCounter++;
|
||||||
check();
|
check();
|
||||||
|
@ -34,9 +34,33 @@ define(['jquery', 'underscore', 'backbone', 'js/app-config'], function($, _, Bac
|
|||||||
$(this.el).html(this.template(params));
|
$(this.el).html(this.template(params));
|
||||||
this.renderBody();
|
this.renderBody();
|
||||||
|
|
||||||
|
// set download link for attachment button
|
||||||
|
this.parseAttachments();
|
||||||
|
|
||||||
return this;
|
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) {
|
renderBody: function(tryHtml) {
|
||||||
var page = $(this.el),
|
var page = $(this.el),
|
||||||
emailBody = this.model.body;
|
emailBody = this.model.body;
|
||||||
|
@ -28,6 +28,6 @@
|
|||||||
},
|
},
|
||||||
"sandbox": {
|
"sandbox": {
|
||||||
"pages": ["sandbox.html", "mail-content.html"],
|
"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 *"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,6 +26,10 @@
|
|||||||
<iframe src="mail-content.html" sandbox="allow-scripts" id="mailContentFrame" frameborder="0"></iframe>
|
<iframe src="mail-content.html" sandbox="allow-scripts" id="mailContentFrame" frameborder="0"></iframe>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li id="attachmentItem">
|
||||||
|
<a id="attachmentBtn" data-role="button">Download Attachment</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div><!-- /content -->
|
</div><!-- /content -->
|
Loading…
Reference in New Issue
Block a user