Others
Others
data-toggle="modal"
id="compose-button"
class="btn btn-primary pull-right hidden">Compose</a>
((((((The compose button is not displayed on the interface by default. This is so
that it only appears once the user has authenticated. To enable this functionality
we need to remove the hidden class from the element at the same time as we remove
the hidden class from the table which displays the inbox. This means that we should
amend our handleAuthResult() function to add the following just after the
loadGmailApi() call:))))))
$('#compose-button').removeClass("hidden");
(((The Compose button will simply open a modal, which we�re also going to add
directly into the DOM.)))
<div class="modal fade" id="compose-modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-
label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">Compose</h4>
</div>
<form onsubmit="return sendEmail();">
<div class="modal-body">
<div class="form-group">
<input type="email" class="form-control" id="compose-to"
placeholder="To" required />
</div>
<div class="form-group">
<input type="text" class="form-control" id="compose-subject"
placeholder="Subject" required />
</div>
<div class="form-group">
<textarea class="form-control" id="compose-message"
placeholder="Message" rows="10" required></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-
dismiss="modal">Close</button>
<button type="submit" id="send-button" class="btn
btn-primary">Send</button>
</div>
</form>
</div>
</div>
</div>
sendMessage(
{
'To': $('#compose-to').val(),
'Subject': $('#compose-subject').val()
},
$('#compose-message').val(),
composeTidy
);
return false;
}
return sendRequest.execute(callback);
}
function composeTidy()
{
$('#compose-modal').modal('hide');
$('#compose-to').val('');
$('#compose-subject').val('');
$('#compose-message').val('');
$('#send-button').removeClass('disabled');
}
var reply_to = (getHeader(message.payload.headers, 'Reply-to') !== '' ?
getHeader(message.payload.headers, 'Reply-to') :
getHeader(message.payload.headers, 'From')).replace(/\"/g, '"');
<div class="modal-body">
<div class="form-group">
<input type="text" class="form-control" id="reply-to" disabled />
</div>
<div class="form-group">
<input type="text" class="form-control disabled" id="reply-subject"
disabled />
</div>
<div class="form-group">
<textarea class="form-control" id="reply-message" placeholder="Message"
rows="10" required></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-
dismiss="modal">Close</button>
<button type="submit" id="reply-button" class="btn
btn-primary">Send</button>
</div>
</form>
</div>
</div>
</div>
(((((The reply modal is quite similar to the compose modal. The main difference
being the hidden field which stores the message ID. This is required to thread
emails correctly in email clients � matching the subject with a �Re: � prefix is
not enough. Also we�re going to disable the To and Subject fields as they shouldn�t
be changed at this point, they are only visible to provide context. Once the reply
modal form is submitted the sendReply() function is called.))))
The reply modal is quite similar to the compose modal. The main difference being
the hidden field which stores the message ID. This is required to thread emails
correctly in email clients � matching the subject with a �Re: � prefix is not
enough. Also we�re going to disable the To and Subject fields as they shouldn�t be
changed at this point, they are only visible to provide context. Once the reply
modal form is submitted the sendReply() function is called.))))
function sendReply()
{
$('#reply-button').addClass('disabled');
sendMessage(
{
'To': $('#reply-to').val(),
'Subject': $('#reply-subject').val(),
'In-Reply-To': $('#reply-message-id').val()
},
$('#reply-message').val(),
replyTidy
);
return false;
}
$('#reply-message').val('');
$('#reply-button').removeClass('disabled');
}