mirror of
https://github.com/moparisthebest/mail
synced 2024-12-21 23:08:50 -05:00
prefill compose view for replying works
This commit is contained in:
parent
7e137549d0
commit
ebbb16866a
@ -8,7 +8,8 @@
|
||||
'compose': 'compose',
|
||||
'accounts/:userId/folders': 'folders',
|
||||
'accounts/:userId/folders/:folder': 'messagelist',
|
||||
'accounts/:userId/folders/:folder/read/:messageId': 'read'
|
||||
'accounts/:userId/folders/:folder/read/:messageId': 'read',
|
||||
'accounts/:userId/folders/:folder/reply/:messageId': 'compose'
|
||||
},
|
||||
|
||||
initialize: function() {},
|
||||
|
@ -18,6 +18,11 @@
|
||||
|
||||
page.html(this.template());
|
||||
|
||||
// prefill fields for reply
|
||||
if (this.replyTo) {
|
||||
self.fillFields();
|
||||
}
|
||||
|
||||
page.find('#sendBtn').on('vmousedown', function() {
|
||||
self.sendEmail();
|
||||
});
|
||||
@ -25,6 +30,33 @@
|
||||
return this;
|
||||
},
|
||||
|
||||
fillFields: function() {
|
||||
var page = $(this.el),
|
||||
re = this.replyTo,
|
||||
from = re.get('from')[0],
|
||||
subject = re.get('subject');
|
||||
|
||||
// fill recipient field
|
||||
var replyToAddress = from.address;
|
||||
page.find('#toInput').val(replyToAddress);
|
||||
|
||||
// fill subject
|
||||
subject = 'Re: ' + ((subject) ? subject.replace('Re: ', '') : '');
|
||||
page.find('#subjectInput').val(subject);
|
||||
|
||||
// fill text body
|
||||
var body = '\n\n' + re.get('sentDate') + ' ' + from.name + ' <' + from.address + '>\n';
|
||||
var bodyRows = re.get('body').split('\n');
|
||||
var isHtml = false;
|
||||
_.each(bodyRows, function(row) {
|
||||
if (row.indexOf('<') === 0) {
|
||||
isHtml = true;
|
||||
}
|
||||
body += (!isHtml) ? '> ' + row + '\n' : '';
|
||||
});
|
||||
page.find('#bodyTextarea').text(body);
|
||||
},
|
||||
|
||||
/**
|
||||
* Send an email via the email dao
|
||||
*/
|
||||
@ -44,7 +76,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var signature = '\n\nSent with whiteout.io - get your mailbox for end-2-end encrypted messaging!\nhttps://mail.whiteout.io';
|
||||
var signature = '\n\nSent with whiteout mail - get your free mailbox for end-2-end encrypted messaging!\nhttps://mail.whiteout.io';
|
||||
|
||||
var email = new app.model.Email({
|
||||
from: self.dao.account.get('emailAddress'),
|
||||
@ -60,7 +92,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
//window.history.back();
|
||||
window.history.back();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,12 @@
|
||||
},
|
||||
|
||||
render: function(eventName) {
|
||||
$(this.el).html(this.template(this.model.toJSON()));
|
||||
var params = this.model.toJSON();
|
||||
params.account = this.options.dao.account.get('emailAddress');
|
||||
params.folder = this.options.folder;
|
||||
params.id = encodeURIComponent(params.id);
|
||||
|
||||
$(this.el).html(this.template(params));
|
||||
this.renderBody();
|
||||
|
||||
return this;
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div data-role="header" data-position="fixed">
|
||||
<input type="button" id="backBtn" data-icon="arrow-l" value="Back" class="ui-btn-left">
|
||||
<h1><%- subject %></h1>
|
||||
<a href="#compose" data-role="button" data-icon="back" data-iconpos="right" class="ui-btn-right">Reply</a>
|
||||
<a href="#accounts/<%- account %>/folders/<%- folder %>/reply/<%- id %>" data-role="button" data-icon="back" data-iconpos="right" class="ui-btn-right">Reply</a>
|
||||
</div><!-- /header -->
|
||||
|
||||
<div data-role="content">
|
||||
|
Loading…
Reference in New Issue
Block a user