diff --git a/mailnews/base/resources/content/commandglue.js b/mailnews/base/resources/content/commandglue.js index 45227901433..2186959770b 100644 --- a/mailnews/base/resources/content/commandglue.js +++ b/mailnews/base/resources/content/commandglue.js @@ -576,6 +576,9 @@ function ConvertColumnIDToSortType(columnID) case "idCol": sortKey = nsMsgViewSortType.byId; break; + case "attachmentCol": + sortKey = nsMsgViewSortType.byAttachments; + break; default: dump("unsupported sort column: " + columnID + "\n"); sortKey = 0; @@ -638,6 +641,9 @@ function ConvertSortTypeToColumnID(sortKey) case nsMsgViewSortType.byJunkStatus: columnID = "junkStatusCol"; break; + case nsMsgViewSortType.byAttachments: + columnID = "attachmentCol"; + break; default: dump("unsupported sort key: " + sortKey + "\n"); columnID = null; diff --git a/mailnews/base/resources/content/mailWindowOverlay.js b/mailnews/base/resources/content/mailWindowOverlay.js index a91656a924f..7f45cebe5e5 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.js +++ b/mailnews/base/resources/content/mailWindowOverlay.js @@ -221,6 +221,7 @@ function InitViewSortByMenu() setSortByMenuItemCheckState("sortByJunkStatusMenuitem", (sortType == nsMsgViewSortType.byJunkStatus)); setSortByMenuItemCheckState("sortBySenderMenuitem", (sortType == nsMsgViewSortType.byAuthor)); setSortByMenuItemCheckState("sortByRecipientMenuitem", (sortType == nsMsgViewSortType.byRecipient)); + setSortByMenuItemCheckState("sortByAttachmentsMenuitem", (sortType == nsMsgViewSortType.byAttachments)); var sortOrder = gDBView.sortOrder; var sortTypeSupportsGrouping = (sortType == nsMsgViewSortType.byAuthor diff --git a/mailnews/base/resources/content/mailWindowOverlay.xul b/mailnews/base/resources/content/mailWindowOverlay.xul index 694621aa9a8..55c110e990c 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.xul +++ b/mailnews/base/resources/content/mailWindowOverlay.xul @@ -1238,6 +1238,7 @@ + diff --git a/mailnews/base/resources/content/msgMail3PaneWindow.js b/mailnews/base/resources/content/msgMail3PaneWindow.js index 56f1ec8d2d5..82fa05b92bf 100644 --- a/mailnews/base/resources/content/msgMail3PaneWindow.js +++ b/mailnews/base/resources/content/msgMail3PaneWindow.js @@ -918,6 +918,12 @@ function OnFolderUnreadColAttrModified(event) } } +function OnAttachmentColAttrModified(event) +{ + if (event.attrName == "hidden") + UpdateAttachmentCol(false); +} + function UpgradeFolderPaneUI() { // placeholder in case any new columns get added to the folder pane @@ -962,36 +968,37 @@ function OnLoadFolderPane() // "mailnews.ui.threadpane.version" pref. function UpgradeThreadPaneUI() { - var threadPaneUIVersion; - try { - threadPaneUIVersion = pref.getIntPref("mailnews.ui.threadpane.version"); - if (threadPaneUIVersion < 4) { - var threadTree = document.getElementById("threadTree"); - var junkCol = document.getElementById("junkStatusCol"); - var beforeCol; - - if (threadPaneUIVersion < 3) { - var subjectCol = document.getElementById("subjectCol"); - + var threadTree = document.getElementById("threadTree"); + var junkCol = document.getElementById("junkStatusCol"); + var subjectCol = document.getElementById("subjectCol"); + var beforeCol; + switch (pref.getIntPref("mailnews.ui.threadpane.version")) { + case 1: // upgrade from 1 to 2 + case 2: // upgrade from 2 to 3 beforeCol = subjectCol.boxObject.nextSibling.boxObject.nextSibling; if (beforeCol) threadTree._reorderColumn(junkCol, beforeCol, true); else // subjectCol was the last column, put it after threadTree._reorderColumn(junkCol, subjectCol, false); - } - var senderCol = document.getElementById("senderCol"); - var recipientCol = document.getElementById("recipientCol"); - - beforeCol = junkCol.boxObject.nextSibling.boxObject.nextSibling; - if (beforeCol) - threadTree._reorderColumn(recipientCol, beforeCol, true); - else // junkCol was the last column, put it after - threadTree._reorderColumn(recipientCol, junkCol, false); - threadTree._reorderColumn(senderCol, recipientCol, true); + case 3: // upgrade from 3 to 4 + var senderCol = document.getElementById("senderCol"); + var recipientCol = document.getElementById("recipientCol"); + beforeCol = junkCol.boxObject.nextSibling.boxObject.nextSibling; + if (beforeCol) + threadTree._reorderColumn(recipientCol, beforeCol, true); + else // junkCol was the last column, put it after + threadTree._reorderColumn(recipientCol, junkCol, false); + threadTree._reorderColumn(senderCol, recipientCol, true); - pref.setIntPref("mailnews.ui.threadpane.version", 4); + case 4: // upgrade from 4 to 5 + var attachmentCol = document.getElementById("attachmentCol"); + threadTree._reorderColumn(attachmentCol, subjectCol, true); + pref.setIntPref("mailnews.ui.threadpane.version", 5); + + default: // already upgraded + break; } } catch (ex) { @@ -1002,6 +1009,18 @@ function UpgradeThreadPaneUI() function OnLoadThreadPane() { UpgradeThreadPaneUI(); + UpdateAttachmentCol(true); +} + +function UpdateAttachmentCol(aFirstTimeFlag) +{ + var attachmentCol = document.getElementById("attachmentCol"); + var threadTree = GetThreadTree(); + threadTree.setAttribute("noattachcol", attachmentCol.getAttribute("hidden")); + if (aFirstTimeFlag) + attachmentCol.addEventListener("DOMAttrModified", OnAttachmentColAttrModified, false); + else + threadTree.treeBoxObject.clearStyleAndImageCaches(); } function GetFolderDatasource() diff --git a/mailnews/base/resources/content/threadPane.xul b/mailnews/base/resources/content/threadPane.xul index 6a1bdbf30e2..945d3ea3b29 100644 --- a/mailnews/base/resources/content/threadPane.xul +++ b/mailnews/base/resources/content/threadPane.xul @@ -49,13 +49,17 @@