2000-06-21 06:34:59 +00:00
|
|
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code, released
|
|
|
|
* March 31, 1998.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
2000-09-01 03:28:13 +00:00
|
|
|
var gOldNumSelected = 0;
|
2000-06-21 06:34:59 +00:00
|
|
|
function ThreadPaneOnClick(event)
|
|
|
|
{
|
2000-12-30 20:48:15 +00:00
|
|
|
var t = event.originalTarget;
|
2000-09-07 08:17:32 +00:00
|
|
|
|
|
|
|
if (t.localName != "treecell" &&
|
|
|
|
t.localName != "treeitem" &&
|
|
|
|
t.localName != "image")
|
2000-06-22 06:20:14 +00:00
|
|
|
return;
|
2000-08-16 22:54:43 +00:00
|
|
|
|
2000-12-30 20:48:15 +00:00
|
|
|
// fix for #48424. bail out of here when the user is
|
|
|
|
// clicking on the column headers
|
|
|
|
if (t.localName == "treecell") {
|
|
|
|
if (t.parentNode && (t.parentNode.getAttribute("id") == "headRow")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var targetclass = "";
|
2000-09-07 08:17:32 +00:00
|
|
|
|
|
|
|
if (t.localName == "image" && (t.getAttribute('twisty') != 'true'))
|
|
|
|
targetclass = t.parentNode.getAttribute('class');
|
2000-08-16 07:26:45 +00:00
|
|
|
|
2000-08-16 22:54:43 +00:00
|
|
|
//dump('targetclass = ' + targetclass + '\n');
|
2000-06-21 06:34:59 +00:00
|
|
|
|
2000-08-12 01:08:09 +00:00
|
|
|
if(targetclass.indexOf('unreadcol') != -1)
|
|
|
|
{
|
2000-09-07 08:17:32 +00:00
|
|
|
ToggleMessageRead(t.parentNode.parentNode.parentNode);
|
2000-08-12 01:08:09 +00:00
|
|
|
}
|
|
|
|
if(targetclass.indexOf('flagcol') != -1)
|
|
|
|
{
|
2000-09-07 08:17:32 +00:00
|
|
|
ToggleMessageFlagged(t.parentNode.parentNode.parentNode);
|
2000-08-12 01:08:09 +00:00
|
|
|
}
|
2000-09-07 08:17:32 +00:00
|
|
|
else if (t.getAttribute('twisty') == 'true') {
|
2000-06-21 06:34:59 +00:00
|
|
|
// The twisty is nested three below the treeitem:
|
|
|
|
// <treeitem>
|
|
|
|
// <treerow>
|
|
|
|
// <treecell>
|
2000-11-25 01:19:03 +00:00
|
|
|
// <button class="tree-cell-twisty"> <!-- anonymous -->
|
2000-09-07 08:17:32 +00:00
|
|
|
var treeitem = t.parentNode.parentNode.parentNode;
|
2000-06-21 06:34:59 +00:00
|
|
|
var open = treeitem.getAttribute('open');
|
|
|
|
if(open == "true")
|
|
|
|
{
|
|
|
|
//open all of the children of the treeitem
|
|
|
|
msgNavigationService.OpenTreeitemAndDescendants(treeitem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(event.detail == 2)
|
|
|
|
{
|
2001-01-20 05:06:10 +00:00
|
|
|
ThreadPaneDoubleClick();
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-20 05:06:10 +00:00
|
|
|
function ThreadPaneDoubleClick()
|
2000-06-21 06:34:59 +00:00
|
|
|
{
|
2000-12-31 07:59:47 +00:00
|
|
|
var loadedFolder;
|
|
|
|
var messageArray;
|
|
|
|
var messageUri;
|
|
|
|
|
2000-06-21 06:34:59 +00:00
|
|
|
if(IsSpecialFolderSelected("Drafts"))
|
|
|
|
{
|
2000-12-31 07:59:47 +00:00
|
|
|
loadedFolder = GetLoadedMsgFolder();
|
|
|
|
messageArray = GetSelectedMessages();
|
2000-06-21 06:34:59 +00:00
|
|
|
|
|
|
|
ComposeMessage(msgComposeType.Draft, msgComposeFormat.Default, loadedFolder, messageArray);
|
|
|
|
}
|
|
|
|
else if(IsSpecialFolderSelected("Templates"))
|
|
|
|
{
|
2000-12-31 07:59:47 +00:00
|
|
|
loadedFolder = GetLoadedMsgFolder();
|
|
|
|
messageArray = GetSelectedMessages();
|
2000-06-21 06:34:59 +00:00
|
|
|
ComposeMessage(msgComposeType.Template, msgComposeFormat.Default, loadedFolder, messageArray);
|
|
|
|
}
|
2000-09-14 22:58:41 +00:00
|
|
|
else
|
|
|
|
{
|
2001-01-20 05:06:10 +00:00
|
|
|
MsgOpenSelectedMessages();
|
2000-09-14 22:58:41 +00:00
|
|
|
}
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
2000-09-14 22:58:41 +00:00
|
|
|
function ThreadPaneKeyPress(event)
|
|
|
|
{
|
|
|
|
if (event.keyCode == 13)
|
2001-01-20 05:06:10 +00:00
|
|
|
ThreadPaneDoubleClick();
|
2000-09-14 22:58:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-06-21 06:34:59 +00:00
|
|
|
|
|
|
|
function MsgSortByDate()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
SortThreadPane('DateColumn', 'http://home.netscape.com/NC-rdf#Date', null, true, null, true);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSortBySender()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
SortThreadPane('AuthorColumn', 'http://home.netscape.com/NC-rdf#Sender', 'http://home.netscape.com/NC-rdf#Date', true, null, true);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSortByRecipient()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
SortThreadPane('AuthorColumn', 'http://home.netscape.com/NC-rdf#Recipient', 'http://home.netscape.com/NC-rdf#Date', true, null, true);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSortByStatus()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
SortThreadPane('StatusColumn', 'http://home.netscape.com/NC-rdf#Status', 'http://home.netscape.com/NC-rdf#Date', true, null, true);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSortBySubject()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
SortThreadPane('SubjectColumn', 'http://home.netscape.com/NC-rdf#Subject', 'http://home.netscape.com/NC-rdf#Date', true, null, true);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSortByFlagged()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
SortThreadPane('FlaggedButtonColumn', 'http://home.netscape.com/NC-rdf#Flagged', 'http://home.netscape.com/NC-rdf#Date', true, null, true);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSortByPriority()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
SortThreadPane('PriorityColumn', 'http://home.netscape.com/NC-rdf#Priority', 'http://home.netscape.com/NC-rdf#Date',true, null, true);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSortBySize()
|
|
|
|
{
|
2000-11-01 20:01:44 +00:00
|
|
|
SortThreadPane('MemoryColumn', 'http://home.netscape.com/NC-rdf#Size', 'http://home.netscape.com/NC-rdf#Date', true, null, true);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
2000-11-01 20:01:44 +00:00
|
|
|
function MsgSortByLines()
|
|
|
|
{
|
|
|
|
SortThreadPane('MemoryColumn', 'http://home.netscape.com/NC-rdf#Lines', 'http://home.netscape.com/NC-rdf#Date', true, null, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-21 06:34:59 +00:00
|
|
|
function MsgSortByUnread()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
SortThreadPane('UnreadColumn', 'http://home.netscape.com/NC-rdf#TotalUnreadMessages','http://home.netscape.com/NC-rdf#Date', true, null, true);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSortByOrderReceived()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
SortThreadPane('OrderReceivedColumn', 'http://home.netscape.com/NC-rdf#OrderReceived','http://home.netscape.com/NC-rdf#Date', true, null, true);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSortByRead()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
SortThreadPane('UnreadButtonColumn', 'http://home.netscape.com/NC-rdf#IsUnread','http://home.netscape.com/NC-rdf#Date', true, null,true);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSortByTotal()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
SortThreadPane('TotalColumn', 'http://home.netscape.com/NC-rdf#TotalMessages', 'http://home.netscape.com/NC-rdf#Date', true, null, true);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSortByThread()
|
|
|
|
{
|
|
|
|
ChangeThreadView()
|
|
|
|
}
|
|
|
|
|
|
|
|
function ChangeThreadView()
|
|
|
|
{
|
|
|
|
var folder = GetSelectedFolder();
|
|
|
|
|
|
|
|
var threadColumn = document.getElementById('ThreadColumnHeader');
|
|
|
|
if(threadColumn)
|
|
|
|
{
|
|
|
|
var currentView = threadColumn.getAttribute('currentView');
|
|
|
|
if(currentView== 'threaded')
|
|
|
|
{
|
|
|
|
ShowThreads(false);
|
|
|
|
if(folder)
|
2000-12-05 01:25:21 +00:00
|
|
|
folder.setAttribute('threaded', "false");
|
2000-08-11 01:14:59 +00:00
|
|
|
SetTemplateTreeItemOpen(false);
|
2000-06-21 06:34:59 +00:00
|
|
|
}
|
|
|
|
else if(currentView == 'unthreaded')
|
|
|
|
{
|
|
|
|
ShowThreads(true);
|
|
|
|
if(folder)
|
|
|
|
folder.setAttribute('threaded', "true");
|
|
|
|
}
|
|
|
|
RefreshThreadTreeView();
|
|
|
|
}
|
|
|
|
}
|
2000-06-30 06:02:30 +00:00
|
|
|
|
|
|
|
function IsSpecialFolderSelected(folderName)
|
|
|
|
{
|
|
|
|
var selectedFolder = GetThreadTreeFolder();
|
|
|
|
var id = selectedFolder.getAttribute('ref');
|
|
|
|
var folderResource = RDF.GetResource(id);
|
|
|
|
if(!folderResource)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var db = GetFolderDatasource();
|
|
|
|
|
|
|
|
var property =
|
|
|
|
RDF.GetResource('http://home.netscape.com/NC-rdf#SpecialFolder');
|
|
|
|
if (!property) return false;
|
|
|
|
var result = db.GetTarget(folderResource, property , true);
|
|
|
|
if (!result) return false;
|
|
|
|
result = result.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
|
|
|
if (!result) return false;
|
|
|
|
if(result.Value == folderName)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Called when selection changes in the thread pane.
|
|
|
|
function ThreadPaneSelectionChange()
|
|
|
|
{
|
|
|
|
var collapsed = IsThreadAndMessagePaneSplitterCollapsed();
|
|
|
|
|
|
|
|
if(!collapsed)
|
|
|
|
{
|
|
|
|
LoadSelectionIntoMessagePane();
|
2000-08-26 20:54:51 +00:00
|
|
|
|
2000-06-30 06:02:30 +00:00
|
|
|
}
|
2000-08-26 20:54:51 +00:00
|
|
|
|
|
|
|
var tree = GetThreadTree();
|
|
|
|
var selectedMessages = tree.selectedItems;
|
|
|
|
var numSelected = selectedMessages.length;
|
2000-09-01 03:28:13 +00:00
|
|
|
//If the current selected is 1 or 0 then we know that a change has taken place that might
|
|
|
|
//cause us to send out threadTree update notifications. We also care about this if the previous
|
|
|
|
//numSelected was 0 or 1 because we might be involved in something like a SelectAll where we won't
|
|
|
|
//get notified about the change from 0 to 1.
|
|
|
|
if(numSelected == 0 || numSelected == 1 || gOldNumSelected == 0 || gOldNumSelected == 1)
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
document.commandDispatcher.updateCommands('threadTree-select');
|
2000-09-01 03:28:13 +00:00
|
|
|
}
|
|
|
|
//Store the current number selected.
|
|
|
|
gOldNumSelected = numSelected;
|
2000-06-30 06:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function GetThreadTree()
|
|
|
|
{
|
|
|
|
if (gThreadTree) return gThreadTree;
|
|
|
|
var threadTree = document.getElementById('threadTree');
|
|
|
|
gThreadTree = threadTree;
|
|
|
|
return threadTree;
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetThreadTreeFolder()
|
|
|
|
{
|
|
|
|
var tree = GetThreadTree();
|
|
|
|
return tree;
|
|
|
|
}
|
|
|
|
|