2007-03-29 20:05:23 +02:00
|
|
|
/* JavaScript for SOGoMail */
|
2007-05-25 23:12:46 +02:00
|
|
|
var accounts = {};
|
|
|
|
var mailboxTree;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
|
|
|
var currentMessages = new Array();
|
2006-07-31 22:24:50 +02:00
|
|
|
var maxCachedMessages = 20;
|
2006-07-29 00:59:11 +02:00
|
|
|
var cachedMessages = new Array();
|
2007-05-25 23:12:46 +02:00
|
|
|
var currentMailbox = null;
|
2007-05-19 03:12:23 +02:00
|
|
|
|
2007-05-22 20:34:02 +02:00
|
|
|
var usersRightsWindowHeight = 320;
|
|
|
|
var usersRightsWindowWidth = 400;
|
2007-05-19 03:12:23 +02:00
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
/* mail list */
|
|
|
|
|
2006-10-03 18:27:02 +02:00
|
|
|
function openMessageWindow(msguid, url) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var wId = '';
|
|
|
|
if (msguid) {
|
|
|
|
wId += "SOGo_msg_" + msguid;
|
|
|
|
markMailReadInWindow(window, msguid);
|
|
|
|
}
|
|
|
|
var msgWin = window.open(url, wId,
|
|
|
|
"width=680,height=520,resizable=1,scrollbars=1,toolbar=0,"
|
|
|
|
+ "location=0,directories=0,status=0,menubar=0,copyhistory=0");
|
|
|
|
if (msguid) {
|
|
|
|
msgWin.messageId = msguid;
|
|
|
|
msgWin.messageURL = ApplicationBaseURL + currentMailbox + "/" + msguid;
|
|
|
|
}
|
|
|
|
msgWin.focus();
|
|
|
|
|
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onMessageDoubleClick(event) {
|
2007-05-18 19:25:58 +02:00
|
|
|
resetSelection(window);
|
|
|
|
var msguid = this.parentNode.id.substr(4);
|
|
|
|
|
|
|
|
return openMessageWindow(msguid,
|
|
|
|
ApplicationBaseURL + currentMailbox + "/"
|
|
|
|
+ msguid + "/popupview");
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleMailSelect(sender) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var row;
|
|
|
|
row = $(sender.name);
|
|
|
|
row.className = sender.checked ? "tableview_selected" : "tableview";
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function clearSearch(sender) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var searchField = window.$("search");
|
|
|
|
if (searchField) searchField.value="";
|
|
|
|
return true;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mail editor */
|
|
|
|
|
|
|
|
function validateEditorInput(sender) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var errortext = "";
|
|
|
|
var field;
|
|
|
|
|
|
|
|
field = document.pageform.subject;
|
|
|
|
if (field.value == "")
|
|
|
|
errortext = errortext + labels.error_missingsubject + "\n";
|
|
|
|
|
|
|
|
if (!UIxRecipientSelectorHasRecipients())
|
|
|
|
errortext = errortext + labels.error_missingrecipients + "\n";
|
|
|
|
|
|
|
|
if (errortext.length > 0) {
|
|
|
|
alert(labels.error_validationfailed.decodeEntities() + ":\n"
|
|
|
|
+ errortext.decodeEntities());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function clickedEditorSend(sender) {
|
2007-05-18 19:25:58 +02:00
|
|
|
if (!validateEditorInput(sender))
|
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-06-08 22:24:57 +02:00
|
|
|
document.pageform.action = "send";
|
2007-05-18 19:25:58 +02:00
|
|
|
document.pageform.submit();
|
|
|
|
// if everything is ok, close the window
|
|
|
|
return true;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function clickedEditorAttach(sender) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var urlstr;
|
|
|
|
|
|
|
|
urlstr = "viewAttachments";
|
|
|
|
window.open(urlstr, "SOGo_attach",
|
|
|
|
"width=320,height=320,resizable=1,scrollbars=1,toolbar=0," +
|
|
|
|
"location=0,directories=0,status=0,menubar=0,copyhistory=0");
|
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
|
|
|
function clickedEditorSave(sender) {
|
2007-06-08 22:24:57 +02:00
|
|
|
document.pageform.action = "save";
|
2007-05-18 19:25:58 +02:00
|
|
|
document.pageform.submit();
|
|
|
|
refreshOpener();
|
|
|
|
return true;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function clickedEditorDelete(sender) {
|
2007-06-08 22:24:57 +02:00
|
|
|
document.pageform.action = "delete";
|
2007-05-18 19:25:58 +02:00
|
|
|
document.pageform.submit();
|
|
|
|
refreshOpener();
|
|
|
|
window.close();
|
|
|
|
return true;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function openAddressbook(sender) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var urlstr;
|
|
|
|
|
|
|
|
urlstr = ApplicationBaseURL + "/../Contacts/?popup=YES";
|
|
|
|
var w = window.open(urlstr, "Addressbook",
|
|
|
|
"width=640,height=400,resizable=1,scrollbars=1,toolbar=0,"
|
|
|
|
+ "location=0,directories=0,status=0,menubar=0,copyhistory=0");
|
|
|
|
w.focus();
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-05-19 03:12:23 +02:00
|
|
|
function onMenuSharing(event) {
|
|
|
|
var folderID = document.menuTarget.getAttribute("dataname");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/acls";
|
2007-06-12 21:25:46 +02:00
|
|
|
preventDefault(event);
|
2007-05-19 03:12:23 +02:00
|
|
|
|
|
|
|
openAclWindow(urlstr);
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
/* mail list DOM changes */
|
|
|
|
|
|
|
|
function markMailInWindow(win, msguid, markread) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var msgDiv;
|
|
|
|
|
|
|
|
msgDiv = win.$("div_" + msguid);
|
|
|
|
if (msgDiv) {
|
|
|
|
if (markread) {
|
|
|
|
msgDiv.removeClassName("mailer_unreadmailsubject");
|
|
|
|
msgDiv.addClassName("mailer_readmailsubject");
|
|
|
|
msgDiv = win.$("unreaddiv_" + msguid);
|
|
|
|
if (msgDiv)
|
|
|
|
{
|
|
|
|
msgDiv.setAttribute("class", "mailerUnreadIcon");
|
|
|
|
msgDiv.setAttribute("id", "readdiv_" + msguid);
|
|
|
|
msgDiv.setAttribute("src", ResourcesURL + "/icon_read.gif");
|
|
|
|
msgDiv.setAttribute("onclick", "mailListMarkMessage(this,"
|
|
|
|
+ " 'markMessageUnread', " + msguid
|
|
|
|
+ ", false);"
|
|
|
|
+" return false;");
|
|
|
|
var title = msgDiv.getAttribute("title-markunread");
|
|
|
|
if (title)
|
|
|
|
msgDiv.setAttribute("title", title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msgDiv.removeClassName('mailer_readmailsubject');
|
|
|
|
msgDiv.addClassName('mailer_unreadmailsubject');
|
|
|
|
msgDiv = win.$("readdiv_" + msguid);
|
|
|
|
if (msgDiv)
|
|
|
|
{
|
|
|
|
msgDiv.setAttribute("class", "mailerReadIcon");
|
|
|
|
msgDiv.setAttribute("id", "unreaddiv_" + msguid);
|
|
|
|
msgDiv.setAttribute("src", ResourcesURL + "/icon_unread.gif");
|
|
|
|
msgDiv.setAttribute("onclick", "mailListMarkMessage(this,"
|
|
|
|
+ " 'markMessageRead', " + msguid
|
|
|
|
+ ", true);"
|
|
|
|
+" return false;");
|
|
|
|
var title = msgDiv.getAttribute("title-markread");
|
|
|
|
if (title)
|
|
|
|
msgDiv.setAttribute("title", title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function markMailReadInWindow(win, msguid) {
|
2007-05-18 19:25:58 +02:00
|
|
|
/* this is called by UIxMailView with window.opener */
|
|
|
|
return markMailInWindow(win, msguid, true);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* main window */
|
|
|
|
|
|
|
|
function reopenToRemoveLocationBar() {
|
2007-05-18 19:25:58 +02:00
|
|
|
// we cannot really use this, see below at the close comment
|
|
|
|
if (window.locationbar && window.locationbar.visible) {
|
|
|
|
newwin = window.open(window.location.href, "SOGo",
|
|
|
|
"width=800,height=600,resizable=1,scrollbars=1," +
|
|
|
|
"toolbar=0,location=0,directories=0,status=0," +
|
|
|
|
"menubar=0,copyhistory=0");
|
|
|
|
if (newwin) {
|
|
|
|
window.close(); // this does only work for windows opened by scripts!
|
|
|
|
newwin.focus();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mail list reply */
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function openMessageWindowsForSelection(action) {
|
2007-05-18 19:25:58 +02:00
|
|
|
if (document.body.hasClassName("popup"))
|
|
|
|
win = openMessageWindow(window.messageId,
|
|
|
|
window.messageURL + "/" + action /* url */);
|
|
|
|
else {
|
|
|
|
var messageList = $("messageList");
|
|
|
|
var rows = messageList.getSelectedRowsId();
|
|
|
|
var idset = "";
|
|
|
|
for (var i = 0; i < rows.length; i++)
|
|
|
|
win = openMessageWindow(rows[i].substr(4) /* msguid */,
|
|
|
|
ApplicationBaseURL + currentMailbox
|
|
|
|
+ "/" + rows[i].substr(4)
|
|
|
|
+ "/" + action /* url */);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function mailListMarkMessage(event) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var http = createHTTPClient();
|
|
|
|
var url = ApplicationBaseURL + currentMailbox + "/" + action + "?uid=" + msguid;
|
|
|
|
|
|
|
|
if (http) {
|
|
|
|
// TODO: add parameter to signal that we are only interested in OK
|
|
|
|
http.open("POST", url + "&jsonly=1", false /* not async */);
|
|
|
|
http.send("");
|
|
|
|
if (http.status != 200) {
|
|
|
|
// TODO: refresh page?
|
|
|
|
alert("Message Mark Failed: " + http.statusText);
|
|
|
|
window.location.reload();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
markMailInWindow(window, msguid, markread);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.location.href = url;
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* maillist row highlight */
|
|
|
|
|
|
|
|
var oldMaillistHighlight = null; // to remember deleted/selected style
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function ml_highlight(sender) {
|
2007-05-18 19:25:58 +02:00
|
|
|
oldMaillistHighlight = sender.className;
|
|
|
|
if (oldMaillistHighlight == "tableview_highlight")
|
|
|
|
oldMaillistHighlight = null;
|
|
|
|
sender.className = "tableview_highlight";
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
2006-08-01 20:01:00 +02:00
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function ml_lowlight(sender) {
|
2007-05-18 19:25:58 +02:00
|
|
|
if (oldMaillistHighlight) {
|
|
|
|
sender.className = oldMaillistHighlight;
|
|
|
|
oldMaillistHighlight = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sender.className = "tableview";
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* folder operations */
|
|
|
|
|
|
|
|
function ctxFolderAdd(sender) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var folderName;
|
|
|
|
|
|
|
|
folderName = prompt("Foldername: ");
|
|
|
|
if (folderName == undefined)
|
|
|
|
return false;
|
|
|
|
if (folderName == "")
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// TODO: should use a form-POST or AJAX
|
|
|
|
window.location.href = "createFolder?name=" + escape(folderName);
|
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function ctxFolderDelete(sender) {
|
2007-05-18 19:25:58 +02:00
|
|
|
if (!confirm("Delete current folder?").decodeEntities())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// TODO: should use a form-POST or AJAX
|
|
|
|
window.location.href = "deleteFolder";
|
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* bulk delete of messages */
|
|
|
|
|
|
|
|
function uixDeleteSelectedMessages(sender) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var failCount = 0;
|
|
|
|
|
|
|
|
var messageList = $("messageList");
|
|
|
|
var rowIds = messageList.getSelectedRowsId();
|
|
|
|
|
|
|
|
for (var i = 0; i < rowIds.length; i++) {
|
|
|
|
var url, http;
|
|
|
|
var rowId = rowIds[i].substr(4);
|
|
|
|
/* send AJAX request (synchronously) */
|
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
var messageId = currentMailbox + "/" + rowId;
|
2007-05-18 19:25:58 +02:00
|
|
|
url = ApplicationBaseURL + messageId + "/trash?jsonly=1";
|
|
|
|
http = createHTTPClient();
|
|
|
|
http.open("GET", url, false /* not async */);
|
|
|
|
http.send("");
|
|
|
|
if (http.status != 200) { /* request failed */
|
|
|
|
failCount++;
|
2006-07-29 00:59:11 +02:00
|
|
|
http = null;
|
|
|
|
continue;
|
2007-05-18 19:25:58 +02:00
|
|
|
} else {
|
|
|
|
deleteCachedMessage(messageId);
|
|
|
|
if (currentMessages[currentMailbox] == rowId) {
|
|
|
|
var div = $('messageContent');
|
|
|
|
div.innerHTML = "";
|
|
|
|
currentMessages[currentMailbox] = null;
|
|
|
|
}
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
2007-05-18 19:25:58 +02:00
|
|
|
http = null;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
/* remove from page */
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
/* line-through would be nicer, but hiding is OK too */
|
|
|
|
var row = $(rowIds[i]);
|
|
|
|
row.parentNode.removeChild(row);
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
if (failCount > 0)
|
|
|
|
alert("Could not delete " + failCount + " messages!");
|
|
|
|
|
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2006-11-10 23:59:39 +01:00
|
|
|
function moveMessages(rowIds, folder) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var failCount = 0;
|
|
|
|
|
|
|
|
for (var i = 0; i < rowIds.length; i++) {
|
|
|
|
var url, http;
|
|
|
|
|
|
|
|
/* send AJAX request (synchronously) */
|
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
var messageId = currentMailbox + "/" + rowIds[i];
|
2007-05-18 19:25:58 +02:00
|
|
|
url = ApplicationBaseURL + messageId + "/move?jsonly=1&tofolder=" + folder;
|
|
|
|
http = createHTTPClient();
|
|
|
|
http.open("GET", url, false /* not async */);
|
|
|
|
http.send("");
|
|
|
|
if (http.status == 200) {
|
|
|
|
var row = $("row_" + rowIds[i]);
|
|
|
|
row.parentNode.removeChild(row);
|
|
|
|
deleteCachedMessage(messageId);
|
|
|
|
if (currentMessages[currentMailbox] == rowIds[i]) {
|
|
|
|
var div = $('messageContent');
|
|
|
|
div.innerHTML = "";
|
|
|
|
currentMessages[currentMailbox] = null;
|
|
|
|
}
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
2007-05-18 19:25:58 +02:00
|
|
|
else /* request failed */
|
|
|
|
failCount++;
|
2006-11-10 23:59:39 +01:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
/* remove from page */
|
2006-11-10 23:59:39 +01:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
/* line-through would be nicer, but hiding is OK too */
|
|
|
|
}
|
2006-11-10 23:59:39 +01:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
if (failCount > 0)
|
|
|
|
alert("Could not move " + failCount + " messages!");
|
|
|
|
|
|
|
|
return failCount;
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
|
|
|
|
2006-11-10 00:11:50 +01:00
|
|
|
function onMenuDeleteMessage(event) {
|
2007-05-18 19:25:58 +02:00
|
|
|
uixDeleteSelectedMessages();
|
2007-06-12 21:25:46 +02:00
|
|
|
preventDefault(event);
|
2006-11-10 00:11:50 +01:00
|
|
|
}
|
|
|
|
|
2006-12-22 17:48:11 +01:00
|
|
|
function onMailboxTreeItemClick(event) {
|
2007-05-25 23:12:46 +02:00
|
|
|
var topNode = $("mailboxTree");
|
2007-05-18 19:25:58 +02:00
|
|
|
var mailbox = this.parentNode.getAttribute("dataname");
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
if (topNode.selectedEntry)
|
2007-05-18 19:25:58 +02:00
|
|
|
topNode.selectedEntry.deselect();
|
|
|
|
this.select();
|
|
|
|
topNode.selectedEntry = this;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
var datatype = this.parentNode.getAttribute("datatype");
|
|
|
|
if (datatype == "account" || datatype == "additional") {
|
|
|
|
currentMailbox = mailbox;
|
|
|
|
$("messageContent").innerHTML = "";
|
|
|
|
var body = $("messageList").tBodies[0];
|
|
|
|
for (var i = body.rows.length - 1; i > 0; i--)
|
|
|
|
body.deleteRow(i);
|
|
|
|
}
|
|
|
|
else
|
2007-05-18 19:25:58 +02:00
|
|
|
openMailbox(mailbox);
|
2007-05-25 23:12:46 +02:00
|
|
|
|
2007-06-12 21:25:46 +02:00
|
|
|
preventDefault(event);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
function onMailboxMenuMove() {
|
|
|
|
window.alert("unimplemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMailboxMenuCopy() {
|
|
|
|
window.alert("unimplemented");
|
|
|
|
}
|
|
|
|
|
2007-05-04 17:57:23 +02:00
|
|
|
function _refreshWindowMailbox() {
|
|
|
|
openMailbox(currentMailbox, true);
|
|
|
|
}
|
2006-11-13 23:29:31 +01:00
|
|
|
|
2007-05-04 17:57:23 +02:00
|
|
|
function refreshMailbox() {
|
|
|
|
var topWindow = getTopWindow();
|
|
|
|
if (topWindow)
|
|
|
|
topWindow._refreshWindowMailbox();
|
2007-05-25 23:12:46 +02:00
|
|
|
|
2007-05-04 17:57:23 +02:00
|
|
|
return false;
|
2006-11-13 23:29:31 +01:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:14:57 +02:00
|
|
|
function openMailbox(mailbox, reload) {
|
2007-05-18 19:25:58 +02:00
|
|
|
if (mailbox != currentMailbox || reload) {
|
|
|
|
currentMailbox = mailbox;
|
|
|
|
var url = ApplicationBaseURL + mailbox + "/view?noframe=1&desc=1";
|
|
|
|
var mailboxContent = $("mailboxContent");
|
|
|
|
var rightDragHandle = $("rightDragHandle");
|
|
|
|
var messageContent = $("messageContent");
|
|
|
|
messageContent.innerHTML = '';
|
|
|
|
if (mailbox.lastIndexOf("/") == 0) {
|
|
|
|
var url = (ApplicationBaseURL + currentMailbox + "/"
|
|
|
|
+ "/view?noframe=1");
|
|
|
|
if (document.messageAjaxRequest) {
|
|
|
|
document.messageAjaxRequest.aborted = true;
|
|
|
|
document.messageAjaxRequest.abort();
|
2007-06-11 23:14:57 +02:00
|
|
|
}
|
2007-05-18 19:25:58 +02:00
|
|
|
document.messageAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, messageCallback);
|
|
|
|
mailboxContent.innerHTML = '';
|
|
|
|
mailboxContent.style.visibility = "hidden;";
|
|
|
|
rightDragHandle.style.visibility = "hidden;";
|
|
|
|
messageContent.style.top = "0px;";
|
|
|
|
} else {
|
|
|
|
if (document.messageListAjaxRequest) {
|
|
|
|
document.messageListAjaxRequest.aborted = true;
|
|
|
|
document.messageListAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
if (currentMessages[mailbox]) {
|
|
|
|
loadMessage(currentMessages[mailbox]);
|
|
|
|
url += '&pageforuid=' + currentMessages[mailbox];
|
2007-06-11 23:14:57 +02:00
|
|
|
}
|
2007-05-18 19:25:58 +02:00
|
|
|
document.messageListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, messageListCallback,
|
|
|
|
currentMessages[mailbox]);
|
2007-06-08 22:24:57 +02:00
|
|
|
if (mailboxContent.getStyle('visibility') == "hidden") {
|
|
|
|
mailboxContent.setStyle({ visibility: "visible" });
|
|
|
|
rightDragHandle.setStyle({ visibility: "visible" });
|
|
|
|
messageContent.setStyle({ top: (rightDragHandle.offsetTop
|
|
|
|
+ rightDragHandle.offsetHeight
|
|
|
|
+ 'px') });
|
2007-05-18 19:25:58 +02:00
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
2007-05-18 19:25:58 +02:00
|
|
|
}
|
|
|
|
// triggerAjaxRequest(mailbox, 'toolbar', toolbarCallback);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-06-04 22:01:53 +02:00
|
|
|
function openMailboxAtIndex(event) {
|
|
|
|
var idx = this.getAttribute("idx");
|
2007-05-18 19:25:58 +02:00
|
|
|
var url = ApplicationBaseURL + currentMailbox + "/view?noframe=1&idx=" + idx;
|
2006-07-31 22:24:50 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
if (document.messageListAjaxRequest) {
|
|
|
|
document.messageListAjaxRequest.aborted = true;
|
|
|
|
document.messageListAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.messageListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, messageListCallback);
|
2006-11-09 00:49:09 +01:00
|
|
|
|
2007-06-08 22:24:57 +02:00
|
|
|
preventDefault(event);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function messageListCallback(http) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var div = $('mailboxContent');
|
2007-06-08 22:24:57 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.messageListAjaxRequest = null;
|
|
|
|
div.innerHTML = http.responseText;
|
|
|
|
var selected = http.callbackData;
|
|
|
|
if (selected) {
|
|
|
|
var row = $('row_' + selected);
|
|
|
|
row.select();
|
|
|
|
}
|
|
|
|
configureMessageListEvents();
|
|
|
|
configureSortableTableHeaders();
|
|
|
|
}
|
|
|
|
else
|
2007-06-08 22:24:57 +02:00
|
|
|
log("messageListCallback: problem during ajax request (readyState = " + http.readyState + ", status = " + http.status + ")");
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onMessageContextMenu(event) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var menu = $('messageListMenu');
|
|
|
|
Event.observe(menu, "hideMenu", onMessageContextMenuHide);
|
|
|
|
popupMenu(event, "messageListMenu", this);
|
2006-08-01 22:03:50 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
var topNode = $('messageList');
|
|
|
|
var selectedNodes = topNode.getSelectedRows();
|
|
|
|
for (var i = 0; i < selectedNodes.length; i++)
|
|
|
|
selectedNodes[i].deselect();
|
|
|
|
topNode.menuSelectedRows = selectedNodes;
|
|
|
|
topNode.menuSelectedEntry = this;
|
|
|
|
this.select();
|
2006-08-01 22:03:50 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onMessageContextMenuHide(event) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var topNode = $('messageList');
|
2006-08-02 22:04:46 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
if (topNode.menuSelectedEntry) {
|
|
|
|
topNode.menuSelectedEntry.deselect();
|
|
|
|
topNode.menuSelectedEntry = null;
|
|
|
|
}
|
|
|
|
if (topNode.menuSelectedRows) {
|
|
|
|
var nodes = topNode.menuSelectedRows;
|
|
|
|
for (var i = 0; i < nodes.length; i++)
|
|
|
|
nodes[i].select();
|
|
|
|
topNode.menuSelectedRows = null;
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onFolderMenuClick(event) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var onhide, menuName;
|
|
|
|
|
|
|
|
var menutype = this.parentNode.getAttribute("datatype");
|
|
|
|
if (menutype) {
|
|
|
|
if (menutype == "inbox") {
|
|
|
|
menuName = "inboxIconMenu";
|
|
|
|
} else if (menutype == "account") {
|
|
|
|
menuName = "accountIconMenu";
|
|
|
|
} else if (menutype == "trash") {
|
|
|
|
menuName = "trashIconMenu";
|
|
|
|
} else {
|
|
|
|
menuName = "mailboxIconMenu";
|
|
|
|
}
|
|
|
|
} else {
|
2006-12-22 23:13:53 +01:00
|
|
|
menuName = "mailboxIconMenu";
|
2007-05-18 19:25:58 +02:00
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
var menu = $(menuName);
|
|
|
|
Event.observe(menu, "hideMenu", onFolderMenuHide);
|
|
|
|
popupMenu(event, menuName, this.parentNode);
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
var topNode = $("mailboxTree");
|
2007-05-18 19:25:58 +02:00
|
|
|
if (topNode.selectedEntry)
|
|
|
|
topNode.selectedEntry.deselect();
|
|
|
|
if (topNode.menuSelectedEntry)
|
|
|
|
topNode.menuSelectedEntry.deselect();
|
|
|
|
topNode.menuSelectedEntry = this;
|
|
|
|
this.select();
|
2007-05-25 23:12:46 +02:00
|
|
|
|
2007-06-12 21:25:46 +02:00
|
|
|
preventDefault(event);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onFolderMenuHide(event) {
|
2007-05-25 23:12:46 +02:00
|
|
|
var topNode = $("mailboxTree");
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
if (topNode.menuSelectedEntry) {
|
|
|
|
topNode.menuSelectedEntry.deselect();
|
|
|
|
topNode.menuSelectedEntry = null;
|
|
|
|
}
|
|
|
|
if (topNode.selectedEntry)
|
|
|
|
topNode.selectedEntry.select();
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2006-11-10 23:59:39 +01:00
|
|
|
function deleteCachedMessage(messageId) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var done = false;
|
|
|
|
var counter = 0;
|
|
|
|
|
|
|
|
while (counter < cachedMessages.length
|
|
|
|
&& !done)
|
|
|
|
if (cachedMessages[counter]
|
|
|
|
&& cachedMessages[counter]['idx'] == messageId) {
|
|
|
|
cachedMessages.splice(counter, 1);
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
counter++;
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function getCachedMessage(idx) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var message = null;
|
|
|
|
var counter = 0;
|
|
|
|
|
|
|
|
while (counter < cachedMessages.length
|
|
|
|
&& message == null)
|
|
|
|
if (cachedMessages[counter]
|
|
|
|
&& cachedMessages[counter]['idx'] == currentMailbox + '/' + idx)
|
|
|
|
message = cachedMessages[counter];
|
|
|
|
else
|
|
|
|
counter++;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
return message;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function storeCachedMessage(cachedMessage) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var oldest = -1;
|
|
|
|
var timeOldest = -1;
|
|
|
|
var counter = 0;
|
|
|
|
|
|
|
|
if (cachedMessages.length < maxCachedMessages)
|
|
|
|
oldest = cachedMessages.length;
|
|
|
|
else {
|
|
|
|
while (cachedMessages[counter]) {
|
|
|
|
if (oldest == -1
|
|
|
|
|| cachedMessages[counter]['time'] < timeOldest) {
|
|
|
|
oldest = counter;
|
|
|
|
timeOldest = cachedMessages[counter]['time'];
|
|
|
|
}
|
|
|
|
counter++;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
if (oldest == -1)
|
|
|
|
oldest = 0;
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
cachedMessages[oldest] = cachedMessage;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onMessageSelectionChange() {
|
2007-05-18 19:25:58 +02:00
|
|
|
var rows = this.getSelectedRowsId();
|
2007-06-08 22:24:57 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
if (rows.length == 1) {
|
|
|
|
var idx = rows[0].substr(4);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
if (currentMessages[currentMailbox] != idx) {
|
|
|
|
currentMessages[currentMailbox] = idx;
|
|
|
|
loadMessage(idx);
|
|
|
|
}
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function loadMessage(idx) {
|
2007-05-18 19:25:58 +02:00
|
|
|
if (document.messageAjaxRequest) {
|
|
|
|
document.messageAjaxRequest.aborted = true;
|
|
|
|
document.messageAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
var cachedMessage = getCachedMessage(idx);
|
|
|
|
|
|
|
|
if (cachedMessage == null) {
|
|
|
|
var url = (ApplicationBaseURL + currentMailbox + "/"
|
|
|
|
+ idx + "/view?noframe=1");
|
|
|
|
document.messageAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, messageCallback, idx);
|
|
|
|
markMailInWindow(window, idx, true);
|
|
|
|
} else {
|
|
|
|
var div = $('messageContent');
|
|
|
|
div.innerHTML = cachedMessage['text'];
|
|
|
|
cachedMessage['time'] = (new Date()).getTime();
|
|
|
|
document.messageAjaxRequest = null;
|
|
|
|
configureLinksInMessage();
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-05-16 18:35:09 +02:00
|
|
|
function configureLinksInMessage() {
|
2007-05-17 19:25:45 +02:00
|
|
|
var messageDiv = $('messageContent');
|
|
|
|
var mailContentDiv = document.getElementsByClassName('mailer_mailcontent',
|
|
|
|
messageDiv)[0];
|
2007-06-12 21:15:11 +02:00
|
|
|
Event.observe(mailContentDiv, "contextmenu", onMessageContentMenu.bindAsEventListener(mailContentDiv));
|
2007-05-17 19:25:45 +02:00
|
|
|
var anchors = messageDiv.getElementsByTagName('a');
|
2007-05-15 22:52:38 +02:00
|
|
|
for (var i = 0; i < anchors.length; i++)
|
2007-05-16 23:42:47 +02:00
|
|
|
if (anchors[i].href.substring(0,7) == "mailto:") {
|
2007-06-08 22:24:57 +02:00
|
|
|
Event.observe(anchors[i], "click", onEmailAddressClick.bindAsEventListener(anchors[i]));
|
|
|
|
Event.observe(anchors[i], "contextmenu", onEmailAddressClick.bindAsEventListener(anchors[i]));
|
2007-05-16 23:42:47 +02:00
|
|
|
}
|
|
|
|
else
|
2007-05-18 19:25:58 +02:00
|
|
|
Event.observe(anchors[i], "click", onMessageAnchorClick);
|
2007-05-16 23:42:47 +02:00
|
|
|
}
|
|
|
|
|
2007-05-17 19:25:45 +02:00
|
|
|
function onMessageContentMenu(event) {
|
2007-05-18 19:25:58 +02:00
|
|
|
popupMenu(event, 'messageContentMenu', this);
|
|
|
|
}
|
2007-05-17 19:25:45 +02:00
|
|
|
|
2007-05-16 23:42:47 +02:00
|
|
|
function onEmailAddressClick(event) {
|
2007-05-18 19:25:58 +02:00
|
|
|
popupMenu(event, 'addressMenu', this);
|
2007-05-15 22:52:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onMessageAnchorClick (event) {
|
|
|
|
window.open(this.href);
|
2007-06-08 22:24:57 +02:00
|
|
|
preventDefault(event);
|
2007-05-15 22:52:38 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function messageCallback(http) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var div = $('messageContent');
|
|
|
|
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.messageAjaxRequest = null;
|
|
|
|
div.innerHTML = http.responseText;
|
|
|
|
configureLinksInMessage();
|
2007-06-08 22:24:57 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
if (http.callbackData) {
|
|
|
|
var cachedMessage = new Array();
|
|
|
|
cachedMessage['idx'] = currentMailbox + '/' + http.callbackData;
|
|
|
|
cachedMessage['time'] = (new Date()).getTime();
|
|
|
|
cachedMessage['text'] = http.responseText;
|
|
|
|
if (cachedMessage['text'].length < 30000)
|
|
|
|
storeCachedMessage(cachedMessage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-06-12 21:15:11 +02:00
|
|
|
log("messageCallback: problem during ajax request: " + http.status);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function processMailboxMenuAction(mailbox) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var currentNode, upperNode;
|
|
|
|
var mailboxName;
|
|
|
|
var action;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
mailboxName = mailbox.getAttribute('mailboxname');
|
|
|
|
currentNode = mailbox;
|
|
|
|
upperNode = null;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
while (currentNode
|
|
|
|
&& !currentNode.hasAttribute('mailboxaction'))
|
|
|
|
currentNode = currentNode.parentNode.parentNode.parentMenuItem;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
if (currentNode)
|
|
|
|
{
|
2006-07-29 00:59:11 +02:00
|
|
|
action = currentNode.getAttribute('mailboxaction');
|
2007-05-18 19:25:58 +02:00
|
|
|
// var rows = collectSelectedRows();
|
|
|
|
// var rString = rows.join(', ');
|
|
|
|
// alert("performing '" + action + "' on " + rString
|
|
|
|
// + " to " + mailboxName);
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var rowSelectionCount = 0;
|
|
|
|
|
|
|
|
validateControls();
|
|
|
|
|
|
|
|
function showElement(e, shouldShow) {
|
2007-05-18 19:25:58 +02:00
|
|
|
e.style.display = shouldShow ? "" : "none";
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function enableElement(e, shouldEnable) {
|
2007-05-18 19:25:58 +02:00
|
|
|
if(!e)
|
|
|
|
return;
|
|
|
|
if(shouldEnable) {
|
|
|
|
if(e.hasAttribute("disabled"))
|
|
|
|
e.removeAttribute("disabled");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
e.setAttribute("disabled", "1");
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function validateControls() {
|
2007-05-18 19:25:58 +02:00
|
|
|
var e = $("moveto");
|
|
|
|
this.enableElement(e, rowSelectionCount > 0);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function moveTo(uri) {
|
2007-05-18 19:25:58 +02:00
|
|
|
alert("MoveTo: " + uri);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function deleteSelectedMails() {
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* message menu entries */
|
2007-03-19 15:31:49 +01:00
|
|
|
function onMenuOpenMessage(event) {
|
2007-05-04 05:12:24 +02:00
|
|
|
return openMessageWindowsForSelection('popupview');
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuReplyToSender(event) {
|
|
|
|
return openMessageWindowsForSelection('reply');
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuReplyToAll(event) {
|
|
|
|
return openMessageWindowsForSelection('replyall');
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-04 05:12:24 +02:00
|
|
|
function onMenuForwardMessage(event) {
|
|
|
|
return openMessageWindowsForSelection('forward');
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* contacts */
|
2007-05-18 19:25:58 +02:00
|
|
|
function newContactFromEmail(event) {
|
|
|
|
var mailto = document.menuTarget.innerHTML;
|
|
|
|
|
|
|
|
// var emailre
|
|
|
|
// = /([a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])/g;
|
|
|
|
// emailre.exec(mailto);
|
|
|
|
// email = RegExp.$1;
|
|
|
|
|
|
|
|
// var namere = /(\w[\w\ _-]+)\ (<|<)/;
|
|
|
|
// var c_name = '';
|
|
|
|
// if (namere.test(mailto)) {
|
|
|
|
// namere.exec(mailto);
|
|
|
|
// c_name += RegExp.$1;
|
|
|
|
// }
|
|
|
|
|
|
|
|
var email = extractEmailAddress(mailto);
|
|
|
|
var c_name = extractEmailName(mailto);
|
|
|
|
if (email.length > 0)
|
|
|
|
{
|
2006-09-19 23:11:53 +02:00
|
|
|
var url = UserFolderURL + "Contacts/new?contactEmail=" + email;
|
|
|
|
if (c_name)
|
2007-05-18 19:25:58 +02:00
|
|
|
url += "&contactFN=" + c_name;
|
2006-09-19 23:11:53 +02:00
|
|
|
w = window.open(url, null,
|
|
|
|
"width=546,height=490,resizable=1,scrollbars=1,toolbar=0,"
|
|
|
|
+ "location=0,directories=0,status=0,menubar=0,copyhistory=0");
|
2006-07-29 00:59:11 +02:00
|
|
|
w.focus();
|
2007-05-18 19:25:58 +02:00
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
|
|
|
function newEmailTo(sender) {
|
2007-05-18 19:25:58 +02:00
|
|
|
return openMailTo(document.menuTarget.innerHTML);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function expandUpperTree(node) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var currentNode = node.parentNode;
|
2006-07-31 22:24:50 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
while (currentNode.className != "dtree") {
|
2007-04-06 23:30:13 +02:00
|
|
|
if (currentNode.className == 'clip') {
|
|
|
|
var id = currentNode.getAttribute("id");
|
|
|
|
var number = parseInt(id.substr(2));
|
|
|
|
if (number > 0) {
|
2007-05-25 23:12:46 +02:00
|
|
|
var cn = mailboxTree.aNodes[number];
|
|
|
|
mailboxTree.nodeStatus(1, number, cn._ls);
|
2007-04-06 23:30:13 +02:00
|
|
|
}
|
|
|
|
}
|
2006-07-31 22:24:50 +02:00
|
|
|
currentNode = currentNode.parentNode;
|
2007-05-18 19:25:58 +02:00
|
|
|
}
|
2006-07-31 22:24:50 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onHeaderClick(event) {
|
2007-05-18 19:25:58 +02:00
|
|
|
if (document.messageListAjaxRequest) {
|
|
|
|
document.messageListAjaxRequest.aborted = true;
|
|
|
|
document.messageListAjaxRequest.abort();
|
|
|
|
}
|
2007-06-12 20:20:16 +02:00
|
|
|
var link = this.getAttribute('href');
|
|
|
|
url = ApplicationBaseURL + currentMailbox + "/" + link;
|
|
|
|
if (!link.match(/noframe=/))
|
2007-05-18 19:25:58 +02:00
|
|
|
url += "&noframe=1";
|
|
|
|
document.messageListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, messageListCallback);
|
2006-08-01 20:01:00 +02:00
|
|
|
|
2007-06-12 20:20:16 +02:00
|
|
|
preventDefault(event);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
2006-08-31 01:13:28 +02:00
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onSearchFormSubmit() {
|
2007-05-28 15:18:31 +02:00
|
|
|
log("search not implemented");
|
2006-08-31 01:13:28 +02:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
return false;
|
2006-08-31 01:13:28 +02:00
|
|
|
}
|
2006-10-23 16:56:32 +02:00
|
|
|
|
2006-11-09 00:49:09 +01:00
|
|
|
function pouetpouet(event) {
|
2007-05-18 19:25:58 +02:00
|
|
|
window.alert("pouet pouet");
|
2006-11-09 00:49:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var mailboxSpanAcceptType = function(type) {
|
2007-05-18 19:25:58 +02:00
|
|
|
return (type == "mailRow");
|
2006-11-09 00:49:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var mailboxSpanEnter = function() {
|
2007-05-18 19:25:58 +02:00
|
|
|
this.addClassName("_dragOver");
|
2006-11-09 00:49:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var mailboxSpanExit = function() {
|
2007-05-18 19:25:58 +02:00
|
|
|
this.removeClassName("_dragOver");
|
2006-11-09 00:49:09 +01:00
|
|
|
}
|
|
|
|
|
2006-11-10 23:59:39 +01:00
|
|
|
var mailboxSpanDrop = function(data) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var success = false;
|
2006-11-10 23:59:39 +01:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
if (data) {
|
|
|
|
var folder = this.parentNode.parentNode.getAttribute("dataname");
|
|
|
|
if (folder != currentMailbox)
|
|
|
|
success = (moveMessages(data, folder) == 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
success = false;
|
2006-11-10 23:59:39 +01:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
return success;
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var plusSignEnter = function() {
|
2007-05-18 19:25:58 +02:00
|
|
|
var nodeNr = parseInt(this.id.substr(2));
|
2007-05-25 23:12:46 +02:00
|
|
|
if (!mailboxTree.aNodes[nodeNr]._io)
|
|
|
|
this.plusSignTimer = setTimeout("openPlusSign('" + nodeNr + "');", 1000);
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var plusSignExit = function() {
|
2007-05-18 19:25:58 +02:00
|
|
|
if (this.plusSignTimer) {
|
|
|
|
clearTimeout(this.plusSignTimer);
|
|
|
|
this.plusSignTimer = null;
|
|
|
|
}
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function openPlusSign(nodeNr) {
|
2007-05-25 23:12:46 +02:00
|
|
|
mailboxTree.nodeStatus(1, nodeNr, mailboxTree.aNodes[nodeNr]._ls);
|
|
|
|
mailboxTree.aNodes[nodeNr]._io = 1;
|
2007-05-18 19:25:58 +02:00
|
|
|
this.plusSignTimer = null;
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
|
|
|
|
2006-11-09 00:49:09 +01:00
|
|
|
var messageListGhost = function () {
|
2007-05-18 19:25:58 +02:00
|
|
|
var newDiv = document.createElement("div");
|
|
|
|
// newDiv.style.width = "25px;";
|
|
|
|
// newDiv.style.height = "25px;";
|
|
|
|
newDiv.style.backgroundColor = "#aae;";
|
|
|
|
newDiv.style.border = "2px solid #a3a;";
|
|
|
|
newDiv.style.padding = "5px;";
|
|
|
|
newDiv.ghostOffsetX = 10;
|
|
|
|
newDiv.ghostOffsetY = 5;
|
2006-11-09 00:49:09 +01:00
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
var newImg = document.createElement("img");
|
|
|
|
newImg.src = ResourcesURL + "/message-mail.png";
|
2006-11-13 23:29:31 +01:00
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
var list = $("messageList");
|
|
|
|
var count = list.getSelectedRows().length;
|
|
|
|
newDiv.appendChild(newImg);
|
|
|
|
newDiv.appendChild(document.createElement("br"));
|
|
|
|
newDiv.appendChild(document.createTextNode(count + " messages..."));
|
2006-11-09 00:49:09 +01:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
return newDiv;
|
2006-11-09 00:49:09 +01:00
|
|
|
}
|
|
|
|
|
2006-11-10 23:59:39 +01:00
|
|
|
var messageListData = function(type) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var rows = this.parentNode.parentNode.getSelectedRowsId();
|
|
|
|
var msgIds = new Array();
|
|
|
|
for (var i = 0; i < rows.length; i++)
|
|
|
|
msgIds.push(rows[i].substr(4));
|
2006-11-10 23:59:39 +01:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
return msgIds;
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function configureMessageListEvents() {
|
2007-05-18 19:25:58 +02:00
|
|
|
var messageList = $("messageList");
|
|
|
|
if (messageList) {
|
2007-06-14 00:06:01 +02:00
|
|
|
Event.observe(messageList, "mousedown",
|
|
|
|
onMessageSelectionChange.bindAsEventListener(messageList));
|
|
|
|
var cell = messageList.tHead.rows[1].cells[0];
|
|
|
|
if ($(cell).hasClassName("tbtv_navcell")) {
|
|
|
|
var anchors = $(cell).childNodesWithTag("a");
|
|
|
|
for (var i = 0; i < anchors.length; i++)
|
|
|
|
Event.observe(anchors[i], "click", openMailboxAtIndex.bindAsEventListener(anchors[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
rows = messageList.tBodies[0].rows;
|
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
Event.observe(rows[i], "mousedown", onRowClick);
|
|
|
|
Event.observe(rows[i], "contextmenu", onMessageContextMenu.bindAsEventListener(rows[i]));
|
|
|
|
|
|
|
|
rows[i].dndTypes = function() { return new Array("mailRow"); };
|
|
|
|
rows[i].dndGhost = messageListGhost;
|
|
|
|
rows[i].dndDataForType = messageListData;
|
|
|
|
document.DNDManager.registerSource(rows[i]);
|
|
|
|
|
|
|
|
for (var j = 0; j < rows[i].cells.length; j++) {
|
|
|
|
var cell = rows[i].cells[j];
|
|
|
|
Event.observe(cell, "mousedown", listRowMouseDownHandler);
|
|
|
|
if (j == 2 || j == 3 || j == 5)
|
|
|
|
Event.observe(cell, "dblclick", onMessageDoubleClick.bindAsEventListener(cell));
|
|
|
|
else if (j == 4) {
|
|
|
|
var img = cell.childNodesWithTag("img")[0];
|
|
|
|
Event.observe(img, "click", mailListMarkMessage);
|
2007-05-18 19:25:58 +02:00
|
|
|
}
|
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
2007-05-18 19:25:58 +02:00
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
|
|
|
|
2006-12-22 17:48:11 +01:00
|
|
|
function configureDragHandles() {
|
2007-05-18 19:25:58 +02:00
|
|
|
var handle = $("verticalDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.leftBlock=$("leftPanel");
|
|
|
|
handle.rightBlock=$("rightPanel");
|
|
|
|
}
|
2006-12-22 17:48:11 +01:00
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.upperBlock=$("mailboxContent");
|
|
|
|
handle.lowerBlock=$("messageContent");
|
|
|
|
}
|
2006-12-22 17:48:11 +01:00
|
|
|
}
|
|
|
|
|
2006-11-09 00:49:09 +01:00
|
|
|
/* dnd */
|
|
|
|
function initDnd() {
|
2007-05-28 15:18:31 +02:00
|
|
|
// log("MailerUI initDnd");
|
2007-05-18 19:25:58 +02:00
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
var tree = $("mailboxTree");
|
2007-05-18 19:25:58 +02:00
|
|
|
if (tree) {
|
|
|
|
var images = tree.getElementsByTagName("img");
|
|
|
|
for (var i = 0; i < images.length; i++) {
|
|
|
|
if (images[i].id[0] == 'j') {
|
|
|
|
images[i].dndAcceptType = mailboxSpanAcceptType;
|
|
|
|
images[i].dndEnter = plusSignEnter;
|
|
|
|
images[i].dndExit = plusSignExit;
|
|
|
|
document.DNDManager.registerDestination(images[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var nodes = document.getElementsByClassName("nodeName", tree);
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
nodes[i].dndAcceptType = mailboxSpanAcceptType;
|
|
|
|
nodes[i].dndEnter = mailboxSpanEnter;
|
|
|
|
nodes[i].dndExit = mailboxSpanExit;
|
|
|
|
nodes[i].dndDrop = mailboxSpanDrop;
|
|
|
|
document.DNDManager.registerDestination(nodes[i]);
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
2007-05-18 19:25:58 +02:00
|
|
|
}
|
2006-11-09 00:49:09 +01:00
|
|
|
}
|
|
|
|
|
2006-10-23 16:56:32 +02:00
|
|
|
/* stub */
|
|
|
|
|
|
|
|
function refreshContacts() {
|
|
|
|
}
|
|
|
|
|
2006-12-22 23:13:53 +01:00
|
|
|
function openInbox(node) {
|
2007-05-18 19:25:58 +02:00
|
|
|
var done = false;
|
|
|
|
openMailbox(node.parentNode.getAttribute("dataname"));
|
2007-05-25 23:12:46 +02:00
|
|
|
var tree = $("mailboxTree");
|
2007-05-18 19:25:58 +02:00
|
|
|
tree.selectedEntry = node;
|
|
|
|
node.select();
|
2007-05-25 23:12:46 +02:00
|
|
|
mailboxTree.o(1);
|
2006-12-22 23:13:53 +01:00
|
|
|
}
|
|
|
|
|
2007-03-22 22:14:17 +01:00
|
|
|
function configureSearchField() {
|
|
|
|
var searchValue = $("searchValue");
|
2006-12-22 17:48:11 +01:00
|
|
|
|
2007-06-08 22:24:57 +02:00
|
|
|
Event.observe(searchValue, "mousedown", onSearchMouseDown.bindAsEventListener(searchValue));
|
|
|
|
Event.observe(searchValue, "click", popupSearchMenu.bindAsEventListener(searchValue));
|
|
|
|
Event.observe(searchValue, "blur", onSearchBlur.bindAsEventListener(searchValue));
|
|
|
|
Event.observe(searchValue, "focus", onSearchFocus.bindAsEventListener(searchValue));
|
|
|
|
Event.observe(searchValue, "keydown", onSearchKeyDown.bindAsEventListener(searchValue));
|
2007-05-18 19:25:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function initMailer(event) {
|
|
|
|
if (!document.body.hasClassName("popup")) {
|
|
|
|
configureSearchField();
|
|
|
|
configureMessageListEvents();
|
|
|
|
initDnd();
|
2007-05-25 23:12:46 +02:00
|
|
|
currentMailbox = "/" + accounts[0] + "/INBOX";
|
|
|
|
initMailboxTree();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function initMailboxTree() {
|
|
|
|
mailboxTree = new dTree("mailboxTree");
|
|
|
|
mailboxTree.config.folderLinks = true;
|
|
|
|
mailboxTree.config.hideRoot = true;
|
|
|
|
|
|
|
|
mailboxTree.icon.root = ResourcesURL + "/tbtv_account_17x17.gif";
|
|
|
|
mailboxTree.icon.folder = ResourcesURL + "/tbtv_leaf_corner_17x17.gif";
|
|
|
|
mailboxTree.icon.folderOpen = ResourcesURL + "/tbtv_leaf_corner_17x17.gif";
|
|
|
|
mailboxTree.icon.node = ResourcesURL + "/tbtv_leaf_corner_17x17.gif";
|
|
|
|
mailboxTree.icon.line = ResourcesURL + "/tbtv_line_17x17.gif";
|
|
|
|
mailboxTree.icon.join = ResourcesURL + "/tbtv_junction_17x17.gif";
|
|
|
|
mailboxTree.icon.joinBottom = ResourcesURL + "/tbtv_corner_17x17.gif";
|
|
|
|
mailboxTree.icon.plus = ResourcesURL + "/tbtv_plus_17x17.gif";
|
|
|
|
mailboxTree.icon.plusBottom = ResourcesURL + "/tbtv_corner_plus_17x17.gif";
|
|
|
|
mailboxTree.icon.minus = ResourcesURL + "/tbtv_minus_17x17.gif";
|
|
|
|
mailboxTree.icon.minusBottom = ResourcesURL + "/tbtv_corner_minus_17x17.gif";
|
|
|
|
mailboxTree.icon.nlPlus = ResourcesURL + "/tbtv_corner_plus_17x17.gif";
|
|
|
|
mailboxTree.icon.nlMinus = ResourcesURL + "/tbtv_corner_minus_17x17.gif";
|
|
|
|
mailboxTree.icon.empty = ResourcesURL + "/empty.gif";
|
|
|
|
|
|
|
|
mailboxTree.add(0, -1, '');
|
|
|
|
|
|
|
|
mailboxTree.pendingRequests = mailAccounts.length;
|
|
|
|
for (var i = 0; i < mailAccounts.length; i++) {
|
|
|
|
var url = ApplicationBaseURL + "/" + mailAccounts[i] + "/mailboxes";
|
|
|
|
triggerAjaxRequest(url, onLoadMailboxesCallback, mailAccounts[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateMailboxTreeInPage() {
|
|
|
|
$("folderTreeContent").innerHTML = mailboxTree;
|
|
|
|
|
|
|
|
var inboxFound = false;
|
|
|
|
var tree = $("mailboxTree");
|
|
|
|
var nodes = document.getElementsByClassName("node", tree);
|
|
|
|
for (i = 0; i < nodes.length; i++) {
|
2007-05-28 18:12:06 +02:00
|
|
|
Event.observe(nodes[i], "click", onMailboxTreeItemClick.bindAsEventListener(nodes[i]));
|
|
|
|
Event.observe(nodes[i], "contextmenu", onFolderMenuClick.bindAsEventListener(nodes[i]));
|
2007-05-25 23:12:46 +02:00
|
|
|
if (!inboxFound
|
|
|
|
&& nodes[i].parentNode.getAttribute("datatype") == "inbox") {
|
|
|
|
openInbox(nodes[i]);
|
|
|
|
inboxFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mailboxMenuNode(type, name) {
|
|
|
|
var newNode = document.createElement("li");
|
|
|
|
var icon = MailerUIdTreeExtension.folderIcons[type];
|
|
|
|
if (!icon)
|
|
|
|
icon = "tbtv_leaf_corner_17x17.gif";
|
|
|
|
var image = document.createElement("img");
|
|
|
|
image.src = ResourcesURL + "/" + icon;
|
|
|
|
newNode.appendChild(image);
|
|
|
|
newNode.appendChild(document.createTextNode(" " + name));
|
|
|
|
|
|
|
|
return newNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
function generateMenuForMailbox(mailbox, prefix, callback) {
|
|
|
|
var menuDIV = document.createElement("div");
|
2007-06-08 22:24:57 +02:00
|
|
|
$(menuDIV).addClassName("menu");
|
2007-05-25 23:12:46 +02:00
|
|
|
menuDIV.setAttribute("id", prefix + "Submenu");
|
|
|
|
var menu = document.createElement("ul");
|
|
|
|
menuDIV.appendChild(menu);
|
|
|
|
|
|
|
|
var callbacks = new Array();
|
|
|
|
if (mailbox.type != "account") {
|
|
|
|
var newNode = document.createElement("li");
|
|
|
|
newNode.mailbox = mailbox;
|
|
|
|
newNode.appendChild(document.createTextNode("coucou"));
|
|
|
|
menu.appendChild(newNode);
|
|
|
|
menu.appendChild(document.createElement("li"));
|
|
|
|
callbacks.push(callback);
|
|
|
|
callbacks.push("-");
|
|
|
|
}
|
|
|
|
|
|
|
|
var submenuCount = 0;
|
|
|
|
for (var i = 0; i < mailbox.children.length; i++) {
|
|
|
|
var child = mailbox.children[i];
|
|
|
|
var newNode = mailboxMenuNode(child.type, child.name);
|
|
|
|
menu.appendChild(newNode);
|
|
|
|
if (child.children.length > 0) {
|
|
|
|
var newPrefix = prefix + submenuCount;
|
|
|
|
var newSubmenu = generateMenuForMailbox(child,
|
|
|
|
newPrefix,
|
|
|
|
callback);
|
|
|
|
document.body.appendChild(newSubmenu);
|
|
|
|
callbacks.push(newPrefix + "Submenu");
|
|
|
|
submenuCount++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newNode.mailbox = child;
|
|
|
|
callbacks.push(callback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
initMenu(menuDIV, callbacks);
|
|
|
|
|
|
|
|
return menuDIV;
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateMailboxMenus() {
|
|
|
|
var mailboxActions = { move: onMailboxMenuMove,
|
|
|
|
copy: onMailboxMenuCopy };
|
|
|
|
|
|
|
|
for (key in mailboxActions) {
|
|
|
|
var menuId = key + "MailboxMenu";
|
|
|
|
var menuDIV = $(menuId);
|
|
|
|
if (menuDIV)
|
|
|
|
menuDIV.parentNode.removeChild(menuDIV);
|
2007-06-08 22:24:57 +02:00
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
menuDIV = document.createElement("div");
|
2007-06-08 22:24:57 +02:00
|
|
|
document.body.appendChild(menuDIV);
|
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
var menu = document.createElement("ul");
|
|
|
|
menuDIV.appendChild(menu);
|
|
|
|
|
2007-06-08 22:24:57 +02:00
|
|
|
$(menuDIV).addClassName("menu");
|
|
|
|
menuDIV.setAttribute("id", menuId);
|
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
var submenuIds = new Array();
|
|
|
|
for (var i = 0; i < mailAccounts.length; i++) {
|
2007-06-08 22:24:57 +02:00
|
|
|
var menuEntry = mailboxMenuNode("account", mailAccounts[i]);
|
2007-05-25 23:12:46 +02:00
|
|
|
menu.appendChild(menuEntry);
|
|
|
|
var mailbox = accounts[mailAccounts[i]];
|
|
|
|
var newSubmenu = generateMenuForMailbox(mailbox,
|
|
|
|
key, mailboxActions[key]);
|
|
|
|
document.body.appendChild(newSubmenu);
|
|
|
|
submenuIds.push(newSubmenu.getAttribute("id"));
|
|
|
|
}
|
|
|
|
initMenu(menuDIV, submenuIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onLoadMailboxesCallback(http) {
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
var newAccount = buildMailboxes(http.callbackData,
|
|
|
|
http.responseText);
|
|
|
|
accounts[http.callbackData] = newAccount;
|
|
|
|
mailboxTree.addMailAccount(newAccount);
|
|
|
|
mailboxTree.pendingRequests--;
|
|
|
|
if (!mailboxTree.pendingRequests) {
|
2007-06-08 22:24:57 +02:00
|
|
|
updateMailboxTreeInPage();
|
|
|
|
updateMailboxMenus();
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
2007-05-28 15:18:31 +02:00
|
|
|
}
|
2007-05-25 23:12:46 +02:00
|
|
|
|
|
|
|
// var tree = $("mailboxTree");
|
|
|
|
// var treeNodes = document.getElementsByClassName("dTreeNode", tree);
|
|
|
|
// var i = 0;
|
|
|
|
// while (i < treeNodes.length
|
|
|
|
// && treeNodes[i].getAttribute("dataname") != currentMailbox)
|
|
|
|
// i++;
|
|
|
|
// if (i < treeNodes.length) {
|
2007-05-28 15:18:31 +02:00
|
|
|
// // log("found mailbox");
|
2007-05-25 23:12:46 +02:00
|
|
|
// var links = document.getElementsByClassName("node", treeNodes[i]);
|
|
|
|
// if (tree.selectedEntry)
|
|
|
|
// tree.selectedEntry.deselect();
|
|
|
|
// links[0].select();
|
|
|
|
// tree.selectedEntry = links[0];
|
|
|
|
// expandUpperTree(links[0]);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
function buildMailboxes(accountName, encoded) {
|
|
|
|
var account = new Mailbox("account", accountName);
|
|
|
|
var data = encoded.evalJSON(true);
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
|
var currentNode = account;
|
|
|
|
var names = data[i].path.split("/");
|
|
|
|
for (var j = 1; j < (names.length - 1); j++) {
|
|
|
|
var node = currentNode.findMailboxByName(names[j]);
|
|
|
|
if (!node) {
|
|
|
|
node = new Mailbox("additional", names[j]);
|
|
|
|
currentNode.addMailbox(node);
|
2007-03-22 22:14:17 +01:00
|
|
|
}
|
2007-05-25 23:12:46 +02:00
|
|
|
currentNode = node;
|
|
|
|
}
|
|
|
|
var basename = names[names.length-1];
|
|
|
|
var leaf = currentNode.findMailboxByName(basename);
|
|
|
|
if (leaf)
|
|
|
|
leaf.type = data[i].type;
|
|
|
|
else {
|
|
|
|
leaf = new Mailbox(data[i].type, basename);
|
|
|
|
currentNode.addMailbox(leaf);
|
2007-03-22 22:14:17 +01:00
|
|
|
}
|
|
|
|
}
|
2007-05-25 23:12:46 +02:00
|
|
|
|
|
|
|
return account;
|
2006-11-09 00:49:09 +01:00
|
|
|
}
|
|
|
|
|
2007-05-28 15:18:31 +02:00
|
|
|
function onMenuCreateFolder(event) {
|
2007-05-28 18:02:46 +02:00
|
|
|
var name = window.prompt(labels["Name :"].decodeEntities(), "");
|
2007-05-28 15:18:31 +02:00
|
|
|
if (name && name.length > 0) {
|
|
|
|
var folderID = document.menuTarget.getAttribute("dataname");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/createFolder?name=" + name;
|
|
|
|
triggerAjaxRequest(urlstr, folderOperationCallback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuRenameFolder(event) {
|
2007-05-28 18:02:46 +02:00
|
|
|
var name = window.prompt(labels["Enter the new name of your folder :"]
|
|
|
|
.decodeEntities(),
|
2007-05-28 15:18:31 +02:00
|
|
|
"");
|
|
|
|
if (name && name.length > 0) {
|
|
|
|
var folderID = document.menuTarget.getAttribute("dataname");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/renameFolder?name=" + name;
|
|
|
|
triggerAjaxRequest(urlstr, folderOperationCallback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuDeleteFolder(event) {
|
2007-05-28 18:02:46 +02:00
|
|
|
var answer = window.confirm(labels["Do you really want to move this folder into the trash ?"].decodeEntities());
|
2007-05-28 15:18:31 +02:00
|
|
|
if (answer) {
|
|
|
|
var folderID = document.menuTarget.getAttribute("dataname");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/deleteFolder";
|
|
|
|
triggerAjaxRequest(urlstr, folderOperationCallback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-28 21:05:00 +02:00
|
|
|
function onMenuEmptyTrash(event) {
|
|
|
|
var folderID = document.menuTarget.getAttribute("dataname");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/emptyTrash";
|
|
|
|
triggerAjaxRequest(urlstr, folderOperationCallback);
|
|
|
|
}
|
|
|
|
|
2007-05-28 15:18:31 +02:00
|
|
|
function folderOperationCallback(http) {
|
|
|
|
if (http.readyState == 4
|
2007-05-28 18:02:46 +02:00
|
|
|
&& http.status == 204)
|
2007-05-28 15:18:31 +02:00
|
|
|
initMailboxTree();
|
|
|
|
else
|
2007-05-28 18:02:46 +02:00
|
|
|
window.alert(labels["Operation failed"].decodeEntities());
|
2007-05-28 15:18:31 +02:00
|
|
|
}
|
|
|
|
|
2007-05-28 21:19:17 +02:00
|
|
|
function getMenus() {
|
|
|
|
var menus = {}
|
2007-05-28 15:18:31 +02:00
|
|
|
menus["accountIconMenu"] = new Array(null, null, onMenuCreateFolder, null,
|
|
|
|
null, null);
|
|
|
|
menus["inboxIconMenu"] = new Array(null, null, null, "-", null,
|
|
|
|
onMenuCreateFolder, null, "-", null,
|
|
|
|
onMenuSharing);
|
|
|
|
menus["trashIconMenu"] = new Array(null, null, null, "-", null,
|
|
|
|
onMenuCreateFolder, null,
|
2007-05-28 21:05:00 +02:00
|
|
|
onMenuEmptyTrash, "-", null,
|
|
|
|
onMenuSharing);
|
2007-05-28 15:18:31 +02:00
|
|
|
menus["mailboxIconMenu"] = new Array(null, null, null, "-", null,
|
|
|
|
onMenuCreateFolder,
|
|
|
|
onMenuRenameFolder,
|
|
|
|
null, onMenuDeleteFolder, "-", null,
|
2007-05-22 16:38:54 +02:00
|
|
|
onMenuSharing);
|
2007-05-18 19:25:58 +02:00
|
|
|
menus["addressMenu"] = new Array(newContactFromEmail, newEmailTo, null);
|
|
|
|
menus["messageListMenu"] = new Array(onMenuOpenMessage, "-",
|
|
|
|
onMenuReplyToSender,
|
|
|
|
onMenuReplyToAll,
|
|
|
|
onMenuForwardMessage, null,
|
2007-05-25 23:12:46 +02:00
|
|
|
"-", "moveMailboxMenu",
|
|
|
|
"copyMailboxMenu", "label-menu",
|
2007-05-18 19:25:58 +02:00
|
|
|
"mark-menu", "-", null, null,
|
|
|
|
null, onMenuDeleteMessage);
|
|
|
|
menus["messageContentMenu"] = new Array(onMenuReplyToSender,
|
|
|
|
onMenuReplyToAll,
|
|
|
|
onMenuForwardMessage,
|
2007-05-25 23:12:46 +02:00
|
|
|
null, "moveMailboxMenu",
|
|
|
|
"copyMailboxMenu",
|
2007-05-18 19:25:58 +02:00
|
|
|
"-", "label-menu", "mark-menu",
|
2007-05-25 23:12:46 +02:00
|
|
|
"-",
|
|
|
|
null, null, null,
|
2007-05-18 19:25:58 +02:00
|
|
|
onMenuDeleteMessage);
|
|
|
|
menus["label-menu"] = new Array(null, "-", null , null, null, null , null,
|
|
|
|
null);
|
|
|
|
menus["mark-menu"] = new Array(null, null, null, null, "-", null, "-",
|
|
|
|
null, null, null);
|
2007-05-28 21:19:17 +02:00
|
|
|
|
|
|
|
return menus;
|
2007-05-18 19:25:58 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 22:24:57 +02:00
|
|
|
addEvent(window, 'load', initMailer);
|
2007-05-25 23:12:46 +02:00
|
|
|
|
|
|
|
function Mailbox(type, name) {
|
|
|
|
this.type = type;
|
|
|
|
this.name = name;
|
|
|
|
this.parentFolder = null;
|
|
|
|
this.children = new Array();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
Mailbox.prototype.dump = function(indent) {
|
|
|
|
if (!indent)
|
|
|
|
indent = 0;
|
|
|
|
log(" ".repeat(indent) + this.name);
|
|
|
|
for (var i = 0; i < this.children.length; i++) {
|
|
|
|
this.children[i].dump(indent + 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Mailbox.prototype.findMailboxByName = function(name) {
|
|
|
|
var mailbox = null;
|
|
|
|
|
|
|
|
var i = 0;
|
|
|
|
while (!mailbox && i <this.children.length)
|
|
|
|
if (this.children[i].name == name)
|
|
|
|
mailbox = this.children[i];
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
|
|
|
|
return mailbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
Mailbox.prototype.addMailbox = function(mailbox) {
|
|
|
|
mailbox.parentFolder = this;
|
|
|
|
this.children.push(mailbox);
|
|
|
|
}
|