2007-03-29 20:05:23 +02:00
|
|
|
/* JavaScript for SOGoMail */
|
2007-05-25 23:12:46 +02:00
|
|
|
var accounts = {};
|
|
|
|
var mailboxTree;
|
2007-10-18 23:54:24 +02:00
|
|
|
var mailAccounts;
|
|
|
|
if (typeof textMailAccounts != 'undefined')
|
|
|
|
mailAccounts = textMailAccounts.evalJSON(true);
|
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-08-15 22:34:11 +02:00
|
|
|
var currentMailboxType = "";
|
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
|
|
|
|
2007-10-18 00:29:51 +02:00
|
|
|
var pageContent;
|
|
|
|
|
2007-10-24 17:52:08 +02:00
|
|
|
var deleteMessageRequestCount = 0;
|
|
|
|
|
2007-10-26 17:35:51 +02:00
|
|
|
var messageCheckTimer;
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
/* mail list */
|
|
|
|
|
2006-10-03 18:27:02 +02:00
|
|
|
function openMessageWindow(msguid, url) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var wId = '';
|
|
|
|
if (msguid) {
|
|
|
|
wId += "SOGo_msg_" + msguid;
|
|
|
|
markMailReadInWindow(window, msguid);
|
|
|
|
}
|
2007-08-21 18:00:25 +02:00
|
|
|
var msgWin = openMailComposeWindow(url, wId);
|
2007-07-30 17:55:28 +02:00
|
|
|
msgWin.focus();
|
|
|
|
|
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onMessageDoubleClick(event) {
|
2007-08-15 22:34:11 +02:00
|
|
|
var action;
|
|
|
|
|
|
|
|
if (currentMailboxType == "draft")
|
|
|
|
action = "edit";
|
|
|
|
else
|
|
|
|
action = "popupview";
|
|
|
|
|
|
|
|
return openMessageWindowsForSelection(action, true);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleMailSelect(sender) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var row;
|
|
|
|
row = $(sender.name);
|
|
|
|
row.className = sender.checked ? "tableview_selected" : "tableview";
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function openAddressbook(sender) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var urlstr;
|
2007-05-18 19:25:58 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
urlstr = ApplicationBaseURL + "/../Contacts/?popup=YES";
|
|
|
|
var w = window.open(urlstr, "Addressbook",
|
|
|
|
"width=640,height=400,resizable=1,scrollbars=1,toolbar=0,"
|
2007-10-18 19:19:05 +02:00
|
|
|
+ "location=no,directories=0,status=0,menubar=0,copyhistory=0");
|
2007-07-30 17:55:28 +02:00
|
|
|
w.focus();
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-05-19 03:12:23 +02:00
|
|
|
function onMenuSharing(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var folderID = document.menuTarget.getAttribute("dataname");
|
2007-10-17 00:14:50 +02:00
|
|
|
var type = document.menuTarget.getAttribute("datatype");
|
2007-10-25 21:22:07 +02:00
|
|
|
|
2007-10-17 00:14:50 +02:00
|
|
|
if (type == "additional")
|
|
|
|
window.alert(clabels["The user rights cannot be"
|
|
|
|
+ " edited for this object!"]);
|
|
|
|
else {
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/acls";
|
|
|
|
openAclWindow(urlstr);
|
|
|
|
}
|
2007-05-19 03:12:23 +02:00
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
/* mail list DOM changes */
|
|
|
|
|
|
|
|
function markMailInWindow(win, msguid, markread) {
|
2007-07-30 17:55:28 +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-07-30 17:55:28 +02:00
|
|
|
/* this is called by UIxMailView with window.opener */
|
|
|
|
return markMailInWindow(win, msguid, true);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mail list reply */
|
|
|
|
|
2007-08-15 22:34:11 +02:00
|
|
|
function openMessageWindowsForSelection(action, firstOnly) {
|
2007-10-30 22:04:11 +01:00
|
|
|
if (document.body.hasClassName("popup")) {
|
|
|
|
return true;
|
|
|
|
}
|
2007-07-30 17:55:28 +02:00
|
|
|
else {
|
|
|
|
var messageList = $("messageList");
|
|
|
|
var rows = messageList.getSelectedRowsId();
|
2007-08-15 22:34:11 +02:00
|
|
|
if (rows.length > 0) {
|
2007-10-27 00:17:29 +02:00
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
openMessageWindow(rows[i].substr(4),
|
2007-08-15 22:34:11 +02:00
|
|
|
ApplicationBaseURL + currentMailbox
|
2007-10-27 00:17:29 +02:00
|
|
|
+ "/" + rows[i].substr(4)
|
2007-08-15 22:34:11 +02:00
|
|
|
+ "/" + action);
|
2007-10-27 00:17:29 +02:00
|
|
|
if (firstOnly)
|
|
|
|
break;
|
|
|
|
}
|
2007-10-09 19:57:27 +02:00
|
|
|
} else {
|
|
|
|
window.alert(labels["Please select a message."]);
|
2007-08-15 22:34:11 +02:00
|
|
|
}
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function mailListMarkMessage(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var http = createHTTPClient();
|
2007-09-11 21:41:40 +02:00
|
|
|
var url = ApplicationBaseURL + currentMailbox + "/" + msguid + "/" + action;
|
2007-07-30 17:55:28 +02:00
|
|
|
|
|
|
|
if (http) {
|
|
|
|
// TODO: add parameter to signal that we are only interested in OK
|
2007-09-10 17:08:32 +02:00
|
|
|
http.open("POST", url, false /* not async */);
|
2007-07-30 17:55:28 +02:00
|
|
|
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-07-30 17:55:28 +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-07-30 17:55:28 +02:00
|
|
|
if (oldMaillistHighlight) {
|
|
|
|
sender.className = oldMaillistHighlight;
|
|
|
|
oldMaillistHighlight = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sender.className = "tableview";
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* bulk delete of messages */
|
|
|
|
|
2007-10-24 17:52:08 +02:00
|
|
|
function deleteSelectedMessages(sender) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var messageList = $("messageList");
|
|
|
|
var rowIds = messageList.getSelectedRowsId();
|
|
|
|
|
|
|
|
for (var i = 0; i < rowIds.length; i++) {
|
|
|
|
var url, http;
|
|
|
|
var rowId = rowIds[i].substr(4);
|
|
|
|
var messageId = currentMailbox + "/" + rowId;
|
2007-09-10 17:08:32 +02:00
|
|
|
url = ApplicationBaseURL + messageId + "/trash";
|
2007-10-24 17:52:08 +02:00
|
|
|
deleteMessageRequestCount++;
|
|
|
|
var data = { "id": rowId, "mailbox": currentMailbox, "messageId": messageId };
|
|
|
|
triggerAjaxRequest(url, deleteSelectedMessagesCallback, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteSelectedMessagesCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
var data = http.callbackData;
|
|
|
|
deleteCachedMessage(data["messageId"]);
|
|
|
|
if (currentMailbox == data["mailbox"]) {
|
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
var div = $('messageContent');
|
2007-10-24 17:52:08 +02:00
|
|
|
if (currentMessages[currentMailbox] == data["id"]) {
|
|
|
|
div.update();
|
|
|
|
currentMessages[currentMailbox] = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var row = $("row_" + data["id"]);
|
|
|
|
row.parentNode.removeChild(row);
|
2007-10-27 00:17:29 +02:00
|
|
|
// row.addClassName("deleted"); // when we'll offer "mark as deleted"
|
2007-10-24 17:52:08 +02:00
|
|
|
|
|
|
|
deleteMessageRequestCount--;
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
|
|
|
}
|
2007-10-24 17:52:08 +02:00
|
|
|
else
|
|
|
|
log ("deleteSelectedMessagesCallback: problem during ajax request " + http.status);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-10-30 20:56:50 +01:00
|
|
|
function deleteDraft(url) {
|
|
|
|
/* this is called by UIxMailEditor with window.opener */
|
|
|
|
new Ajax.Request(url, {
|
|
|
|
method: 'post',
|
|
|
|
onFailure: function(transport) {
|
|
|
|
if (!isHttpStatus204)
|
|
|
|
log("draftDeleteCallback: problem during ajax request: " + transport.status);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2006-11-10 23:59:39 +01:00
|
|
|
function moveMessages(rowIds, folder) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var failCount = 0;
|
2007-05-18 19:25:58 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
for (var i = 0; i < rowIds.length; i++) {
|
|
|
|
var url, http;
|
2007-05-18 19:25:58 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
/* send AJAX request (synchronously) */
|
2007-05-18 19:25:58 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
var messageId = currentMailbox + "/" + rowIds[i];
|
|
|
|
url = (ApplicationBaseURL + messageId
|
2007-09-10 17:08:32 +02:00
|
|
|
+ "/move?tofolder=" + folder);
|
2007-07-30 17:55:28 +02:00
|
|
|
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');
|
2007-09-14 20:20:51 +02:00
|
|
|
div.update();
|
2007-07-30 17:55:28 +02:00
|
|
|
currentMessages[currentMailbox] = null;
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
|
|
|
else /* request failed */
|
|
|
|
failCount++;
|
2006-11-10 23:59:39 +01:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
/* remove from page */
|
2006-11-10 23:59:39 +01:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
/* line-through would be nicer, but hiding is OK too */
|
|
|
|
}
|
2006-11-10 23:59:39 +01:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
if (failCount > 0)
|
|
|
|
alert("Could not move " + failCount + " messages!");
|
2007-05-18 19:25:58 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
return failCount;
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
|
|
|
|
2006-11-10 00:11:50 +01:00
|
|
|
function onMenuDeleteMessage(event) {
|
2007-10-24 17:52:08 +02:00
|
|
|
deleteSelectedMessages();
|
2007-07-30 17:55:28 +02:00
|
|
|
preventDefault(event);
|
2006-11-10 00:11:50 +01:00
|
|
|
}
|
|
|
|
|
2007-08-08 23:36:17 +02:00
|
|
|
function onPrintCurrentMessage(event) {
|
|
|
|
var rowIds = $("messageList").getSelectedRowsId();
|
|
|
|
if (rowIds.length == 0) {
|
2007-09-14 23:54:19 +02:00
|
|
|
window.alert(labels["Please select a message to print."]);
|
2007-08-08 23:36:17 +02:00
|
|
|
}
|
|
|
|
else if (rowIds.length > 1) {
|
2007-09-14 23:54:19 +02:00
|
|
|
window.alert(labels["Please select only one message to print."]);
|
2007-08-08 23:36:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
window.print();
|
|
|
|
|
|
|
|
preventDefault(event);
|
|
|
|
}
|
|
|
|
|
2006-12-22 17:48:11 +01:00
|
|
|
function onMailboxTreeItemClick(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var topNode = $("mailboxTree");
|
|
|
|
var mailbox = this.parentNode.getAttribute("dataname");
|
|
|
|
|
|
|
|
if (topNode.selectedEntry)
|
|
|
|
topNode.selectedEntry.deselect();
|
|
|
|
this.select();
|
|
|
|
topNode.selectedEntry = this;
|
|
|
|
|
|
|
|
search = {};
|
|
|
|
sorting = {};
|
|
|
|
$("searchValue").value = "";
|
|
|
|
initCriteria();
|
|
|
|
|
2007-08-15 22:34:11 +02:00
|
|
|
currentMailboxType = this.parentNode.getAttribute("datatype");
|
|
|
|
if (currentMailboxType == "account" || currentMailboxType == "additional") {
|
2007-07-30 17:55:28 +02:00
|
|
|
currentMailbox = mailbox;
|
2007-09-14 20:20:51 +02:00
|
|
|
$("messageContent").update();
|
2007-10-03 22:01:05 +02:00
|
|
|
var table = $("messageList");
|
|
|
|
var head = table.tHead;
|
|
|
|
var body = table.tBodies[0];
|
2007-08-15 22:34:11 +02:00
|
|
|
for (var i = body.rows.length; i > 0; i--)
|
|
|
|
body.deleteRow(i-1);
|
2007-10-03 22:01:05 +02:00
|
|
|
if (head.rows[1])
|
|
|
|
head.rows[1].firstChild.update();
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
openMailbox(mailbox);
|
2007-05-25 23:12:46 +02:00
|
|
|
|
2007-09-24 23:26:23 +02:00
|
|
|
Event.stop(event);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-10-18 00:29:51 +02:00
|
|
|
function _onMailboxMenuAction(menuEntry, error, actionName) {
|
|
|
|
var targetMailbox = menuEntry.mailbox.fullName();
|
|
|
|
|
|
|
|
if (targetMailbox == currentMailbox)
|
|
|
|
window.alert(labels[error]);
|
|
|
|
else {
|
|
|
|
var message;
|
2007-10-18 19:19:05 +02:00
|
|
|
if (document.menuTarget.tagName == "DIV")
|
2007-10-18 00:29:51 +02:00
|
|
|
message = currentMessages[currentMailbox];
|
|
|
|
else
|
|
|
|
message = document.menuTarget.getAttribute("id").substr(4);
|
|
|
|
|
|
|
|
var urlstr = (URLForFolderID(currentMailbox) + "/" + message
|
|
|
|
+ "/" + actionName + "?folder=" + targetMailbox);
|
|
|
|
triggerAjaxRequest(urlstr, folderRefreshCallback, currentMailbox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMailboxMenuMove(event) {
|
|
|
|
_onMailboxMenuAction(this,
|
|
|
|
"Moving a message into its own folder is impossible!",
|
|
|
|
"move");
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
|
|
|
|
2007-10-18 00:29:51 +02:00
|
|
|
function onMailboxMenuCopy(event) {
|
|
|
|
_onMailboxMenuAction(this,
|
|
|
|
"Copying a message into its own folder is impossible!",
|
|
|
|
"copy");
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
|
|
|
|
2007-05-04 17:57:23 +02:00
|
|
|
function refreshMailbox() {
|
2007-07-30 17:55:28 +02:00
|
|
|
var topWindow = getTopWindow();
|
|
|
|
if (topWindow)
|
|
|
|
topWindow.refreshCurrentFolder();
|
2007-05-25 23:12:46 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
return false;
|
2006-11-13 23:29:31 +01:00
|
|
|
}
|
|
|
|
|
2007-08-15 22:34:11 +02:00
|
|
|
function onComposeMessage() {
|
|
|
|
var topWindow = getTopWindow();
|
|
|
|
if (topWindow)
|
|
|
|
topWindow.composeNewMessage();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function composeNewMessage() {
|
|
|
|
var account = currentMailbox.split("/")[1];
|
|
|
|
var url = ApplicationBaseURL + "/" + account + "/compose";
|
2007-08-21 18:00:25 +02:00
|
|
|
openMailComposeWindow(url);
|
2007-08-15 22:34:11 +02:00
|
|
|
}
|
|
|
|
|
2007-06-28 20:28:33 +02:00
|
|
|
function openMailbox(mailbox, reload, idx) {
|
2007-07-30 17:55:28 +02:00
|
|
|
if (mailbox != currentMailbox || reload) {
|
|
|
|
currentMailbox = mailbox;
|
2007-10-03 22:01:05 +02:00
|
|
|
var url = ApplicationBaseURL + encodeURI(mailbox) + "/view?noframe=1";
|
2007-07-30 17:55:28 +02:00
|
|
|
var messageContent = $("messageContent");
|
2007-09-14 20:20:51 +02:00
|
|
|
messageContent.update();
|
2007-10-02 17:29:16 +02:00
|
|
|
lastClickedRow = null; // from generic.js
|
|
|
|
|
2007-08-18 22:29:50 +02:00
|
|
|
var currentMessage;
|
|
|
|
if (!idx) {
|
|
|
|
currentMessage = currentMessages[mailbox];
|
|
|
|
if (currentMessage) {
|
|
|
|
loadMessage(currentMessage);
|
|
|
|
url += '&pageforuid=' + currentMessage;
|
|
|
|
}
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
2007-06-28 22:35:09 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
var searchValue = search["value"];
|
|
|
|
if (searchValue && searchValue.length > 0)
|
|
|
|
url += ("&search=" + search["criteria"]
|
2007-08-15 00:09:20 +02:00
|
|
|
+ "&value=" + escape(searchValue));
|
2007-07-30 17:55:28 +02:00
|
|
|
var sortAttribute = sorting["attribute"];
|
|
|
|
if (sortAttribute && sortAttribute.length > 0)
|
|
|
|
url += ("&sort=" + sorting["attribute"]
|
|
|
|
+ "&asc=" + sorting["ascending"]);
|
|
|
|
if (idx)
|
|
|
|
url += "&idx=" + idx;
|
2007-10-27 00:17:29 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
if (document.messageListAjaxRequest) {
|
|
|
|
document.messageListAjaxRequest.aborted = true;
|
|
|
|
document.messageListAjaxRequest.abort();
|
|
|
|
}
|
2007-06-28 22:35:09 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
var mailboxContent = $("mailboxContent");
|
|
|
|
if (mailboxContent.getStyle('visibility') == "hidden") {
|
|
|
|
mailboxContent.setStyle({ visibility: "visible" });
|
|
|
|
var rightDragHandle = $("rightDragHandle");
|
|
|
|
rightDragHandle.setStyle({ visibility: "visible" });
|
|
|
|
messageContent.setStyle({ top: (rightDragHandle.offsetTop
|
|
|
|
+ rightDragHandle.offsetHeight
|
|
|
|
+ 'px') });
|
|
|
|
}
|
|
|
|
document.messageListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, messageListCallback,
|
2007-08-18 22:29:50 +02:00
|
|
|
currentMessage);
|
2007-07-11 07:05:03 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
var quotasUrl = ApplicationBaseURL + mailbox + "/quotas";
|
|
|
|
document.quotasAjaxRequest
|
|
|
|
= triggerAjaxRequest(quotasUrl, quotasCallback);
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-06-04 22:01:53 +02:00
|
|
|
function openMailboxAtIndex(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
openMailbox(currentMailbox, true, this.getAttribute("idx"));
|
2006-11-09 00:49:09 +01:00
|
|
|
|
2007-09-24 23:26:23 +02:00
|
|
|
Event.stop(event);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function messageListCallback(http) {
|
2007-10-17 15:26:26 +02:00
|
|
|
var div = $('mailboxContent');
|
2007-09-24 23:26:23 +02:00
|
|
|
var table = $('messageList');
|
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2007-09-14 20:20:51 +02:00
|
|
|
document.messageListAjaxRequest = null;
|
|
|
|
|
2007-09-24 23:26:23 +02:00
|
|
|
if (table) {
|
|
|
|
// Update table
|
|
|
|
var thead = table.tHead;
|
|
|
|
var tbody = table.tBodies[0];
|
|
|
|
var tmp = document.createElement('div');
|
|
|
|
$(tmp).update(http.responseText);
|
|
|
|
thead.rows[1].parentNode.replaceChild(tmp.firstChild.tHead.rows[1], thead.rows[1]);
|
|
|
|
table.replaceChild(tmp.firstChild.tBodies[0], tbody);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Add table
|
|
|
|
div.update(http.responseText);
|
|
|
|
table = $('messageList');
|
|
|
|
configureMessageListEvents(table);
|
|
|
|
TableKit.Resizable.init(table, {'trueResize' : true, 'keepWidth' : true});
|
|
|
|
}
|
|
|
|
configureMessageListBodyEvents(table);
|
2007-09-14 20:20:51 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
var selected = http.callbackData;
|
|
|
|
if (selected) {
|
|
|
|
var row = $("row_" + selected);
|
2007-10-17 15:26:26 +02:00
|
|
|
if (row) {
|
2007-07-30 17:55:28 +02:00
|
|
|
row.select();
|
2007-10-25 21:22:07 +02:00
|
|
|
lastClickedRow = row.rowIndex - $(row).up('table').down('thead').getElementsByTagName('tr').length;
|
2007-10-17 15:26:26 +02:00
|
|
|
div.scrollTop = row.rowIndex * row.getHeight(); // scroll to selected message
|
|
|
|
}
|
2007-10-03 15:59:39 +02:00
|
|
|
else
|
|
|
|
$("messageContent").update();
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
2007-10-17 15:26:26 +02:00
|
|
|
else
|
|
|
|
div.scrollTop = 0;
|
2007-09-14 20:20:51 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
if (sorting["attribute"] && sorting["attribute"].length > 0) {
|
2007-09-24 23:26:23 +02:00
|
|
|
var sortHeader = $(sorting["attribute"] + "Header");
|
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
if (sortHeader) {
|
2007-09-24 23:26:23 +02:00
|
|
|
var sortImages = $(table.tHead).getElementsByClassName("sortImage");
|
|
|
|
$(sortImages).each(function(item) {
|
|
|
|
item.remove();
|
|
|
|
});
|
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
var sortImage = createElement("img", "messageSortImage", "sortImage");
|
|
|
|
sortHeader.insertBefore(sortImage, sortHeader.firstChild);
|
|
|
|
if (sorting["ascending"])
|
|
|
|
sortImage.src = ResourcesURL + "/title_sortdown_12x12.png";
|
|
|
|
else
|
|
|
|
sortImage.src = ResourcesURL + "/title_sortup_12x12.png";
|
2007-06-28 20:28:33 +02:00
|
|
|
}
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
|
|
|
}
|
2007-10-03 22:01:05 +02:00
|
|
|
else {
|
|
|
|
var data = http.responseText;
|
|
|
|
var msg = data.replace(/^(.*\n)*.*<p>((.*\n)*.*)<\/p>(.*\n)*.*$/, "$2");
|
|
|
|
log("messageListCallback: problem during ajax request (readyState = " + http.readyState + ", status = " + http.status + ", response = " + msg + ")");
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-07-11 07:05:03 +02:00
|
|
|
function quotasCallback(http) {
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
var hasQuotas = false;
|
|
|
|
|
|
|
|
var quotas = http.responseText.evalJSON(true);
|
|
|
|
for (var i in quotas) {
|
|
|
|
hasQuotas = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasQuotas) {
|
|
|
|
var treePath = currentMailbox.split("/");
|
|
|
|
var mbQuotas = quotas["/" + treePath[2]];
|
|
|
|
var used = mbQuotas["usedSpace"];
|
|
|
|
var max = mbQuotas["maxQuota"];
|
|
|
|
var percents = (Math.round(used * 10000 / max) / 100);
|
2007-09-14 23:54:19 +02:00
|
|
|
var format = labels["quotasFormat"];
|
2007-07-11 07:05:03 +02:00
|
|
|
var text = format.formatted(used, max, percents);
|
|
|
|
window.status = text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onMessageContextMenu(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var menu = $('messageListMenu');
|
|
|
|
Event.observe(menu, "hideMenu", onMessageContextMenuHide);
|
|
|
|
popupMenu(event, "messageListMenu", this);
|
2006-08-01 22:03:50 +02:00
|
|
|
|
2007-07-30 17:55:28 +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-07-30 17:55:28 +02:00
|
|
|
var topNode = $('messageList');
|
2006-08-02 22:04:46 +02:00
|
|
|
|
2007-07-30 17:55:28 +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-07-30 17:55:28 +02:00
|
|
|
var onhide, menuName;
|
2007-05-18 19:25:58 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
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 {
|
2006-12-22 23:13:53 +01:00
|
|
|
menuName = "mailboxIconMenu";
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
menuName = "mailboxIconMenu";
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
var menu = $(menuName);
|
|
|
|
Event.observe(menu, "hideMenu", onFolderMenuHide);
|
|
|
|
popupMenu(event, menuName, this.parentNode);
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
var topNode = $("mailboxTree");
|
|
|
|
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-07-30 17:55:28 +02:00
|
|
|
preventDefault(event);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onFolderMenuHide(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var topNode = $("mailboxTree");
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-07-30 17:55:28 +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-07-30 17:55:28 +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-07-30 17:55:28 +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-07-30 17:55:28 +02:00
|
|
|
return message;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function storeCachedMessage(cachedMessage) {
|
2007-07-30 17:55:28 +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'];
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
2007-07-30 17:55:28 +02:00
|
|
|
counter++;
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
if (oldest == -1)
|
|
|
|
oldest = 0;
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
cachedMessages[oldest] = cachedMessage;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-10-02 17:29:16 +02:00
|
|
|
function onMessageSelectionChange() {
|
2007-07-30 17:55:28 +02:00
|
|
|
var rows = this.getSelectedRowsId();
|
2007-06-08 22:24:57 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
if (rows.length == 1) {
|
|
|
|
var idx = rows[0].substr(4);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-07-30 17:55:28 +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-07-30 17:55:28 +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');
|
2007-09-14 20:20:51 +02:00
|
|
|
div.update(cachedMessage['text']);
|
2007-07-30 17:55:28 +02:00
|
|
|
cachedMessage['time'] = (new Date()).getTime();
|
|
|
|
document.messageAjaxRequest = null;
|
|
|
|
configureLinksInMessage();
|
2007-10-25 22:36:08 +02:00
|
|
|
resizeMailContent();
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-05-16 18:35:09 +02:00
|
|
|
function configureLinksInMessage() {
|
2007-07-30 17:55:28 +02:00
|
|
|
var messageDiv = $('messageContent');
|
|
|
|
var mailContentDiv = document.getElementsByClassName('mailer_mailcontent',
|
|
|
|
messageDiv)[0];
|
2007-10-27 00:17:29 +02:00
|
|
|
if (!document.body.hasClassName("popup"))
|
|
|
|
Event.observe(mailContentDiv, "contextmenu",
|
|
|
|
onMessageContentMenu.bindAsEventListener(mailContentDiv));
|
2007-07-30 17:55:28 +02:00
|
|
|
var anchors = messageDiv.getElementsByTagName('a');
|
|
|
|
for (var i = 0; i < anchors.length; i++)
|
|
|
|
if (anchors[i].href.substring(0,7) == "mailto:") {
|
|
|
|
Event.observe(anchors[i], "click",
|
|
|
|
onEmailAddressClick.bindAsEventListener(anchors[i]));
|
|
|
|
Event.observe(anchors[i], "contextmenu",
|
|
|
|
onEmailAddressClick.bindAsEventListener(anchors[i]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Event.observe(anchors[i], "click",
|
2007-10-26 17:54:44 +02:00
|
|
|
onMessageAnchorClick.bindAsEventListener(anchors[i]));
|
2007-08-15 22:34:11 +02:00
|
|
|
|
|
|
|
var editDraftButton = $("editDraftButton");
|
|
|
|
if (editDraftButton)
|
2007-10-26 17:54:44 +02:00
|
|
|
Event.observe(editDraftButton, "click",
|
|
|
|
onMessageEditDraft.bindAsEventListener(editDraftButton));
|
2007-05-16 23:42:47 +02:00
|
|
|
}
|
|
|
|
|
2007-10-25 22:36:08 +02:00
|
|
|
function resizeMailContent() {
|
|
|
|
var headerTable = document.getElementsByClassName('mailer_fieldtable')[0];
|
|
|
|
var contentDiv = document.getElementsByClassName('mailer_mailcontent')[0];
|
|
|
|
|
|
|
|
contentDiv.setStyle({ 'top': (Element.getHeight(headerTable) + headerTable.offsetTop) + 'px' });
|
|
|
|
}
|
|
|
|
|
2007-05-17 19:25:45 +02:00
|
|
|
function onMessageContentMenu(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
popupMenu(event, 'messageContentMenu', this);
|
2007-05-18 19:25:58 +02:00
|
|
|
}
|
2007-05-17 19:25:45 +02:00
|
|
|
|
2007-08-15 22:34:11 +02:00
|
|
|
function onMessageEditDraft(event) {
|
|
|
|
return openMessageWindowsForSelection("edit", true);
|
|
|
|
}
|
|
|
|
|
2007-05-16 23:42:47 +02:00
|
|
|
function onEmailAddressClick(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
popupMenu(event, 'addressMenu', this);
|
2007-05-15 22:52:38 +02:00
|
|
|
}
|
|
|
|
|
2007-10-26 17:54:44 +02:00
|
|
|
function onMessageAnchorClick(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
window.open(this.href);
|
|
|
|
preventDefault(event);
|
2007-05-15 22:52:38 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function messageCallback(http) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var div = $('messageContent');
|
2007-05-18 19:25:58 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.messageAjaxRequest = null;
|
2007-09-14 20:20:51 +02:00
|
|
|
div.update(http.responseText);
|
2007-07-30 17:55:28 +02:00
|
|
|
configureLinksInMessage();
|
2007-10-25 22:36:08 +02:00
|
|
|
resizeMailContent();
|
|
|
|
|
2007-07-30 17:55:28 +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
|
|
|
|
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-07-30 17:55:28 +02:00
|
|
|
var currentNode, upperNode;
|
|
|
|
var mailboxName;
|
|
|
|
var action;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
mailboxName = mailbox.getAttribute('mailboxname');
|
|
|
|
currentNode = mailbox;
|
|
|
|
upperNode = null;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
while (currentNode
|
|
|
|
&& !currentNode.hasAttribute('mailboxaction'))
|
|
|
|
currentNode = currentNode.parentNode.parentNode.parentMenuItem;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-07-30 17:55:28 +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
|
2007-07-30 17:55:28 +02:00
|
|
|
// + " to " + mailboxName);
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var rowSelectionCount = 0;
|
|
|
|
|
|
|
|
validateControls();
|
|
|
|
|
|
|
|
function showElement(e, shouldShow) {
|
2007-07-30 17:55:28 +02:00
|
|
|
e.style.display = shouldShow ? "" : "none";
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function enableElement(e, shouldEnable) {
|
2007-07-30 17:55:28 +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-07-30 17:55:28 +02:00
|
|
|
var e = $("moveto");
|
|
|
|
this.enableElement(e, rowSelectionCount > 0);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function moveTo(uri) {
|
2007-07-30 17:55:28 +02:00
|
|
|
alert("MoveTo: " + uri);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* message menu entries */
|
2007-03-19 15:31:49 +01:00
|
|
|
function onMenuOpenMessage(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
return openMessageWindowsForSelection('popupview');
|
2007-05-04 05:12:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuReplyToSender(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
return openMessageWindowsForSelection('reply');
|
2007-05-04 05:12:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuReplyToAll(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
return openMessageWindowsForSelection('replyall');
|
2007-05-04 05:12:24 +02:00
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-04 05:12:24 +02:00
|
|
|
function onMenuForwardMessage(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
return openMessageWindowsForSelection('forward');
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-07-04 17:40:22 +02:00
|
|
|
function onMenuViewMessageSource(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var messageList = $("messageList");
|
|
|
|
var rows = messageList.getSelectedRowsId();
|
|
|
|
|
|
|
|
if (rows.length > 0) {
|
|
|
|
var url = (ApplicationBaseURL + currentMailbox + "/"
|
|
|
|
+ rows[0].substr(4) + "/viewsource");
|
2007-08-21 18:00:25 +02:00
|
|
|
openMailComposeWindow(url);
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
2007-07-04 17:40:22 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
preventDefault(event);
|
2007-07-04 17:40:22 +02:00
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
/* contacts */
|
2007-05-18 19:25:58 +02:00
|
|
|
function newContactFromEmail(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var mailto = document.menuTarget.innerHTML;
|
2007-05-18 19:25:58 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
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-07-30 17:55:28 +02:00
|
|
|
url += "&contactFN=" + c_name;
|
2007-08-21 18:00:25 +02:00
|
|
|
openContactWindow(url);
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
return false; /* stop following the link */
|
2007-07-11 07:05:03 +02:00
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
|
|
|
function newEmailTo(sender) {
|
2007-07-30 17:55:28 +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-07-30 17:55:28 +02:00
|
|
|
var currentNode = node.parentNode;
|
|
|
|
|
|
|
|
while (currentNode.className != "dtree") {
|
|
|
|
if (currentNode.className == 'clip') {
|
|
|
|
var id = currentNode.getAttribute("id");
|
|
|
|
var number = parseInt(id.substr(2));
|
|
|
|
if (number > 0) {
|
|
|
|
var cn = mailboxTree.aNodes[number];
|
|
|
|
mailboxTree.nodeStatus(1, number, cn._ls);
|
2007-04-06 23:30:13 +02:00
|
|
|
}
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
|
|
|
currentNode = currentNode.parentNode;
|
|
|
|
}
|
2006-07-31 22:24:50 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onHeaderClick(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var headerId = this.getAttribute("id");
|
|
|
|
var newSortAttribute;
|
|
|
|
if (headerId == "subjectHeader")
|
|
|
|
newSortAttribute = "subject";
|
|
|
|
else if (headerId == "fromHeader")
|
|
|
|
newSortAttribute = "from";
|
|
|
|
else if (headerId == "dateHeader")
|
|
|
|
newSortAttribute = "date";
|
|
|
|
else
|
|
|
|
newSortAttribute = "arrival";
|
2007-09-26 00:09:59 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
if (sorting["attribute"] == newSortAttribute)
|
|
|
|
sorting["ascending"] = !sorting["ascending"];
|
|
|
|
else {
|
|
|
|
sorting["attribute"] = newSortAttribute;
|
|
|
|
sorting["ascending"] = true;
|
|
|
|
}
|
|
|
|
refreshCurrentFolder();
|
2007-09-24 23:26:23 +02:00
|
|
|
|
2007-09-14 20:20:51 +02:00
|
|
|
Event.stop(event);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
2006-08-31 01:13:28 +02:00
|
|
|
|
2007-06-28 22:35:09 +02:00
|
|
|
function refreshCurrentFolder() {
|
2007-07-30 17:55:28 +02:00
|
|
|
openMailbox(currentMailbox, true);
|
2006-08-31 01:13:28 +02:00
|
|
|
}
|
2006-10-23 16:56:32 +02:00
|
|
|
|
2007-10-04 16:17:38 +02:00
|
|
|
function refreshFolderByType(type) {
|
|
|
|
if (currentMailboxType == type)
|
|
|
|
refreshCurrentFolder();
|
|
|
|
}
|
|
|
|
|
2006-11-09 00:49:09 +01:00
|
|
|
var mailboxSpanAcceptType = function(type) {
|
2007-07-30 17:55:28 +02:00
|
|
|
return (type == "mailRow");
|
2006-11-09 00:49:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var mailboxSpanEnter = function() {
|
2007-07-30 17:55:28 +02:00
|
|
|
this.addClassName("_dragOver");
|
2006-11-09 00:49:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var mailboxSpanExit = function() {
|
2007-07-30 17:55:28 +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-07-30 17:55:28 +02:00
|
|
|
var success = false;
|
2006-11-10 23:59:39 +01:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
if (data) {
|
|
|
|
var folder = this.parentNode.parentNode.getAttribute("dataname");
|
|
|
|
if (folder != currentMailbox)
|
|
|
|
success = (moveMessages(data, folder) == 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
success = false;
|
2007-10-29 19:58:14 +01:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
return success;
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
2007-10-29 19:58:14 +01:00
|
|
|
|
2006-11-10 23:59:39 +01:00
|
|
|
var plusSignEnter = function() {
|
2007-07-30 17:55:28 +02:00
|
|
|
var nodeNr = parseInt(this.id.substr(2));
|
|
|
|
if (!mailboxTree.aNodes[nodeNr]._io)
|
|
|
|
this.plusSignTimer = setTimeout("openPlusSign('" + nodeNr + "');", 1000);
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
2007-10-29 19:58:14 +01:00
|
|
|
|
2006-11-10 23:59:39 +01:00
|
|
|
var plusSignExit = function() {
|
2007-07-30 17:55:28 +02:00
|
|
|
if (this.plusSignTimer) {
|
|
|
|
clearTimeout(this.plusSignTimer);
|
|
|
|
this.plusSignTimer = null;
|
|
|
|
}
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
2007-07-30 17:55:28 +02:00
|
|
|
|
2006-11-10 23:59:39 +01:00
|
|
|
function openPlusSign(nodeNr) {
|
2007-07-30 17:55:28 +02:00
|
|
|
mailboxTree.nodeStatus(1, nodeNr, mailboxTree.aNodes[nodeNr]._ls);
|
|
|
|
mailboxTree.aNodes[nodeNr]._io = 1;
|
|
|
|
this.plusSignTimer = null;
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
|
|
|
|
2006-11-09 00:49:09 +01:00
|
|
|
var messageListGhost = function () {
|
2007-07-30 17:55:28 +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-07-30 17:55:28 +02:00
|
|
|
var newImg = document.createElement("img");
|
|
|
|
newImg.src = ResourcesURL + "/message-mail.png";
|
2006-11-13 23:29:31 +01:00
|
|
|
|
2007-07-30 17:55:28 +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-07-30 17:55:28 +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-07-30 17:55:28 +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-07-30 17:55:28 +02:00
|
|
|
return msgIds;
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
|
|
|
|
2007-06-28 20:28:33 +02:00
|
|
|
/* a model for a futur refactoring of the sortable table headers mechanism */
|
2007-09-24 23:26:23 +02:00
|
|
|
function configureMessageListEvents(table) {
|
|
|
|
if (table) {
|
2007-09-29 02:22:11 +02:00
|
|
|
table.multiselect = true;
|
2007-09-24 23:26:23 +02:00
|
|
|
// Each body row can load a message
|
|
|
|
Event.observe(table, "mousedown",
|
2007-09-29 02:22:11 +02:00
|
|
|
onMessageSelectionChange.bindAsEventListener(table));
|
2007-09-24 23:26:23 +02:00
|
|
|
// Sortable columns
|
|
|
|
configureSortableTableHeaders(table);
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
2007-06-28 20:28:33 +02:00
|
|
|
}
|
|
|
|
|
2007-09-24 23:26:23 +02:00
|
|
|
function configureMessageListBodyEvents(table) {
|
|
|
|
if (table) {
|
|
|
|
// Page navigation
|
|
|
|
var cell = table.tHead.rows[1].cells[0];
|
2007-07-30 17:55:28 +02:00
|
|
|
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]));
|
|
|
|
}
|
2007-06-14 00:06:01 +02:00
|
|
|
|
2007-09-24 23:26:23 +02:00
|
|
|
rows = table.tBodies[0].rows;
|
2007-07-30 17:55:28 +02:00
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
Event.observe(rows[i], "mousedown", onRowClick);
|
2007-10-02 17:29:16 +02:00
|
|
|
Event.observe(rows[i], "selectstart", listRowMouseDownHandler);
|
2007-07-30 17:55:28 +02:00
|
|
|
Event.observe(rows[i], "contextmenu", onMessageContextMenu.bindAsEventListener(rows[i]));
|
2007-09-24 23:26:23 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
rows[i].dndTypes = function() { return new Array("mailRow"); };
|
|
|
|
rows[i].dndGhost = messageListGhost;
|
|
|
|
rows[i].dndDataForType = messageListData;
|
2007-10-19 21:24:21 +02:00
|
|
|
// document.DNDManager.registerSource(rows[i]);
|
2007-07-30 17:55:28 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
|
|
|
|
2006-12-22 17:48:11 +01:00
|
|
|
function configureDragHandles() {
|
2007-07-30 17:55:28 +02:00
|
|
|
var handle = $("verticalDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
2007-08-17 04:19:06 +02:00
|
|
|
handle.leftMargin = 1;
|
2007-07-30 17:55:28 +02:00
|
|
|
handle.leftBlock=$("leftPanel");
|
|
|
|
handle.rightBlock=$("rightPanel");
|
|
|
|
}
|
2006-12-22 17:48:11 +01:00
|
|
|
|
2007-07-30 17:55:28 +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-07-30 17:55:28 +02:00
|
|
|
// log("MailerUI initDnd");
|
|
|
|
|
|
|
|
var tree = $("mailboxTree");
|
|
|
|
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]);
|
2006-11-10 23:59:39 +01:00
|
|
|
}
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
|
|
|
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-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-07-30 17:55:28 +02:00
|
|
|
var done = false;
|
|
|
|
openMailbox(node.parentNode.getAttribute("dataname"));
|
|
|
|
var tree = $("mailboxTree");
|
|
|
|
tree.selectedEntry = node;
|
|
|
|
node.select();
|
|
|
|
mailboxTree.o(1);
|
2006-12-22 23:13:53 +01:00
|
|
|
}
|
|
|
|
|
2007-05-18 19:25:58 +02:00
|
|
|
function initMailer(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
if (!document.body.hasClassName("popup")) {
|
2007-10-19 21:24:21 +02:00
|
|
|
// initDnd();
|
2007-07-30 17:55:28 +02:00
|
|
|
initMailboxTree();
|
2007-10-26 17:35:51 +02:00
|
|
|
initMessageCheckTimer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function initMessageCheckTimer() {
|
|
|
|
var messageCheck = userDefaults["MessageCheck"];
|
|
|
|
if (messageCheck && messageCheck != "manually") {
|
|
|
|
var interval;
|
|
|
|
if (messageCheck == "once_per_hour")
|
|
|
|
interval = 3600;
|
|
|
|
else if (messageCheck == "every_minute")
|
|
|
|
interval = 60;
|
|
|
|
else {
|
|
|
|
interval = parseInt(messageCheck.substr(6)) * 60;
|
|
|
|
}
|
|
|
|
messageCheckTimer = window.setInterval(onMessageCheckCallback,
|
|
|
|
interval * 1000);
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
|
|
|
|
2007-10-26 17:35:51 +02:00
|
|
|
function onMessageCheckCallback(event) {
|
|
|
|
refreshMailbox();
|
|
|
|
}
|
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
function initMailboxTree() {
|
2007-07-30 17:55:28 +02:00
|
|
|
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;
|
2007-09-07 15:35:22 +02:00
|
|
|
activeAjaxRequests += mailAccounts.length;
|
2007-07-30 17:55:28 +02:00
|
|
|
for (var i = 0; i < mailAccounts.length; i++) {
|
|
|
|
var url = ApplicationBaseURL + "/" + mailAccounts[i] + "/mailboxes";
|
|
|
|
triggerAjaxRequest(url, onLoadMailboxesCallback, mailAccounts[i]);
|
|
|
|
}
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateMailboxTreeInPage() {
|
2007-09-14 20:20:51 +02:00
|
|
|
$("folderTreeContent").update(mailboxTree);
|
2007-07-30 17:55:28 +02:00
|
|
|
|
|
|
|
var inboxFound = false;
|
|
|
|
var tree = $("mailboxTree");
|
|
|
|
var nodes = document.getElementsByClassName("node", tree);
|
|
|
|
for (i = 0; i < nodes.length; i++) {
|
2007-10-17 23:03:39 +02:00
|
|
|
Event.observe(nodes[i], "click",
|
|
|
|
onMailboxTreeItemClick.bindAsEventListener(nodes[i]));
|
|
|
|
Event.observe(nodes[i], "contextmenu",
|
|
|
|
onFolderMenuClick.bindAsEventListener(nodes[i]));
|
2007-07-30 17:55:28 +02:00
|
|
|
if (!inboxFound
|
|
|
|
&& nodes[i].parentNode.getAttribute("datatype") == "inbox") {
|
|
|
|
openInbox(nodes[i]);
|
|
|
|
inboxFound = true;
|
|
|
|
}
|
|
|
|
}
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function mailboxMenuNode(type, name) {
|
2007-07-30 17:55:28 +02:00
|
|
|
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);
|
2007-10-18 16:45:11 +02:00
|
|
|
var displayName = MailerUIdTreeExtension.folderNames[type];
|
|
|
|
if (!displayName)
|
|
|
|
displayName = name;
|
|
|
|
newNode.appendChild(document.createTextNode(" " + displayName));
|
2007-05-25 23:12:46 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
return newNode;
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function generateMenuForMailbox(mailbox, prefix, callback) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var menuDIV = document.createElement("div");
|
|
|
|
$(menuDIV).addClassName("menu");
|
|
|
|
menuDIV.setAttribute("id", prefix + "Submenu");
|
|
|
|
var menu = document.createElement("ul");
|
|
|
|
menuDIV.appendChild(menu);
|
2007-10-18 00:29:51 +02:00
|
|
|
pageContent.appendChild(menuDIV);
|
2007-07-30 17:55:28 +02:00
|
|
|
|
|
|
|
var callbacks = new Array();
|
|
|
|
if (mailbox.type != "account") {
|
|
|
|
var newNode = document.createElement("li");
|
|
|
|
newNode.mailbox = mailbox;
|
2007-10-18 00:29:51 +02:00
|
|
|
newNode.appendChild(document.createTextNode(labels["This Folder"]));
|
2007-07-30 17:55:28 +02:00
|
|
|
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;
|
2007-10-17 23:03:39 +02:00
|
|
|
var newSubmenuId = generateMenuForMailbox(child, newPrefix, callback);
|
|
|
|
callbacks.push(newSubmenuId);
|
2007-07-30 17:55:28 +02:00
|
|
|
submenuCount++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newNode.mailbox = child;
|
2007-05-25 23:12:46 +02:00
|
|
|
callbacks.push(callback);
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
initMenu(menuDIV, callbacks);
|
2007-05-25 23:12:46 +02:00
|
|
|
|
2007-10-17 23:03:39 +02:00
|
|
|
return menuDIV.getAttribute("id");
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateMailboxMenus() {
|
2007-07-30 17:55:28 +02:00
|
|
|
var mailboxActions = { move: onMailboxMenuMove,
|
|
|
|
copy: onMailboxMenuCopy };
|
2007-05-25 23:12:46 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
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-07-30 17:55:28 +02:00
|
|
|
menuDIV = document.createElement("div");
|
2007-10-18 00:29:51 +02:00
|
|
|
pageContent = $("pageContent");
|
|
|
|
pageContent.appendChild(menuDIV);
|
2007-06-08 22:24:57 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
var menu = document.createElement("ul");
|
|
|
|
menuDIV.appendChild(menu);
|
2007-05-25 23:12:46 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
$(menuDIV).addClassName("menu");
|
|
|
|
menuDIV.setAttribute("id", menuId);
|
2007-10-18 00:29:51 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
var submenuIds = new Array();
|
|
|
|
for (var i = 0; i < mailAccounts.length; i++) {
|
|
|
|
var menuEntry = mailboxMenuNode("account", mailAccounts[i]);
|
|
|
|
menu.appendChild(menuEntry);
|
|
|
|
var mailbox = accounts[mailAccounts[i]];
|
2007-10-17 23:03:39 +02:00
|
|
|
var newSubmenuId = generateMenuForMailbox(mailbox,
|
2007-07-30 17:55:28 +02:00
|
|
|
key, mailboxActions[key]);
|
2007-10-17 23:03:39 +02:00
|
|
|
submenuIds.push(newSubmenuId);
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
|
|
|
initMenu(menuDIV, submenuIds);
|
|
|
|
}
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onLoadMailboxesCallback(http) {
|
2007-07-30 17:55:28 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2007-09-07 15:35:22 +02:00
|
|
|
checkAjaxRequestsState();
|
2007-07-30 17:55:28 +02:00
|
|
|
var newAccount = buildMailboxes(http.callbackData,
|
|
|
|
http.responseText);
|
|
|
|
accounts[http.callbackData] = newAccount;
|
|
|
|
mailboxTree.addMailAccount(newAccount);
|
|
|
|
mailboxTree.pendingRequests--;
|
2007-09-07 15:35:22 +02:00
|
|
|
activeAjaxRequests--;
|
2007-07-30 17:55:28 +02:00
|
|
|
if (!mailboxTree.pendingRequests) {
|
|
|
|
updateMailboxTreeInPage();
|
|
|
|
updateMailboxMenus();
|
2007-09-07 15:35:22 +02:00
|
|
|
checkAjaxRequestsState();
|
2007-07-30 17:55:28 +02:00
|
|
|
}
|
2007-05-28 15:18:31 +02:00
|
|
|
}
|
2007-05-25 23:12:46 +02:00
|
|
|
|
2007-07-30 17:55:28 +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) {
|
|
|
|
// // log("found mailbox");
|
|
|
|
// var links = document.getElementsByClassName("node", treeNodes[i]);
|
|
|
|
// if (tree.selectedEntry)
|
|
|
|
// tree.selectedEntry.deselect();
|
|
|
|
// links[0].select();
|
|
|
|
// tree.selectedEntry = links[0];
|
|
|
|
// expandUpperTree(links[0]);
|
|
|
|
// }
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function buildMailboxes(accountName, encoded) {
|
2007-07-30 17:55:28 +02:00
|
|
|
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-05-25 23:12:46 +02:00
|
|
|
}
|
2007-07-30 17:55:28 +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-05-25 23:12:46 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
return account;
|
2006-11-09 00:49:09 +01:00
|
|
|
}
|
|
|
|
|
2007-10-27 00:17:29 +02:00
|
|
|
function onMenuCreateFolder(event) {
|
2007-09-14 23:54:19 +02:00
|
|
|
var name = window.prompt(labels["Name :"], "");
|
2007-07-30 17:55:28 +02:00
|
|
|
if (name && name.length > 0) {
|
|
|
|
var folderID = document.menuTarget.getAttribute("dataname");
|
2007-10-25 21:22:07 +02:00
|
|
|
var urlstr = URLForFolderID(folderID) + "/createFolder?name=" + name; log ("create " + urlstr);
|
2007-07-30 17:55:28 +02:00
|
|
|
triggerAjaxRequest(urlstr, folderOperationCallback);
|
|
|
|
}
|
2007-05-28 15:18:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuRenameFolder(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var name = window.prompt(labels["Enter the new name of your folder :"]
|
2007-09-14 23:54:19 +02:00
|
|
|
,
|
2007-07-30 17:55:28 +02:00
|
|
|
"");
|
|
|
|
if (name && name.length > 0) {
|
|
|
|
var folderID = document.menuTarget.getAttribute("dataname");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/renameFolder?name=" + name;
|
|
|
|
triggerAjaxRequest(urlstr, folderOperationCallback);
|
|
|
|
}
|
2007-05-28 15:18:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuDeleteFolder(event) {
|
2007-09-14 23:54:19 +02:00
|
|
|
var answer = window.confirm(labels["Do you really want to move this folder into the trash ?"]);
|
2007-07-30 17:55:28 +02:00
|
|
|
if (answer) {
|
|
|
|
var folderID = document.menuTarget.getAttribute("dataname");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/deleteFolder";
|
|
|
|
triggerAjaxRequest(urlstr, folderOperationCallback);
|
|
|
|
}
|
2007-05-28 15:18:31 +02:00
|
|
|
}
|
|
|
|
|
2007-08-16 23:49:59 +02:00
|
|
|
function onMenuExpungeFolder(event) {
|
|
|
|
var folderID = document.menuTarget.getAttribute("dataname");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/expunge";
|
|
|
|
triggerAjaxRequest(urlstr, folderRefreshCallback, folderID);
|
|
|
|
}
|
|
|
|
|
2007-05-28 21:05:00 +02:00
|
|
|
function onMenuEmptyTrash(event) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var folderID = document.menuTarget.getAttribute("dataname");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/emptyTrash";
|
2007-09-26 00:09:59 +02:00
|
|
|
triggerAjaxRequest(urlstr, folderOperationCallback, folderID);
|
2007-09-10 17:50:43 +02:00
|
|
|
|
|
|
|
if (folderID == currentMailbox) {
|
|
|
|
var div = $('messageContent');
|
|
|
|
for (var i = div.childNodes.length - 1; i > -1; i--)
|
|
|
|
div.removeChild(div.childNodes[i]);
|
2007-09-26 00:09:59 +02:00
|
|
|
refreshCurrentFolder();
|
2007-09-10 17:50:43 +02:00
|
|
|
}
|
|
|
|
var msgID = currentMessages[folderID];
|
|
|
|
if (msgID)
|
|
|
|
deleteCachedMessage(folderID + "/" + msgID);
|
2007-05-28 21:05:00 +02:00
|
|
|
}
|
|
|
|
|
2007-10-17 23:03:39 +02:00
|
|
|
function _onMenuChangeToXXXFolder(event, folder) {
|
|
|
|
var type = document.menuTarget.getAttribute("datatype");
|
|
|
|
if (type == "additional")
|
|
|
|
window.alert(labels["You need to choose a non-virtual folder!"]);
|
|
|
|
else {
|
|
|
|
var folderID = document.menuTarget.getAttribute("dataname");
|
2007-11-01 13:48:19 +01:00
|
|
|
var urlstr = URLForFolderID(folderID) + "/setAs" + folder + "Folder";
|
|
|
|
triggerAjaxRequest(urlstr, folderOperationCallback);
|
2007-10-17 23:03:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuChangeToDraftsFolder(event) {
|
|
|
|
return _onMenuChangeToXXXFolder(event, "Drafts");
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuChangeToSentFolder(event) {
|
|
|
|
return _onMenuChangeToXXXFolder(event, "Sent");
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuChangeToTrashFolder(event) {
|
|
|
|
return _onMenuChangeToXXXFolder(event, "Trash");
|
|
|
|
}
|
|
|
|
|
2007-10-22 23:59:20 +02:00
|
|
|
function onMenuLabelNone() {
|
|
|
|
var rowId = document.menuTarget.getAttribute("id").substr(4);
|
|
|
|
var messageId = currentMailbox + "/" + rowId;
|
|
|
|
var urlstr = ApplicationBaseURL + messageId + "/removeAllLabels";
|
|
|
|
triggerAjaxRequest(urlstr, messageFlagCallback,
|
|
|
|
{ mailbox: currentMailbox, msg: rowId, label: null } );
|
|
|
|
}
|
|
|
|
|
|
|
|
function _onMenuLabelFlagX(flag) {
|
|
|
|
var flags = document.menuTarget.getAttribute("labels").split(" ");
|
|
|
|
|
|
|
|
var rowId = document.menuTarget.getAttribute("id").substr(4);
|
|
|
|
var messageId = currentMailbox + "/" + rowId;
|
|
|
|
|
|
|
|
var operation = "add";
|
|
|
|
if (flags.indexOf("label" + flag) > -1)
|
|
|
|
operation = "remove";
|
|
|
|
var urlstr = (ApplicationBaseURL + messageId
|
|
|
|
+ "/" + operation + "Label" + flag);
|
|
|
|
triggerAjaxRequest(urlstr, messageFlagCallback,
|
|
|
|
{ mailbox: currentMailbox, msg: rowId,
|
|
|
|
label: operation + flag } );
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuLabelFlag1() {
|
|
|
|
_onMenuLabelFlagX(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuLabelFlag2() {
|
|
|
|
_onMenuLabelFlagX(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuLabelFlag3() {
|
|
|
|
_onMenuLabelFlagX(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuLabelFlag4() {
|
|
|
|
_onMenuLabelFlagX(4);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuLabelFlag5() {
|
|
|
|
_onMenuLabelFlagX(5);
|
|
|
|
}
|
|
|
|
|
2007-05-28 15:18:31 +02:00
|
|
|
function folderOperationCallback(http) {
|
2007-07-30 17:55:28 +02:00
|
|
|
if (http.readyState == 4
|
2007-09-26 00:09:59 +02:00
|
|
|
&& isHttpStatus204(http.status))
|
2007-07-30 17:55:28 +02:00
|
|
|
initMailboxTree();
|
|
|
|
else
|
2007-09-14 23:54:19 +02:00
|
|
|
window.alert(labels["Operation failed"]);
|
2007-05-28 15:18:31 +02:00
|
|
|
}
|
|
|
|
|
2007-08-16 23:49:59 +02:00
|
|
|
function folderRefreshCallback(http) {
|
|
|
|
if (http.readyState == 4
|
2007-09-26 00:09:59 +02:00
|
|
|
&& isHttpStatus204(http.status)) {
|
2007-08-16 23:49:59 +02:00
|
|
|
var oldMailbox = http.callbackData;
|
|
|
|
if (oldMailbox == currentMailbox)
|
|
|
|
refreshCurrentFolder();
|
|
|
|
}
|
|
|
|
else
|
2007-09-14 23:54:19 +02:00
|
|
|
window.alert(labels["Operation failed"]);
|
2007-08-16 23:49:59 +02:00
|
|
|
}
|
|
|
|
|
2007-10-22 23:59:20 +02:00
|
|
|
function messageFlagCallback(http) {
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& isHttpStatus204(http.status)) {
|
|
|
|
var data = http.callbackData;
|
|
|
|
if (data["mailbox"] == currentMailbox) {
|
|
|
|
var row = $("row_" + data["msg"]);
|
|
|
|
var operation = data["label"];
|
|
|
|
if (operation) {
|
|
|
|
var labels = row.getAttribute("labels");
|
|
|
|
var flags;
|
|
|
|
if (labels.length > 0)
|
|
|
|
flags = labels.split(" ");
|
|
|
|
else
|
|
|
|
flags = new Array();
|
|
|
|
if (operation.substr(0, 3) == "add")
|
|
|
|
flags.push("label" + operation.substr(3));
|
|
|
|
else {
|
|
|
|
var flag = "label" + operation.substr(6);
|
|
|
|
var idx = flags.indexOf(flag);
|
|
|
|
flags.splice(idx, 1);
|
|
|
|
}
|
|
|
|
row.setAttribute("labels", flags.join(" "));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
row.setAttribute("labels", "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onLabelMenuPrepareVisibility() {
|
|
|
|
var messageList = $("messageList");
|
|
|
|
var flags = {};
|
2007-10-27 00:17:29 +02:00
|
|
|
|
|
|
|
if (messageList) {
|
|
|
|
var rows = messageList.getSelectedRows();
|
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
$w(rows[i].getAttribute("labels")).each(function(flag) {
|
|
|
|
flags[flag] = true;
|
|
|
|
});
|
|
|
|
}
|
2007-10-22 23:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var lis = this.childNodesWithTag("ul")[0].childNodesWithTag("li")
|
|
|
|
var isFlagged = false;
|
|
|
|
for (var i = 1; i < 6; i++) {
|
|
|
|
if (flags["label" + i]) {
|
|
|
|
isFlagged = true;
|
|
|
|
lis[1 + i].addClassName("_chosen");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
lis[1 + i].removeClassName("_chosen");
|
|
|
|
}
|
|
|
|
if (isFlagged)
|
|
|
|
lis[0].removeClassName("_chosen");
|
|
|
|
else
|
|
|
|
lis[0].addClassName("_chosen");
|
|
|
|
}
|
|
|
|
|
2007-05-28 21:19:17 +02:00
|
|
|
function getMenus() {
|
2007-07-30 17:55:28 +02:00
|
|
|
var menus = {}
|
|
|
|
menus["accountIconMenu"] = new Array(null, null, onMenuCreateFolder, null,
|
|
|
|
null, null);
|
|
|
|
menus["inboxIconMenu"] = new Array(null, null, null, "-", null,
|
2007-08-16 23:49:59 +02:00
|
|
|
onMenuCreateFolder, onMenuExpungeFolder,
|
|
|
|
"-", null,
|
2007-07-30 17:55:28 +02:00
|
|
|
onMenuSharing);
|
|
|
|
menus["trashIconMenu"] = new Array(null, null, null, "-", null,
|
2007-08-16 23:49:59 +02:00
|
|
|
onMenuCreateFolder, onMenuExpungeFolder,
|
2007-07-30 17:55:28 +02:00
|
|
|
onMenuEmptyTrash, "-", null,
|
|
|
|
onMenuSharing);
|
|
|
|
menus["mailboxIconMenu"] = new Array(null, null, null, "-", null,
|
|
|
|
onMenuCreateFolder,
|
|
|
|
onMenuRenameFolder,
|
2007-08-16 23:49:59 +02:00
|
|
|
onMenuExpungeFolder,
|
2007-10-17 23:03:39 +02:00
|
|
|
onMenuDeleteFolder,
|
|
|
|
"folderTypeMenu",
|
|
|
|
"-", null,
|
2007-07-30 17:55:28 +02:00
|
|
|
onMenuSharing);
|
|
|
|
menus["addressMenu"] = new Array(newContactFromEmail, newEmailTo, null);
|
|
|
|
menus["messageListMenu"] = new Array(onMenuOpenMessage, "-",
|
|
|
|
onMenuReplyToSender,
|
|
|
|
onMenuReplyToAll,
|
|
|
|
onMenuForwardMessage, null,
|
|
|
|
"-", "moveMailboxMenu",
|
|
|
|
"copyMailboxMenu", "label-menu",
|
|
|
|
"mark-menu", "-", null,
|
|
|
|
onMenuViewMessageSource, null,
|
|
|
|
null, onMenuDeleteMessage);
|
|
|
|
menus["messageContentMenu"] = new Array(onMenuReplyToSender,
|
|
|
|
onMenuReplyToAll,
|
|
|
|
onMenuForwardMessage,
|
|
|
|
null, "moveMailboxMenu",
|
|
|
|
"copyMailboxMenu",
|
|
|
|
"-", "label-menu", "mark-menu",
|
|
|
|
"-",
|
|
|
|
null, onMenuViewMessageSource,
|
2007-08-09 04:31:42 +02:00
|
|
|
null, onPrintCurrentMessage,
|
2007-07-30 17:55:28 +02:00
|
|
|
onMenuDeleteMessage);
|
2007-10-17 23:03:39 +02:00
|
|
|
menus["folderTypeMenu"] = new Array(onMenuChangeToSentFolder,
|
|
|
|
onMenuChangeToDraftsFolder,
|
|
|
|
onMenuChangeToTrashFolder);
|
2007-10-22 23:59:20 +02:00
|
|
|
|
|
|
|
menus["label-menu"] = new Array(onMenuLabelNone, "-", onMenuLabelFlag1,
|
|
|
|
onMenuLabelFlag2, onMenuLabelFlag3,
|
|
|
|
onMenuLabelFlag4, onMenuLabelFlag5);
|
2007-07-30 17:55:28 +02:00
|
|
|
menus["mark-menu"] = new Array(null, null, null, null, "-", null, "-",
|
|
|
|
null, null, null);
|
|
|
|
menus["searchMenu"] = new Array(setSearchCriteria, setSearchCriteria,
|
|
|
|
setSearchCriteria, setSearchCriteria,
|
|
|
|
setSearchCriteria);
|
2007-10-23 19:44:20 +02:00
|
|
|
var labelMenu = $("label-menu");
|
|
|
|
if (labelMenu)
|
|
|
|
labelMenu.prepareVisibility = onLabelMenuPrepareVisibility;
|
2007-07-30 17:55:28 +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) {
|
2007-07-30 17:55:28 +02:00
|
|
|
this.type = type;
|
|
|
|
this.name = name;
|
|
|
|
this.parentFolder = null;
|
|
|
|
this.children = new Array();
|
|
|
|
return this;
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Mailbox.prototype.dump = function(indent) {
|
2007-07-30 17:55:28 +02:00
|
|
|
if (!indent)
|
|
|
|
indent = 0;
|
|
|
|
log(" ".repeat(indent) + this.name);
|
|
|
|
for (var i = 0; i < this.children.length; i++) {
|
|
|
|
this.children[i].dump(indent + 2);
|
|
|
|
}
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
|
|
|
|
2007-10-18 00:29:51 +02:00
|
|
|
Mailbox.prototype.fullName = function() {
|
|
|
|
var fullName = "";
|
|
|
|
|
|
|
|
var currentFolder = this;
|
|
|
|
while (currentFolder.parentFolder) {
|
|
|
|
fullName = "/folder" + currentFolder.name + fullName;
|
|
|
|
currentFolder = currentFolder.parentFolder;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "/" + currentFolder.name + fullName;
|
|
|
|
}
|
|
|
|
|
2007-05-25 23:12:46 +02:00
|
|
|
Mailbox.prototype.findMailboxByName = function(name) {
|
2007-07-30 17:55:28 +02:00
|
|
|
var mailbox = null;
|
2007-05-25 23:12:46 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
var i = 0;
|
|
|
|
while (!mailbox && i < this.children.length)
|
|
|
|
if (this.children[i].name == name)
|
|
|
|
mailbox = this.children[i];
|
|
|
|
else
|
|
|
|
i++;
|
2007-05-25 23:12:46 +02:00
|
|
|
|
2007-07-30 17:55:28 +02:00
|
|
|
return mailbox;
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Mailbox.prototype.addMailbox = function(mailbox) {
|
2007-07-30 17:55:28 +02:00
|
|
|
mailbox.parentFolder = this;
|
|
|
|
this.children.push(mailbox);
|
2007-05-25 23:12:46 +02:00
|
|
|
}
|