Monotone-Parent: 7f76103f70f06e2d9d23dda324c36f84d85eae1c
Monotone-Revision: 2b96d00aec89e2290a01e1ee04bdc8cee5487139 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-08-23T20:58:41 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
aa9312f278
commit
a2b5a5b4bb
15
ChangeLog
15
ChangeLog
|
@ -1,5 +1,20 @@
|
|||
2010-08-23 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* UI/WebServerResources/UIxMailEditor.js: (clickEditorSend): make
|
||||
use of the iframe hack for receiving the POST's response and
|
||||
interpret it as JSON, with error handling.
|
||||
|
||||
* UI/WebServerResources/HTMLElement.js: (Element.allTextContent):
|
||||
fetch the concatenated text content of the all the child nodes of
|
||||
the element, recursively.
|
||||
|
||||
* UI/WebServerResources/MailerUI.js: (initMailer): use
|
||||
"UserSettings" only if we are the main window.
|
||||
|
||||
* UI/MailerUI/UIxMailEditor.m (-sendAction): return a json
|
||||
representation of the success of the operation, with a message if
|
||||
an exception was returned.
|
||||
|
||||
* UI/WebServerResources/MailerUI.js: (mailListToggleMessagesRead):
|
||||
new method, spun from "mailListMarkMessage", which is basically
|
||||
replaces in a more generic way by acting on all selected messages
|
||||
|
|
|
@ -587,33 +587,38 @@ static NSArray *infoKeys = nil;
|
|||
return error;
|
||||
}
|
||||
|
||||
- (id <WOActionResults>) sendAction
|
||||
- (WOResponse *) sendAction
|
||||
{
|
||||
id <WOActionResults> result;
|
||||
SOGoDraftObject *co;
|
||||
NSDictionary *jsonResponse;
|
||||
NSException *error;
|
||||
|
||||
co = [self clientObject];
|
||||
|
||||
// TODO: need to validate whether we have a To etc
|
||||
|
||||
/* first, save form data */
|
||||
result = (id <WOActionResults>) [self validateForSend];
|
||||
if (!result)
|
||||
error = [self validateForSend];
|
||||
if (!error)
|
||||
{
|
||||
if ([self _saveFormInfo])
|
||||
{
|
||||
result = (id <WOActionResults>) [[self clientObject] sendMail];
|
||||
if (!result)
|
||||
{
|
||||
co = [self clientObject];
|
||||
result = [self jsCloseWithRefreshMethod: [NSString stringWithFormat: @"refreshMessage(\"%@\", %i)",
|
||||
[co sourceFolder],
|
||||
[co IMAP4ID]]];
|
||||
}
|
||||
}
|
||||
error = [co sendMail];
|
||||
else
|
||||
result = [self failedToSaveFormResponse];
|
||||
error = [self failedToSaveFormResponse];
|
||||
}
|
||||
|
||||
return result;
|
||||
if (error)
|
||||
jsonResponse = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"failure", @"status",
|
||||
[error reason], @"message",
|
||||
nil];
|
||||
else
|
||||
jsonResponse = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"success", @"status",
|
||||
[co sourceFolder], @"sourceFolder",
|
||||
[co IMAP4ID], @"messageID",
|
||||
nil];
|
||||
|
||||
return [self responseWithStatus: 200
|
||||
andString: [jsonResponse jsonRepresentation]];
|
||||
}
|
||||
|
||||
@end /* UIxMailEditor */
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
class="textField"
|
||||
var:value="subject"
|
||||
/></div>
|
||||
<!-- separator line --><hr/>
|
||||
<!-- separator line --><hr class="fieldSeparator"/>
|
||||
</div>
|
||||
<textarea id="text" name="text" rows="30" var:value="text"></textarea>
|
||||
<!-- img rsrc:src="tbird_073_compose.png" alt="screenshot" / -->
|
||||
|
|
|
@ -8,7 +8,22 @@ Element.addMethods({
|
|||
if (element.bind)
|
||||
element.bind();
|
||||
},
|
||||
|
||||
|
||||
allTextContent: function(element) {
|
||||
var content = "";
|
||||
for (var i = 0; i < element.childNodes.length; i++) {
|
||||
var node = $(element.childNodes[i]);
|
||||
if (node.nodeType == Node.TEXT_NODE) {
|
||||
content += node.nodeValue;
|
||||
}
|
||||
else if (node.nodeType == Node.ELEMENT_NODE) {
|
||||
content += Element.allTextContent(node);
|
||||
}
|
||||
}
|
||||
|
||||
return content;
|
||||
},
|
||||
|
||||
childNodesWithTag: function(element, tagName) {
|
||||
element = $(element);
|
||||
|
||||
|
|
|
@ -1679,18 +1679,18 @@ function openInbox(node) {
|
|||
}
|
||||
|
||||
function initMailer(event) {
|
||||
// Restore sorting from user settings
|
||||
if (UserSettings["Mail"] && UserSettings["Mail"]["SortingState"]) {
|
||||
sorting["attribute"] = UserSettings["Mail"]["SortingState"][0];
|
||||
sorting["ascending"] = parseInt(UserSettings["Mail"]["SortingState"][1]) > 0;
|
||||
if (sorting["attribute"] == 'to') sorting["attribute"] = 'from'; // initial mailbox is always the inbox
|
||||
}
|
||||
else {
|
||||
sorting["attribute"] = "date";
|
||||
sorting["ascending"] = false;
|
||||
}
|
||||
|
||||
if (!$(document.body).hasClassName("popup")) {
|
||||
// Restore sorting from user settings
|
||||
if (UserSettings && UserSettings["Mail"] && UserSettings["Mail"]["SortingState"]) {
|
||||
sorting["attribute"] = UserSettings["Mail"]["SortingState"][0];
|
||||
sorting["ascending"] = parseInt(UserSettings["Mail"]["SortingState"][1]) > 0;
|
||||
if (sorting["attribute"] == 'to') sorting["attribute"] = 'from'; // initial mailbox is always the inbox
|
||||
}
|
||||
else {
|
||||
sorting["attribute"] = "date";
|
||||
sorting["ascending"] = false;
|
||||
}
|
||||
|
||||
Mailer.dataTable = $("mailboxList");
|
||||
Mailer.dataTable.addInterface(SOGoDataTableInterface);
|
||||
Mailer.dataTable.setRowRenderCallback(messageListCallback);
|
||||
|
|
|
@ -98,7 +98,7 @@ div#attachmentsArea
|
|||
margin: auto;
|
||||
border-left: 1px solid #888; }
|
||||
|
||||
hr
|
||||
hr.fieldSeparator
|
||||
{ background-color: #848284;
|
||||
border: 0;
|
||||
clear: both;
|
||||
|
|
|
@ -106,7 +106,7 @@ function insertContact(inputNode, contactName, contactEmail) {
|
|||
|
||||
/* mail editor */
|
||||
|
||||
function validateEditorInput(sender) {
|
||||
function validateEditorInput() {
|
||||
var errortext = "";
|
||||
var field;
|
||||
|
||||
|
@ -125,26 +125,63 @@ function validateEditorInput(sender) {
|
|||
return true;
|
||||
}
|
||||
|
||||
function clickedEditorSend(sender) {
|
||||
if (document.pageform.action == "send" || !validateEditorInput(sender))
|
||||
return false;
|
||||
function onValidate(event) {
|
||||
var rc = false;
|
||||
|
||||
var input = currentAttachmentInput();
|
||||
if (input)
|
||||
input.parentNode.removeChild(input);
|
||||
if (document.pageform.action != "send"
|
||||
&& validateEditorInput()) {
|
||||
var input = currentAttachmentInput();
|
||||
if (input)
|
||||
input.parentNode.removeChild(input);
|
||||
|
||||
var toolbar = document.getElementById("toolbar");
|
||||
if (!document.busyAnim)
|
||||
document.busyAnim = startAnimation(toolbar);
|
||||
var toolbar = document.getElementById("toolbar");
|
||||
if (!document.busyAnim)
|
||||
document.busyAnim = startAnimation(toolbar);
|
||||
|
||||
var lastRow = $("lastRow");
|
||||
lastRow.down("select").name = "popup_last";
|
||||
var lastRow = $("lastRow");
|
||||
lastRow.down("select").name = "popup_last";
|
||||
|
||||
window.shouldPreserve = true;
|
||||
document.pageform.action = "send";
|
||||
document.pageform.submit();
|
||||
|
||||
return false;
|
||||
window.shouldPreserve = true;
|
||||
|
||||
document.pageform.action = "send";
|
||||
|
||||
AIM.submit(document.pageform, {'onComplete' : onPostComplete});
|
||||
|
||||
rc = true;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
function onPostComplete(response) {
|
||||
if (response && response.length > 0) {
|
||||
var jsonResponse = response.evalJSON();
|
||||
if (jsonResponse["status"] == "success") {
|
||||
if (window.opener && window.opener.refreshMessage) {
|
||||
window.opener.refreshMessage(jsonResponse["sourceFolder"],
|
||||
jsonResponse["messageID"]);
|
||||
}
|
||||
window.close();
|
||||
}
|
||||
else {
|
||||
var message = jsonResponse["message"];
|
||||
document.pageform.action = "";
|
||||
var progressImage = $("progressIndicator");
|
||||
if (progressImage) {
|
||||
progressImage.parentNode.removeChild(progressImage);
|
||||
}
|
||||
showAlertDialog(jsonResponse["message"]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
function clickedEditorSend() {
|
||||
if (onValidate()) {
|
||||
document.pageform.submit();
|
||||
}
|
||||
}
|
||||
|
||||
function currentAttachmentInput() {
|
||||
|
@ -161,7 +198,7 @@ function currentAttachmentInput() {
|
|||
return input;
|
||||
}
|
||||
|
||||
function clickedEditorAttach(sender) {
|
||||
function clickedEditorAttach() {
|
||||
var input = currentAttachmentInput();
|
||||
if (!input) {
|
||||
var area = $("attachmentsArea");
|
||||
|
@ -214,7 +251,7 @@ function createAttachment(node, list) {
|
|||
attachment.appendChild(attachmentName);
|
||||
}
|
||||
|
||||
function clickedEditorSave(sender) {
|
||||
function clickedEditorSave() {
|
||||
var input = currentAttachmentInput();
|
||||
if (input)
|
||||
input.parentNode.removeChild(input);
|
||||
|
|
|
@ -1718,8 +1718,9 @@ AIM = {
|
|||
if (d.location.href == "about:blank")
|
||||
return;
|
||||
|
||||
if (typeof(i.onComplete) == 'function')
|
||||
i.onComplete(d.body.innerHTML);
|
||||
if (typeof(i.onComplete) == 'function') {
|
||||
i.onComplete(Element.allTextContent(d.body));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue