Skip to content

Commit

Permalink
Added Attachment Delete JS code, missing API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bnvk committed Oct 17, 2014
1 parent da7a4ae commit cd58a42
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
12 changes: 6 additions & 6 deletions static/default/html/jsapi/compose/attachments.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Mailpile.Composer.Attachments.uploader = function(settings) {

var upload_image_preview = function(file) {

var item = $("<li></li>").prependTo(dom.uploads);
var item = $('<li class="compose-attachment"><a href="#" data-mid="XXX" data-aid="XXX" class="compose-attachment-remove"><span class="icon-circle-x"></span></a></li>').prependTo(dom.uploads);
var image = $(new Image()).appendTo(item);

// Create an instance of the mOxie Image object. This
Expand Down Expand Up @@ -55,7 +55,7 @@ Mailpile.Composer.Attachments.uploader = function(settings) {
mime_types: [
{title : "Audio files", extensions : "mp3,aac,flac,wav,ogg,aiff,midi"},
{title : "Document files", extensions : "pdf,doc,docx,xls,txt,rtf,ods"},
{title : "Image files", extensions : "jpg,gif,png,svg,psd,tiff,bmp,ai,sketch"},
{title : "Image files", extensions : "jpg,jpeg,gif,png,svg,psd,tiff,bmp,ai,sketch"},
{title : "Image files", extensions : "mp2,mp4,mov,avi,mkv"},
{title : "Zip files", extensions : "zip,rar"},
{title : "Crypto files", extensions : "asc,pub,key"}
Expand Down Expand Up @@ -87,13 +87,13 @@ Mailpile.Composer.Attachments.uploader = function(settings) {
upload_image_preview(file);

// Add to attachments
var attachment_html = '<li id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></li>';
var attachment_html = '<li class="compose-attachment" aid="' + file.id + '">' + file.name + ' ' + plupload.formatSize(file.size) + '</li>';
$('#compose-attachments-files').append(attachment_html);

// Show Warning for 10mb or larger
if (file.size > 10485760) {
start_upload = false;
alert(file.name + ' is ' + plupload.formatSize(file.size) + '. Some people cannot receive attachments that are 10 mb or larger');
alert(file.name + ' is ' + plupload.formatSize(file.size) + '. Some people cannot receive attachments that are 50 mb or larger');
}
});

Expand All @@ -105,8 +105,8 @@ Mailpile.Composer.Attachments.uploader = function(settings) {
$('#' + file.id).find('b').html('<span>' + file.percent + '%</span>');
},
Error: function(up, err) {
Mailpile.notations({status: 'error', message: "Error #" + err.code + ": " + err.message });
$('#' + err.file.id).find('b').html('Failed');
Mailpile.notification({status: 'error', message: "Oops, could not upload attachment because: " + err.message });
$('#' + err.file.id).find('b').html('Failed ' + err.code);
uploader.refresh();
}
}
Expand Down
6 changes: 6 additions & 0 deletions static/default/html/jsapi/compose/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ $(document).on('click', '.compose-from', function(e) {
});


$(document).on('click', '.compose-attachment-remove', function(e) {
var aid = $(this).data('aid');
var mid = $(this).data('mid');
alert('This should delete an attachment: ' + aid + ' for mid: ' + mid + ' just need API endpoint to do so');
});

/* Compose - Autogrow composer boxes */
$(document).on('focus', '.compose-text', function() {
$(this).autosize();
Expand Down
2 changes: 1 addition & 1 deletion static/default/html/partials/compose.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
{% if editing_strings.attachments %}
{% for aid, filename in editing_strings.attachments.iteritems() %}
<li class="compose-attachment">
<a href="/message/attachment/={{ mid }}/{{ aid }}/" class="compose-attachment-remove"><span class="icon-circle-x"></span></a>
<a href="#" data-mid="{{ mid }}" data-aid="{{ aid }}" class="compose-attachment-remove"><span class="icon-circle-x"></span></a>
<img src="/message/download/preview/={{ mid }}/{{ aid }}/">
<div class="compose-attachment-filename">{{filename}}</div>
</li>
Expand Down

0 comments on commit cd58a42

Please sign in to comment.