2006-07-29 00:59:11 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2005 SKYRIX Software AG
|
|
|
|
|
|
|
|
This file is part of OpenGroupware.org.
|
|
|
|
|
|
|
|
OGo is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
/* JavaScript for SOGo Mailer */
|
|
|
|
|
|
|
|
/*
|
|
|
|
DOM ids available in mail list view:
|
|
|
|
row_$msgid
|
|
|
|
div_$msgid
|
|
|
|
readdiv_$msgid
|
|
|
|
unreaddiv_$msgid
|
|
|
|
|
|
|
|
Window Properties:
|
|
|
|
width, height
|
|
|
|
bool: resizable, scrollbars, toolbar, location, directories, status,
|
|
|
|
menubar, copyhistory
|
|
|
|
*/
|
|
|
|
|
|
|
|
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();
|
|
|
|
var currentMailbox = '';
|
|
|
|
/* mail list */
|
|
|
|
|
2006-10-03 18:27:02 +02:00
|
|
|
function openMessageWindow(msguid, url) {
|
2006-08-02 22:04:46 +02:00
|
|
|
log ("message window at url: " + url);
|
2006-10-03 18:27:02 +02:00
|
|
|
var wId = '';
|
|
|
|
if (msguid)
|
|
|
|
wId += "SOGo_msg_" + 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");
|
2006-07-29 00:59:11 +02:00
|
|
|
|
|
|
|
msgWin.focus();
|
2006-12-22 17:48:11 +01:00
|
|
|
markMailReadInWindow(window, msguid);
|
2006-10-03 18:27:02 +02:00
|
|
|
|
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onMessageDoubleClick(event) {
|
2006-07-29 00:59:11 +02:00
|
|
|
resetSelection(window);
|
2006-11-09 23:55:04 +01:00
|
|
|
var msguid = this.parentNode.id.substr(4);
|
2006-12-22 17:48:11 +01:00
|
|
|
|
2006-10-03 18:27:02 +02:00
|
|
|
return openMessageWindow(msguid,
|
|
|
|
ApplicationBaseURL + currentMailbox + "/"
|
2006-12-22 17:48:11 +01:00
|
|
|
+ msguid + "/popupview");
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleMailSelect(sender) {
|
|
|
|
var row;
|
2006-09-20 19:58:42 +02:00
|
|
|
row = $(sender.name);
|
2006-07-29 00:59:11 +02:00
|
|
|
row.className = sender.checked ? "tableview_selected" : "tableview";
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearSearch(sender) {
|
2006-09-20 19:58:42 +02:00
|
|
|
var searchField = window.$("search");
|
2006-07-29 00:59:11 +02:00
|
|
|
if (searchField) searchField.value="";
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mail editor */
|
|
|
|
|
|
|
|
function validateEditorInput(sender) {
|
|
|
|
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) {
|
2006-10-12 23:05:58 +02:00
|
|
|
alert(labels.error_validationfailed.decodeEntities() + ":\n"
|
|
|
|
+ errortext.decodeEntities());
|
2006-07-29 00:59:11 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function clickedEditorSend(sender) {
|
|
|
|
if (!validateEditorInput(sender))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
document.pageform.action="send";
|
|
|
|
document.pageform.submit();
|
|
|
|
// if everything is ok, close the window
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function clickedEditorAttach(sender) {
|
|
|
|
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 */
|
|
|
|
}
|
|
|
|
|
|
|
|
function clickedEditorSave(sender) {
|
|
|
|
document.pageform.action="save";
|
|
|
|
document.pageform.submit();
|
|
|
|
refreshOpener();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function clickedEditorDelete(sender) {
|
|
|
|
document.pageform.action="delete";
|
|
|
|
document.pageform.submit();
|
|
|
|
refreshOpener();
|
|
|
|
window.close();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function openAddressbook(sender) {
|
|
|
|
var urlstr;
|
|
|
|
|
2006-10-03 18:27:02 +02:00
|
|
|
urlstr = ApplicationBaseURL + "/../Contacts/?popup=YES";
|
2006-07-29 00:59:11 +02:00
|
|
|
var w = window.open(urlstr, "Addressbook",
|
2006-10-03 18:27:02 +02:00
|
|
|
"width=640,height=400,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();
|
|
|
|
|
2006-10-03 18:27:02 +02:00
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mail list DOM changes */
|
|
|
|
|
|
|
|
function markMailInWindow(win, msguid, markread) {
|
|
|
|
var msgDiv;
|
|
|
|
|
2006-09-20 19:58:42 +02:00
|
|
|
msgDiv = win.$("div_" + msguid);
|
2006-07-29 00:59:11 +02:00
|
|
|
if (msgDiv) {
|
|
|
|
if (markread) {
|
2006-08-22 21:22:42 +02:00
|
|
|
msgDiv.removeClassName("mailer_unreadmailsubject");
|
|
|
|
msgDiv.addClassName("mailer_readmailsubject");
|
2006-09-20 19:58:42 +02:00
|
|
|
msgDiv = win.$("unreaddiv_" + msguid);
|
2006-08-01 21:04:28 +02:00
|
|
|
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);
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
else {
|
2006-08-22 21:22:42 +02:00
|
|
|
msgDiv.removeClassName('mailer_readmailsubject');
|
|
|
|
msgDiv.addClassName('mailer_unreadmailsubject');
|
2006-09-20 19:58:42 +02:00
|
|
|
msgDiv = win.$("readdiv_" + msguid);
|
2006-08-01 21:04:28 +02:00
|
|
|
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);
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function markMailReadInWindow(win, msguid) {
|
|
|
|
/* this is called by UIxMailView with window.opener */
|
|
|
|
return markMailInWindow(win, msguid, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* main window */
|
|
|
|
|
|
|
|
function reopenToRemoveLocationBar() {
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mail list reply */
|
|
|
|
|
2006-10-03 18:27:02 +02:00
|
|
|
function openMessageWindowsForSelection(action)
|
2006-07-31 22:24:50 +02:00
|
|
|
{
|
2006-09-20 19:58:42 +02:00
|
|
|
var messageList = $("messageList");
|
2006-08-19 00:40:04 +02:00
|
|
|
var rows = messageList.getSelectedRowsId();
|
2006-07-29 00:59:11 +02:00
|
|
|
var idset = "";
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
for (var i = 0; i < rows.length; i++)
|
2006-10-03 18:27:02 +02:00
|
|
|
win = openMessageWindow(rows[i].substr(4) /* msguid */,
|
2006-08-02 22:04:46 +02:00
|
|
|
ApplicationBaseURL + currentMailbox
|
2006-08-19 00:40:04 +02:00
|
|
|
+ "/" + rows[i].substr(4)
|
|
|
|
+ "/" + action /* url */);
|
2006-10-03 18:27:02 +02:00
|
|
|
|
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function mailListMarkMessage(event) {
|
2006-07-29 00:59:11 +02:00
|
|
|
var http = createHTTPClient();
|
2006-11-09 23:55:04 +01:00
|
|
|
var url = ApplicationBaseURL + currentMailbox + "/" + action + "?uid=" + msguid;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* maillist row highlight */
|
|
|
|
|
|
|
|
var oldMaillistHighlight = null; // to remember deleted/selected style
|
|
|
|
|
2006-08-01 20:01:00 +02:00
|
|
|
function ml_highlight(sender)
|
|
|
|
{
|
2006-07-29 00:59:11 +02:00
|
|
|
oldMaillistHighlight = sender.className;
|
|
|
|
if (oldMaillistHighlight == "tableview_highlight")
|
|
|
|
oldMaillistHighlight = null;
|
|
|
|
sender.className = "tableview_highlight";
|
|
|
|
}
|
2006-08-01 20:01:00 +02:00
|
|
|
|
|
|
|
function ml_lowlight(sender)
|
|
|
|
{
|
2006-07-29 00:59:11 +02:00
|
|
|
if (oldMaillistHighlight) {
|
|
|
|
sender.className = oldMaillistHighlight;
|
|
|
|
oldMaillistHighlight = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sender.className = "tableview";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* folder operations */
|
|
|
|
|
|
|
|
function ctxFolderAdd(sender) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ctxFolderDelete(sender) {
|
2006-10-12 23:05:58 +02:00
|
|
|
if (!confirm("Delete current folder?").decodeEntities())
|
2006-07-29 00:59:11 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// TODO: should use a form-POST or AJAX
|
|
|
|
window.location.href = "deleteFolder";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bulk delete of messages */
|
|
|
|
|
|
|
|
function uixDeleteSelectedMessages(sender) {
|
|
|
|
var failCount = 0;
|
|
|
|
|
2006-09-20 19:58:42 +02:00
|
|
|
var messageList = $("messageList");
|
2006-11-13 23:29:31 +01:00
|
|
|
var rowIds = messageList.getSelectedRowsId();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-11-13 23:29:31 +01:00
|
|
|
for (var i = 0; i < rowIds.length; i++) {
|
2006-08-25 22:47:33 +02:00
|
|
|
var url, http;
|
2006-11-13 23:29:31 +01:00
|
|
|
var rowId = rowIds[i].substr(4);
|
2006-07-29 00:59:11 +02:00
|
|
|
/* send AJAX request (synchronously) */
|
2006-11-10 23:59:39 +01:00
|
|
|
|
2006-11-13 23:29:31 +01:00
|
|
|
var messageId = currentMailbox + "/" + rowId;
|
2006-11-10 23:59:39 +01:00
|
|
|
url = ApplicationBaseURL + messageId + "/trash?jsonly=1";
|
2006-07-29 00:59:11 +02:00
|
|
|
http = createHTTPClient();
|
2006-11-10 23:59:39 +01:00
|
|
|
http.open("GET", url, false /* not async */);
|
2006-07-29 00:59:11 +02:00
|
|
|
http.send("");
|
|
|
|
if (http.status != 200) { /* request failed */
|
|
|
|
failCount++;
|
|
|
|
http = null;
|
|
|
|
continue;
|
2006-11-10 23:59:39 +01:00
|
|
|
} else {
|
|
|
|
deleteCachedMessage(messageId);
|
2006-11-13 23:29:31 +01:00
|
|
|
if (currentMessages[currentMailbox] == rowId) {
|
2006-11-10 23:59:39 +01:00
|
|
|
var div = $('messageContent');
|
|
|
|
div.innerHTML = "";
|
|
|
|
currentMessages[currentMailbox] = null;
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
http = null;
|
|
|
|
|
|
|
|
/* remove from page */
|
|
|
|
|
|
|
|
/* line-through would be nicer, but hiding is OK too */
|
2006-11-13 23:29:31 +01:00
|
|
|
var row = $(rowIds[i]);
|
|
|
|
row.parentNode.removeChild(row);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (failCount > 0)
|
|
|
|
alert("Could not delete " + failCount + " messages!");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-11-10 23:59:39 +01:00
|
|
|
function moveMessages(rowIds, folder) {
|
|
|
|
var failCount = 0;
|
|
|
|
|
|
|
|
for (var i = 0; i < rowIds.length; i++) {
|
|
|
|
var url, http;
|
|
|
|
|
|
|
|
/* send AJAX request (synchronously) */
|
|
|
|
|
|
|
|
var messageId = currentMailbox + "/" + rowIds[i];
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* request failed */
|
|
|
|
failCount++;
|
|
|
|
|
|
|
|
/* remove from page */
|
|
|
|
|
|
|
|
/* line-through would be nicer, but hiding is OK too */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (failCount > 0)
|
|
|
|
alert("Could not move " + failCount + " messages!");
|
|
|
|
|
|
|
|
return failCount;
|
|
|
|
}
|
|
|
|
|
2006-11-10 00:11:50 +01:00
|
|
|
function onMenuDeleteMessage(event) {
|
|
|
|
uixDeleteSelectedMessages();
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
|
2006-12-22 17:48:11 +01:00
|
|
|
function onMailboxTreeItemClick(event) {
|
2006-09-20 19:58:42 +02:00
|
|
|
var topNode = $('d');
|
2006-12-22 17:48:11 +01:00
|
|
|
var mailbox = this.parentNode.getAttribute("dataname");
|
2006-07-29 00:59:11 +02:00
|
|
|
|
|
|
|
if (topNode.selectedEntry)
|
2006-12-20 23:55:54 +01:00
|
|
|
topNode.selectedEntry.deselect();
|
2006-12-22 17:48:11 +01:00
|
|
|
this.select();
|
|
|
|
topNode.selectedEntry = this;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
|
|
|
openMailbox(mailbox);
|
2006-12-22 17:48:11 +01:00
|
|
|
event.preventDefault();
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2006-11-13 23:29:31 +01:00
|
|
|
function refreshMailbox() {
|
|
|
|
openMailbox(currentMailbox, true);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function openMailbox(mailbox, reload)
|
2006-07-29 00:59:11 +02:00
|
|
|
{
|
2006-11-13 23:29:31 +01:00
|
|
|
if (mailbox != currentMailbox || reload) {
|
2006-07-29 00:59:11 +02:00
|
|
|
currentMailbox = mailbox;
|
2006-08-01 20:01:00 +02:00
|
|
|
var url = ApplicationBaseURL + mailbox + "/view?noframe=1&desc=1";
|
2006-09-20 19:58:42 +02:00
|
|
|
var mailboxContent = $("mailboxContent");
|
|
|
|
var mailboxDragHandle = $("mailboxDragHandle");
|
|
|
|
var messageContent = $("messageContent");
|
2006-07-31 22:24:50 +02:00
|
|
|
messageContent.innerHTML = '';
|
2006-07-29 00:59:11 +02:00
|
|
|
if (mailbox.lastIndexOf("/") == 0) {
|
2006-07-31 22:24:50 +02:00
|
|
|
var url = (ApplicationBaseURL + currentMailbox + "/"
|
|
|
|
+ "/view?noframe=1");
|
|
|
|
if (document.messageAjaxRequest) {
|
|
|
|
document.messageAjaxRequest.aborted = true;
|
|
|
|
document.messageAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.messageAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, messageCallback);
|
|
|
|
mailboxContent.innerHTML = '';
|
2006-07-29 00:59:11 +02:00
|
|
|
mailboxContent.style.visibility = "hidden;";
|
|
|
|
mailboxDragHandle.style.visibility = "hidden;";
|
|
|
|
messageContent.style.top = "0px;";
|
|
|
|
} else {
|
2006-07-31 22:24:50 +02:00
|
|
|
if (document.messageListAjaxRequest) {
|
|
|
|
document.messageListAjaxRequest.aborted = true;
|
|
|
|
document.messageListAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
if (currentMessages[mailbox]) {
|
|
|
|
loadMessage(currentMessages[mailbox]);
|
|
|
|
url += '&pageforuid=' + currentMessages[mailbox];
|
|
|
|
}
|
|
|
|
document.messageListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, messageListCallback,
|
|
|
|
currentMessages[mailbox]);
|
2006-07-29 00:59:11 +02:00
|
|
|
if (mailboxContent.style.visibility == "hidden") {
|
|
|
|
mailboxContent.style.visibility = "visible;";
|
|
|
|
mailboxDragHandle.style.visibility = "visible;";
|
|
|
|
messageContent.style.top = (mailboxDragHandle.offsetTop
|
|
|
|
+ mailboxDragHandle.offsetHeight
|
|
|
|
+ 'px;');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// triggerAjaxRequest(mailbox, 'toolbar', toolbarCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
function openMailboxAtIndex(element) {
|
|
|
|
var idx = element.getAttribute("idx");
|
|
|
|
var url = ApplicationBaseURL + currentMailbox + "/view?noframe=1&idx=" + idx;
|
2006-07-31 22:24:50 +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
|
|
|
|
|
|
|
return false;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function messageListCallback(http)
|
|
|
|
{
|
2006-09-20 19:58:42 +02:00
|
|
|
var div = $('mailboxContent');
|
2006-08-01 20:01:00 +02:00
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
if (http.readyState == 4
|
2006-07-31 22:24:50 +02:00
|
|
|
&& http.status == 200) {
|
|
|
|
document.messageListAjaxRequest = null;
|
|
|
|
div.innerHTML = http.responseText;
|
|
|
|
var selected = http.callbackData;
|
|
|
|
if (selected) {
|
2006-09-20 19:58:42 +02:00
|
|
|
var row = $('row_' + selected);
|
2006-12-20 23:55:54 +01:00
|
|
|
row.select();
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
configureMessageListEvents();
|
|
|
|
configureSortableTableHeaders();
|
2006-07-31 22:24:50 +02:00
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
function onMessageContextMenu(event)
|
2006-08-01 22:03:50 +02:00
|
|
|
{
|
2006-09-20 19:58:42 +02:00
|
|
|
var menu = $('messageListMenu');
|
2006-08-01 22:31:56 +02:00
|
|
|
menu.addEventListener("hideMenu", onMessageContextMenuHide, false);
|
2006-08-01 22:03:50 +02:00
|
|
|
onMenuClick(event, 'messageListMenu');
|
|
|
|
|
2006-09-20 19:58:42 +02:00
|
|
|
var topNode = $('messageList');
|
2006-08-19 00:40:04 +02:00
|
|
|
var selectedNodes = topNode.getSelectedRows();
|
|
|
|
for (var i = 0; i < selectedNodes.length; i++)
|
2006-12-20 23:55:54 +01:00
|
|
|
selectedNodes[i].deselect();
|
2006-08-19 00:40:04 +02:00
|
|
|
topNode.menuSelectedRows = selectedNodes;
|
2006-12-14 22:20:13 +01:00
|
|
|
topNode.menuSelectedEntry = this;
|
2006-12-20 23:55:54 +01:00
|
|
|
this.select();
|
2006-08-01 22:03:50 +02:00
|
|
|
}
|
|
|
|
|
2006-08-01 22:31:56 +02:00
|
|
|
function onMessageContextMenuHide(event)
|
2006-08-01 22:03:50 +02:00
|
|
|
{
|
2006-09-20 19:58:42 +02:00
|
|
|
var topNode = $('messageList');
|
2006-08-02 22:04:46 +02:00
|
|
|
|
|
|
|
if (topNode.menuSelectedEntry) {
|
2006-12-20 23:55:54 +01:00
|
|
|
topNode.menuSelectedEntry.deselect();
|
2006-08-01 22:31:56 +02:00
|
|
|
topNode.menuSelectedEntry = null;
|
2006-08-02 22:04:46 +02:00
|
|
|
}
|
|
|
|
if (topNode.menuSelectedRows) {
|
2006-08-19 00:40:04 +02:00
|
|
|
var nodes = topNode.menuSelectedRows;
|
|
|
|
for (var i = 0; i < nodes.length; i++)
|
2006-12-20 23:55:54 +01:00
|
|
|
nodes[i].select();
|
2006-08-02 22:04:46 +02:00
|
|
|
topNode.menuSelectedRows = null;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-22 17:48:11 +01:00
|
|
|
function onFolderMenuClick(event, menutype)
|
2006-07-29 00:59:11 +02:00
|
|
|
{
|
|
|
|
var onhide, menuName;
|
|
|
|
|
|
|
|
if (menutype == "inbox") {
|
|
|
|
menuName = "inboxIconMenu";
|
|
|
|
} else if (menutype == "account") {
|
|
|
|
menuName = "accountIconMenu";
|
|
|
|
} else if (menutype == "trash") {
|
|
|
|
menuName = "trashIconMenu";
|
|
|
|
} else {
|
|
|
|
menuName = "mailboxIconMenu";
|
|
|
|
}
|
|
|
|
|
2006-09-20 19:58:42 +02:00
|
|
|
var menu = $(menuName);
|
2006-08-01 22:03:50 +02:00
|
|
|
menu.addEventListener("hideMenu", onFolderMenuHide, false);
|
2006-07-29 00:59:11 +02:00
|
|
|
onMenuClick(event, menuName);
|
|
|
|
|
2006-09-20 19:58:42 +02:00
|
|
|
var topNode = $('d');
|
2006-07-29 00:59:11 +02:00
|
|
|
if (topNode.selectedEntry)
|
2006-12-20 23:55:54 +01:00
|
|
|
topNode.selectedEntry.deselect();
|
2006-07-29 00:59:11 +02:00
|
|
|
if (topNode.menuSelectedEntry)
|
2006-12-20 23:55:54 +01:00
|
|
|
topNode.menuSelectedEntry.deselect();
|
2006-12-22 17:48:11 +01:00
|
|
|
topNode.menuSelectedEntry = this;
|
|
|
|
this.select();
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onFolderMenuHide(event)
|
|
|
|
{
|
2006-09-20 19:58:42 +02:00
|
|
|
var topNode = $('d');
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2006-08-02 22:04:46 +02:00
|
|
|
if (topNode.menuSelectedEntry) {
|
2006-12-20 23:55:54 +01:00
|
|
|
topNode.menuSelectedEntry.deselect();
|
2006-08-02 22:04:46 +02:00
|
|
|
topNode.menuSelectedEntry = null;
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
if (topNode.selectedEntry)
|
2006-12-20 23:55:54 +01:00
|
|
|
topNode.selectedEntry.select();
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2006-11-10 23:59:39 +01:00
|
|
|
function deleteCachedMessage(messageId) {
|
|
|
|
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-07-29 00:59:11 +02:00
|
|
|
function getCachedMessage(idx)
|
|
|
|
{
|
|
|
|
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++;
|
|
|
|
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
|
|
|
function storeCachedMessage(cachedMessage)
|
|
|
|
{
|
|
|
|
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++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oldest == -1)
|
|
|
|
oldest = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cachedMessages[oldest] = cachedMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMessageSelectionChange()
|
|
|
|
{
|
2006-11-09 23:55:04 +01:00
|
|
|
var rows = this.getSelectedRowsId();
|
2006-08-19 00:40:04 +02:00
|
|
|
if (rows.length == 1) {
|
|
|
|
var idx = rows[0].substr(4);
|
|
|
|
|
|
|
|
if (currentMessages[currentMailbox] != idx) {
|
|
|
|
currentMessages[currentMailbox] = idx;
|
|
|
|
loadMessage(idx);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadMessage(idx)
|
|
|
|
{
|
|
|
|
var cachedMessage = getCachedMessage(idx);
|
|
|
|
|
2006-07-31 22:24:50 +02:00
|
|
|
if (document.messageAjaxRequest) {
|
|
|
|
document.messageAjaxRequest.aborted = true;
|
|
|
|
document.messageAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
if (cachedMessage == null) {
|
|
|
|
var url = (ApplicationBaseURL + currentMailbox + "/"
|
|
|
|
+ idx + "/view?noframe=1");
|
2006-07-31 22:24:50 +02:00
|
|
|
document.messageAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, messageCallback, idx);
|
2006-07-29 00:59:11 +02:00
|
|
|
markMailInWindow(window, idx, true);
|
|
|
|
} else {
|
2006-09-20 19:58:42 +02:00
|
|
|
var div = $('messageContent');
|
2006-07-29 00:59:11 +02:00
|
|
|
div.innerHTML = cachedMessage['text'];
|
|
|
|
cachedMessage['time'] = (new Date()).getTime();
|
2006-07-31 22:24:50 +02:00
|
|
|
document.messageAjaxRequest = null;
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function messageCallback(http)
|
|
|
|
{
|
2006-09-20 19:58:42 +02:00
|
|
|
var div = $('messageContent');
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2006-07-31 22:24:50 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.messageAjaxRequest = null;
|
|
|
|
div.innerHTML = http.responseText;
|
|
|
|
|
|
|
|
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);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
2006-07-31 22:24:50 +02:00
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
|
|
|
function processMailboxMenuAction(mailbox)
|
|
|
|
{
|
|
|
|
var currentNode, upperNode;
|
|
|
|
var mailboxName;
|
|
|
|
var action;
|
|
|
|
|
|
|
|
mailboxName = mailbox.getAttribute('mailboxname');
|
|
|
|
currentNode = mailbox;
|
|
|
|
upperNode = null;
|
|
|
|
|
|
|
|
while (currentNode
|
|
|
|
&& !currentNode.hasAttribute('mailboxaction'))
|
|
|
|
currentNode = currentNode.parentNode.parentNode.parentMenuItem;
|
|
|
|
|
|
|
|
if (currentNode)
|
|
|
|
{
|
|
|
|
action = currentNode.getAttribute('mailboxaction');
|
2006-08-19 00:40:04 +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) {
|
|
|
|
e.style.display = shouldShow ? "" : "none";
|
|
|
|
}
|
|
|
|
|
|
|
|
function enableElement(e, shouldEnable) {
|
|
|
|
if(!e)
|
|
|
|
return;
|
|
|
|
if(shouldEnable) {
|
|
|
|
if(e.hasAttribute("disabled"))
|
|
|
|
e.removeAttribute("disabled");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
e.setAttribute("disabled", "1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function validateControls() {
|
2006-09-20 19:58:42 +02:00
|
|
|
var e = $("moveto");
|
2006-07-29 00:59:11 +02:00
|
|
|
this.enableElement(e, rowSelectionCount > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function moveTo(uri) {
|
|
|
|
alert("MoveTo: " + uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteSelectedMails()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* message menu entries */
|
|
|
|
function onMenuOpenMessage(event)
|
|
|
|
{
|
|
|
|
var node = getParentMenu(event.target).menuTarget.parentNode;
|
|
|
|
var msgId = node.getAttribute('id').substr(4);
|
|
|
|
|
2006-10-03 18:27:02 +02:00
|
|
|
return openMessageWindow(msgId,
|
|
|
|
ApplicationBaseURL + currentMailbox
|
|
|
|
+ "/" + msgId + "/view");
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* contacts */
|
|
|
|
function newContactFromEmail(sender) {
|
2006-09-19 23:11:53 +02:00
|
|
|
var mailto = sender.parentNode.parentNode.menuTarget.innerHTML;
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
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;
|
2006-09-19 23:11:53 +02:00
|
|
|
emailre.exec(mailto);
|
2006-07-29 00:59:11 +02:00
|
|
|
email = RegExp.$1;
|
|
|
|
|
2006-09-19 23:11:53 +02:00
|
|
|
var namere = /(\w[\w\ _-]+)\ (<|<)/;
|
|
|
|
var c_name = '';
|
|
|
|
if (namere.test(mailto)) {
|
|
|
|
namere.exec(mailto);
|
|
|
|
c_name += RegExp.$1;
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
if (email.length > 0)
|
|
|
|
{
|
|
|
|
emailre.exec("");
|
2006-09-19 23:11:53 +02:00
|
|
|
var url = UserFolderURL + "Contacts/new?contactEmail=" + email;
|
|
|
|
if (c_name)
|
|
|
|
url += "&contactFN=" + c_name;
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
|
|
|
|
|
|
|
function newEmailTo(sender) {
|
2006-09-16 00:27:59 +02:00
|
|
|
return openMailTo(sender.parentNode.parentNode.menuTarget.innerHTML);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2006-07-31 22:24:50 +02:00
|
|
|
function expandUpperTree(node)
|
|
|
|
{
|
|
|
|
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 = d.aNodes[number];
|
|
|
|
d.nodeStatus(1, number, cn._ls);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
currentNode = currentNode.parentNode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
function initMailboxSelection(mailboxName)
|
|
|
|
{
|
|
|
|
currentMailbox = mailboxName;
|
|
|
|
|
2006-09-20 19:58:42 +02:00
|
|
|
var tree = $("d");
|
2006-11-09 23:55:04 +01:00
|
|
|
var treeNodes = document.getElementsByClassName("dTreeNode", tree);
|
2006-07-29 00:59:11 +02:00
|
|
|
var i = 0;
|
|
|
|
while (i < treeNodes.length
|
|
|
|
&& treeNodes[i].getAttribute("dataname") != currentMailbox)
|
|
|
|
i++;
|
|
|
|
if (i < treeNodes.length) {
|
2006-11-09 23:55:04 +01:00
|
|
|
var links = document.getElementsByClassName("node", treeNodes[i]);
|
2006-07-29 00:59:11 +02:00
|
|
|
if (tree.selectedEntry)
|
2006-12-20 23:55:54 +01:00
|
|
|
tree.selectedEntry.deselect();
|
|
|
|
links[0].select();
|
2006-07-29 00:59:11 +02:00
|
|
|
tree.selectedEntry = links[0];
|
2006-07-31 22:24:50 +02:00
|
|
|
expandUpperTree(links[0]);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onHeaderClick(event)
|
2006-08-01 20:01:00 +02:00
|
|
|
{
|
|
|
|
if (document.messageListAjaxRequest) {
|
|
|
|
document.messageListAjaxRequest.aborted = true;
|
|
|
|
document.messageListAjaxRequest.abort();
|
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
url = ApplicationBaseURL + currentMailbox + "/" + this.link;
|
|
|
|
if (!this.link.match(/noframe=/))
|
2006-08-01 20:01:00 +02:00
|
|
|
url += "&noframe=1";
|
|
|
|
document.messageListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, messageListCallback);
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
event.preventDefault();
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
2006-08-31 01:13:28 +02:00
|
|
|
|
|
|
|
function onSearchFormSubmit()
|
|
|
|
{
|
|
|
|
log ("search not implemented");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-23 16:56:32 +02:00
|
|
|
|
2006-11-09 00:49:09 +01:00
|
|
|
function pouetpouet(event) {
|
|
|
|
window.alert("pouet pouet");
|
|
|
|
}
|
|
|
|
|
|
|
|
var mailboxSpanAcceptType = function(type) {
|
|
|
|
return (type == "mailRow");
|
|
|
|
}
|
|
|
|
|
|
|
|
var mailboxSpanEnter = function() {
|
|
|
|
this.addClassName("_dragOver");
|
|
|
|
}
|
|
|
|
|
|
|
|
var mailboxSpanExit = function() {
|
|
|
|
this.removeClassName("_dragOver");
|
|
|
|
}
|
|
|
|
|
2006-11-10 23:59:39 +01:00
|
|
|
var mailboxSpanDrop = function(data) {
|
|
|
|
var success = false;
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
var folder = this.parentNode.parentNode.getAttribute("dataname");
|
|
|
|
if (folder != currentMailbox)
|
|
|
|
success = (moveMessages(data, folder) == 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
success = false;
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
var plusSignEnter = function() {
|
|
|
|
var nodeNr = parseInt(this.id.substr(2));
|
|
|
|
if (!d.aNodes[nodeNr]._io)
|
|
|
|
this.plusSignTimer = setTimeout("openPlusSign('" + nodeNr + "');", 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
var plusSignExit = function() {
|
|
|
|
if (this.plusSignTimer) {
|
|
|
|
clearTimeout(this.plusSignTimer);
|
|
|
|
this.plusSignTimer = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function openPlusSign(nodeNr) {
|
|
|
|
d.nodeStatus(1, nodeNr, d.aNodes[nodeNr]._ls);
|
|
|
|
d.aNodes[nodeNr]._io = 1;
|
|
|
|
this.plusSignTimer = null;
|
|
|
|
}
|
|
|
|
|
2006-11-09 00:49:09 +01:00
|
|
|
var messageListGhost = function () {
|
|
|
|
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;
|
|
|
|
|
|
|
|
var imgCode = '<img src="' + ResourcesURL + '/message-mail.png" />';
|
2006-11-13 23:29:31 +01:00
|
|
|
|
|
|
|
var current = this;
|
|
|
|
while (!current.getSelectedRows)
|
|
|
|
current = current.parentNode;
|
|
|
|
var count = current.getSelectedRows().length;
|
2006-11-09 00:49:09 +01:00
|
|
|
var text = imgCode + '<br />' + count + ' messages...';
|
|
|
|
newDiv.innerHTML = text;
|
|
|
|
|
|
|
|
return newDiv;
|
|
|
|
}
|
|
|
|
|
2006-11-10 23:59:39 +01:00
|
|
|
var messageListData = function(type) {
|
|
|
|
var rows = this.getSelectedRowsId();
|
|
|
|
var msgIds = new Array();
|
|
|
|
for (var i = 0; i < rows.length; i++)
|
|
|
|
msgIds.push(rows[i].substr(4));
|
|
|
|
|
|
|
|
return msgIds;
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function configureMessageListEvents() {
|
|
|
|
var messageList = $("messageList");
|
|
|
|
if (messageList) {
|
|
|
|
messageList.addEventListener("selectionchange",
|
|
|
|
onMessageSelectionChange, false);
|
|
|
|
var rows = messageList.tBodies[0].rows;
|
|
|
|
var start = 0;
|
|
|
|
while (rows[start].cells[0].hasClassName("tbtv_headercell")
|
|
|
|
|| rows[start].cells[0].hasClassName("tbtv_navcell"))
|
|
|
|
start++;
|
|
|
|
for (var i = start; i < rows.length; i++) {
|
2006-11-10 23:59:39 +01:00
|
|
|
rows[i].addEventListener("mousedown", onRowClick, false);
|
2006-11-09 23:55:04 +01:00
|
|
|
rows[i].addEventListener("contextmenu", onMessageContextMenu, false);
|
2006-11-13 23:29:31 +01:00
|
|
|
|
|
|
|
rows[i].dndTypes = function() { return new Array("mailRow"); };
|
|
|
|
rows[i].dndGhost = messageListGhost;
|
|
|
|
rows[i].dndDataForType = messageListData;
|
|
|
|
document.DNDManager.registerSource(rows[i]);
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
for (var j = 0; j < rows[i].cells.length; j++) {
|
|
|
|
var cell = rows[i].cells[j];
|
2006-11-10 23:59:39 +01:00
|
|
|
cell.addEventListener("mousedown", listRowMouseDownHandler, false);
|
2006-11-09 23:55:04 +01:00
|
|
|
if (j == 2 || j == 3 || j == 5)
|
|
|
|
cell.addEventListener("dblclick", onMessageDoubleClick, false);
|
|
|
|
else if (j == 4) {
|
|
|
|
var img = cell.childNodesWithTag("img")[0];
|
|
|
|
img.addEventListener("click", mailListMarkMessage, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function configureDragHandles() {
|
|
|
|
var handle = $("dragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.leftBlock=$("mailerFolderTree");
|
|
|
|
handle.rightBlock=$("mailerPageContent");
|
|
|
|
}
|
|
|
|
|
|
|
|
handle = $("mailboxDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.upperBlock=$("mailboxContent");
|
|
|
|
handle.lowerBlock=$("messageContent");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-22 17:48:11 +01:00
|
|
|
function configureDragHandles() {
|
|
|
|
var handle = $("verticalDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.leftBlock=$("leftPanel");
|
|
|
|
handle.rightBlock=$("rightPanel");
|
|
|
|
}
|
|
|
|
|
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.upperBlock=$("mailboxContent");
|
|
|
|
handle.lowerBlock=$("messageContent");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-09 00:49:09 +01:00
|
|
|
/* dnd */
|
|
|
|
function initDnd() {
|
|
|
|
log ("MailerUI initDnd");
|
2006-11-10 23:59:39 +01:00
|
|
|
|
|
|
|
var tree = $("d");
|
|
|
|
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("leaf", tree);
|
2006-11-09 00:49:09 +01:00
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
2006-11-10 23:59:39 +01:00
|
|
|
nodes[i].dndAcceptType = mailboxSpanAcceptType;
|
|
|
|
nodes[i].dndEnter = mailboxSpanEnter;
|
|
|
|
nodes[i].dndExit = mailboxSpanExit;
|
2006-12-22 17:48:11 +01:00
|
|
|
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-11-09 00:49:09 +01:00
|
|
|
var initMailer = {
|
|
|
|
handleEvent: function (event) {
|
2006-11-09 23:55:04 +01:00
|
|
|
configureMessageListEvents();
|
2006-11-10 00:11:50 +01:00
|
|
|
initDnd();
|
2006-12-22 17:48:11 +01:00
|
|
|
var tree = $("d");
|
|
|
|
var nodes = document.getElementsByClassName("node", tree);
|
|
|
|
nodes = nodes.concat(document.getElementsByClassName("nodeSel", tree));
|
|
|
|
for (i = 0; i < nodes.length; i++) {
|
|
|
|
nodes[i].addEventListener("click", onMailboxTreeItemClick, false);
|
|
|
|
nodes[i].addEventListener("contextmenu", onFolderMenuClick, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
, 'onMailboxTreeItemClick(this);'
|
|
|
|
<!-- if (typeof(node.datatype) != "undefined") str += ' oncontextmenu="onFolderMenuClick(event, this);"';
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2006-11-09 00:49:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
function initializeMenus() {
|
|
|
|
var menus = new Array("accountIconMenu", "inboxIconMenu", "trashIconMenu",
|
|
|
|
"mailboxIconMenu", "addressMenu", "messageListMenu",
|
|
|
|
"messageContentMenu", "label-menu", "mailboxes-menu",
|
|
|
|
"mark-menu", "searchMenu");
|
|
|
|
initMenusNamed(menus);
|
|
|
|
}
|
|
|
|
|
2006-11-09 00:49:09 +01:00
|
|
|
window.addEventListener("load", initMailer, false);
|