diff --git a/UI/WebServerResources/MailerUI.css b/UI/WebServerResources/MailerUI.css
index d241fd35c..3f0108d1d 100644
--- a/UI/WebServerResources/MailerUI.css
+++ b/UI/WebServerResources/MailerUI.css
@@ -234,6 +234,10 @@ DIV#folderTreeContent TABLE TD
margin: 0px;
padding: 0px; }
+/* mailbox tree (dtree) */
+DIV.dTreeNode SPAN.unseen
+{ font-weight: bold; }
+
/* mail tableview */
TD.mailer_readmailsubject
diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js
index 8ab294853..2c422364d 100644
--- a/UI/WebServerResources/MailerUI.js
+++ b/UI/WebServerResources/MailerUI.js
@@ -102,39 +102,54 @@ function onMenuSharing(event) {
function markMailInWindow(win, msguid, markread) {
var row = win.$("row_" + msguid);
var subjectCell = win.$("div_" + msguid);
+ var unseenCount = 0;
+
if (row && subjectCell) {
if (markread) {
- row.removeClassName("mailer_unreadmail");
- subjectCell.addClassName("mailer_readmailsubject");
- var img = win.$("unreaddiv_" + msguid);
- if (img) {
- img.removeClassName("mailerUnreadIcon");
- img.addClassName("mailerReadIcon");
- img.setAttribute("id", "readdiv_" + msguid);
- img.setAttribute("src", ResourcesURL + "/icon_read.gif");
- var title = img.getAttribute("title-markunread");
- if (title)
- img.setAttribute("title", title);
- }
+ if (row.hasClassName("mailer_unreadmail")) {
+ row.removeClassName("mailer_unreadmail");
+ subjectCell.addClassName("mailer_readmailsubject");
+ var img = win.$("unreaddiv_" + msguid);
+ if (img) {
+ img.removeClassName("mailerUnreadIcon");
+ img.addClassName("mailerReadIcon");
+ img.setAttribute("id", "readdiv_" + msguid);
+ img.setAttribute("src", ResourcesURL + "/icon_read.gif");
+ var title = img.getAttribute("title-markunread");
+ if (title)
+ img.setAttribute("title", title);
+ }
+ unseenCount = -1;
+ }
+ }
+ else {
+ if (!row.hasClassName("mailer_unreadmail")) {
+ row.addClassName("mailer_unreadmail");
+ subjectCell.removeClassName('mailer_readmailsubject');
+ var img = win.$("readdiv_" + msguid);
+ if (img) {
+ img.removeClassName("mailerReadIcon");
+ img.addClassName("mailerUnreadIcon");
+ img.setAttribute("id", "unreaddiv_" + msguid);
+ img.setAttribute("src", ResourcesURL + "/icon_unread.gif");
+ var title = img.getAttribute("title-markread");
+ if (title)
+ img.setAttribute("title", title);
+ }
+ unseenCount = 1;
+ }
}
- else {
- row.addClassName("mailer_unreadmail");
- subjectCell.removeClassName('mailer_readmailsubject');
- var img = win.$("readdiv_" + msguid);
- if (img) {
- img.removeClassName("mailerReadIcon");
- img.addClassName("mailerUnreadIcon");
- img.setAttribute("id", "unreaddiv_" + msguid);
- img.setAttribute("src", ResourcesURL + "/icon_unread.gif");
- var title = img.getAttribute("title-markread");
- if (title)
- img.setAttribute("title", title);
- }
- }
- return true;
}
- else
- return false;
+
+ if (unseenCount != 0) {
+ /* Update unseen count only if it's the inbox */
+ for (var i = 0; i < mailboxTree.aNodes.length; i++)
+ if (mailboxTree.aNodes[i].datatype == "inbox") break;
+ if (i != mailboxTree.aNodes.length && Mailer.currentMailbox == mailboxTree.aNodes[i].dataname)
+ updateStatusFolders(unseenCount, true);
+ }
+
+ return (unseenCount != 0);
}
function markMailReadInWindow(win, msguid) {
@@ -277,8 +292,8 @@ function deleteSelectedMessagesCallback(http) {
div.update();
Mailer.currentMessages[Mailer.currentMailbox] = null;
}
+ var row = $("row_" + data["id"][i]);
if (deleteMessageRequestCount == 0) {
- var row = $("row_" + data["id"][i]);
var nextRow = row.next("tr");
if (!nextRow)
nextRow = row.previous("tr");
@@ -289,10 +304,11 @@ function deleteSelectedMessagesCallback(http) {
loadMessage(Mailer.currentMessages[Mailer.currentMailbox]);
}
else {
- div.innerHTML = "";
+ div.update();
}
refreshCurrentFolder();
}
+ row.parentNode.removeChild(row);
}
}
}
@@ -345,14 +361,10 @@ function moveMessages(rowIds, folder) {
if (failCount > 0)
alert("Could not move " + failCount + " messages!");
-
+
return failCount;
}
-function moveMessagesCallback(http) {
- alert("messages are teh moved");
-}
-
function onMenuDeleteMessage(event) {
deleteSelectedMessages();
preventDefault(event);
@@ -489,7 +501,7 @@ function composeNewMessage() {
openMailComposeWindow(url);
}
-function openMailbox(mailbox, reload, idx) {
+function openMailbox(mailbox, reload, idx, updateStatus) {
if (mailbox != Mailer.currentMailbox || reload) {
Mailer.currentMailbox = mailbox;
var url = ApplicationBaseURL + encodeURI(mailbox) + "/view?noframe=1";
@@ -539,6 +551,9 @@ function openMailbox(mailbox, reload, idx) {
document.messageListAjaxRequest
= triggerAjaxRequest(url, messageListCallback,
currentMessage);
+
+ if (updateStatus != false)
+ getStatusFolders();
}
}
@@ -620,6 +635,46 @@ function messageListCallback(http) {
}
}
+function getStatusFolders() {
+ var account = Mailer.currentMailbox.split("/")[1];
+ var url = ApplicationBaseURL + encodeURI(account) + '/statusFolders';
+ if (document.statusFoldersAjaxRequest) {
+ document.statusFoldersAjaxRequest.aborted = true;
+ document.statusFoldersAjaxRequest.abort();
+ }
+ document.statusFoldersAjaxRequest = triggerAjaxRequest(url, statusFoldersCallback);
+}
+
+function statusFoldersCallback(http) {
+ var div = $('mailboxContent');
+ var table = $('messageList');
+
+ if (http.status == 200) {
+ document.statusFoldersAjaxRequest = null;
+ var data = http.responseText.evalJSON(true);
+ updateStatusFolders(data.unseen, false);
+ }
+}
+
+function updateStatusFolders(count, isDelta) {
+ var span = $("unseenCount");
+ var counter = span.select("SPAN").first();
+
+ if (typeof count == "undefined")
+ count = parseInt(counter.innerHTML);
+ else if (isDelta)
+ count += parseInt(counter.innerHTML);
+ counter.update(count);
+ if (count > 0) {
+ span.setStyle({ display: "inline" });
+ span.up("SPAN").addClassName("unseen");
+ }
+ else {
+ span.setStyle({ display: "none" });
+ span.up("SPAN").removeClassName("unseen");
+ }
+}
+
function onMessageContextMenu(event) {
var menu = $('messageListMenu');
var topNode = $('messageList');
@@ -798,7 +853,7 @@ function configureLoadImagesButton() {
if (typeof(displayLoadImages) == "undefined" ||
displayLoadImages == null ||
displayLoadImages.value == 0) {
- loadImagesButton.style.display = 'none';
+ loadImagesButton.setStyle({ display: 'none' });
}
}
@@ -1350,7 +1405,7 @@ function refreshContacts() {
function openInbox(node) {
var done = false;
- openMailbox(node.parentNode.getAttribute("dataname"));
+ openMailbox(node.parentNode.getAttribute("dataname"), null, null, false);
var tree = $("mailboxTree");
tree.selectedEntry = node;
node.selectElement();
@@ -1599,6 +1654,7 @@ function onLoadMailboxesCallback(http) {
updateMailboxMenus();
checkAjaxRequestsState();
getFoldersState();
+ updateStatusFolders();
}
}
}
@@ -1625,6 +1681,7 @@ function buildMailboxes(accountName, encoded) {
var accountIndex = mailAccounts.indexOf(accountName);
var data = encoded.evalJSON(true);
var mailboxes = data.mailboxes;
+ var unseen = (data.status? data.status.unseen : 0);
if (data.quotas)
Mailer.quotas = data.quotas;
@@ -1645,8 +1702,11 @@ function buildMailboxes(accountName, encoded) {
if (leaf)
leaf.type = mailboxes[i].type;
else {
- leaf = new Mailbox(mailboxes[i].type, basename);
- currentNode.addMailbox(leaf);
+ if (mailboxes[i].type == 'inbox')
+ leaf = new Mailbox(mailboxes[i].type, basename, unseen);
+ else
+ leaf = new Mailbox(mailboxes[i].type, basename);
+ currentNode.addMailbox(leaf);
}
}
@@ -2015,9 +2075,10 @@ function getMenus() {
FastInit.addOnLoad(initMailer);
-function Mailbox(type, name) {
+function Mailbox(type, name, unseen) {
this.type = type;
this.name = name;
+ this.unseen = unseen;
this.parentFolder = null;
this.children = new Array();
return this;
diff --git a/UI/WebServerResources/MailerUIdTree.js b/UI/WebServerResources/MailerUIdTree.js
index b14fb03f6..57378fc3f 100644
--- a/UI/WebServerResources/MailerUIdTree.js
+++ b/UI/WebServerResources/MailerUIdTree.js
@@ -11,22 +11,27 @@ var MailerUIdTreeExtension = {
sent: labels["SentFolderName"],
draft: labels["DraftsFolderName"],
trash: labels["TrashFolderName"] },
- _addFolderNode: function (parent, name, fullName, type) {
+ _addFolderNode: function (parent, name, fullName, type, unseen) {
var icon = this.folderIcons[type];
if (icon)
icon = ResourcesURL + "/" + icon;
else
icon = "";
var displayName = this.folderNames[type];
+ var hasUnseen = false;
if (!displayName)
displayName = name;
+ if (typeof unseen != "undefined") {
+ hasUnseen = true;
+ displayName += " (" + parseInt(unseen) + ")";
+ }
this.add(this.elementCounter, parent, displayName, 1, '#', fullName,
- type, '', '', icon, icon);
+ type, '', '', icon, icon, hasUnseen);
this.elementCounter++;
},
_addFolder: function (parent, folder) {
var thisCounter = this.elementCounter;
- this._addFolderNode(parent, folder.name, folder.fullName(), folder.type);
+ this._addFolderNode(parent, folder.name, folder.fullName(), folder.type, folder.unseen);
for (var i = 0; i < folder.children.length; i++)
this._addFolder(thisCounter, folder.children[i]);
},
diff --git a/UI/WebServerResources/dtree.js b/UI/WebServerResources/dtree.js
index 8e5b6274d..8d0f91d7d 100644
--- a/UI/WebServerResources/dtree.js
+++ b/UI/WebServerResources/dtree.js
@@ -11,7 +11,7 @@
// Node object
function Node(id, pid, name, isParent, url, dataname, datatype, title, target,
- icon, iconOpen, open) {
+ icon, iconOpen, open, hasUnseen) {
this.isParent = isParent;
this.id = id;
this.pid = pid;
@@ -23,6 +23,7 @@ function Node(id, pid, name, isParent, url, dataname, datatype, title, target,
this.iconOpen = iconOpen;
this.dataname = dataname;
this.datatype = datatype;
+ this.hasUnseen = hasUnseen;
this._io = open || false;
this._is = false;
this._ls = false;
@@ -74,10 +75,10 @@ function dTree(objName) {
// Adds a new node to the node array
dTree.prototype.add = function(id, pid, name, isParent, url, datatype,
- title, target, icon, iconOpen, open) {
+ title, target, icon, iconOpen, open, hasUnseen) {
this.aNodes[this.aNodes.length] = new Node(id, pid, name, isParent, url,
datatype, title, target, icon,
- iconOpen, open);
+ iconOpen, open, false, hasUnseen);
};
// Open/close all nodes
@@ -160,6 +161,8 @@ dTree.prototype.node = function(node, nodeId) {
str += '' + node.name + '';
if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '';
str += '';
diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js
index 9114c9841..6fb99f911 100644
--- a/UI/WebServerResources/generic.js
+++ b/UI/WebServerResources/generic.js
@@ -545,8 +545,10 @@ function onRowClick(event) {
if (node.tagName == 'TD') {
node = node.parentNode; // select TR
- rowIndex = node.rowIndex - $(node).up('table').down('thead').getElementsByTagName('tr').length;
}
+ if (node.tagName == 'TR') {
+ rowIndex = node.rowIndex - $(node).up('table').down('thead').getElementsByTagName('tr').length;
+ }
else if (node.tagName == 'LI') {
// Find index of clicked row
var list = node.parentNode;
@@ -593,7 +595,7 @@ function onRowClick(event) {
// Single line selection
$(node.parentNode).deselectAll();
$(node).selectElement();
-
+
if (initialSelection != $(node.parentNode).getSelectedNodes()) {
// Selection has changed; fire mousedown event
var parentNode = node.parentNode;