2000-02-06 00:21:56 +03:00
|
|
|
var dirTree = 0;
|
|
|
|
var resultsTree = 0;
|
|
|
|
|
1999-08-02 22:22:58 +04:00
|
|
|
// functions needed from abMainWindow and abSelectAddresses
|
|
|
|
|
1999-09-16 05:46:30 +04:00
|
|
|
// Controller object for Results Pane
|
|
|
|
var ResultsPaneController =
|
|
|
|
{
|
1999-10-14 14:58:25 +04:00
|
|
|
supportsCommand: function(command)
|
1999-09-16 05:46:30 +04:00
|
|
|
{
|
1999-10-14 14:58:25 +04:00
|
|
|
switch ( command )
|
|
|
|
{
|
|
|
|
case "cmd_selectAll":
|
|
|
|
case "cmd_delete":
|
1999-11-02 06:55:59 +03:00
|
|
|
case "button_delete":
|
1999-10-14 14:58:25 +04:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
isCommandEnabled: function(command)
|
|
|
|
{
|
1999-11-12 05:41:50 +03:00
|
|
|
//dump('ResultsPaneController::isCommandEnabled(' + command + ')\n');
|
1999-09-16 05:46:30 +04:00
|
|
|
switch ( command )
|
|
|
|
{
|
|
|
|
case "cmd_selectAll":
|
|
|
|
return true;
|
1999-09-16 09:46:03 +04:00
|
|
|
|
|
|
|
case "cmd_delete":
|
1999-11-02 06:55:59 +03:00
|
|
|
case "button_delete":
|
|
|
|
var numSelected = 0;
|
1999-09-17 02:21:08 +04:00
|
|
|
if ( resultsTree && resultsTree.selectedItems )
|
1999-11-02 06:55:59 +03:00
|
|
|
numSelected = resultsTree.selectedItems.length;
|
|
|
|
if ( command == "cmd_delete" )
|
|
|
|
{
|
|
|
|
if ( numSelected < 2 )
|
|
|
|
goSetMenuValue(command, 'valueCard');
|
|
|
|
else
|
|
|
|
goSetMenuValue(command, 'valueCards');
|
|
|
|
}
|
|
|
|
return ( numSelected > 0 );
|
1999-09-16 09:46:03 +04:00
|
|
|
|
1999-09-16 05:46:30 +04:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
1999-10-14 14:58:25 +04:00
|
|
|
doCommand: function(command)
|
1999-09-16 05:46:30 +04:00
|
|
|
{
|
|
|
|
switch ( command )
|
|
|
|
{
|
|
|
|
case "cmd_selectAll":
|
|
|
|
if ( resultsTree )
|
|
|
|
{
|
|
|
|
dump("select all now!!!!!!" + "\n");
|
|
|
|
resultsTree.selectAll();
|
|
|
|
}
|
|
|
|
break;
|
1999-09-16 09:46:03 +04:00
|
|
|
|
|
|
|
case "cmd_delete":
|
1999-11-02 06:55:59 +03:00
|
|
|
case "button_delete":
|
1999-09-16 09:46:03 +04:00
|
|
|
if ( resultsTree )
|
|
|
|
{
|
|
|
|
var cardList = resultsTree.selectedItems;
|
1999-12-04 06:11:36 +03:00
|
|
|
top.addressbook.deleteCards(resultsTree, resultsTree, cardList);
|
1999-09-16 09:46:03 +04:00
|
|
|
}
|
|
|
|
break;
|
1999-09-16 05:46:30 +04:00
|
|
|
}
|
1999-11-05 05:21:47 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
onEvent: function(event)
|
|
|
|
{
|
|
|
|
dump("onEvent("+event+")\n");
|
|
|
|
// on blur events set the menu item texts back to the normal values
|
|
|
|
if ( event == 'blur' )
|
|
|
|
{
|
|
|
|
goSetMenuValue('cmd_delete', 'valueDefault');
|
|
|
|
}
|
1999-09-16 05:46:30 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Controller object for Dir Pane
|
|
|
|
var DirPaneController =
|
|
|
|
{
|
1999-10-14 14:58:25 +04:00
|
|
|
supportsCommand: function(command)
|
1999-09-16 05:46:30 +04:00
|
|
|
{
|
1999-10-14 14:58:25 +04:00
|
|
|
switch ( command )
|
|
|
|
{
|
|
|
|
case "cmd_selectAll":
|
|
|
|
case "cmd_delete":
|
1999-11-02 06:55:59 +03:00
|
|
|
case "button_delete":
|
1999-10-14 14:58:25 +04:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
isCommandEnabled: function(command)
|
|
|
|
{
|
1999-11-12 05:41:50 +03:00
|
|
|
//dump('DirPaneController::isCommandEnabled(' + command + ')\n');
|
1999-09-16 05:46:30 +04:00
|
|
|
switch ( command )
|
|
|
|
{
|
|
|
|
case "cmd_selectAll":
|
|
|
|
return true;
|
1999-09-16 09:46:03 +04:00
|
|
|
case "cmd_delete":
|
1999-11-02 06:55:59 +03:00
|
|
|
case "button_delete":
|
|
|
|
if ( command == "cmd_delete" )
|
|
|
|
goSetMenuValue(command, 'valueAddressBook');
|
1999-09-17 02:21:08 +04:00
|
|
|
if ( dirTree && dirTree.selectedItems )
|
1999-09-18 03:24:04 +04:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
1999-09-16 05:46:30 +04:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
1999-10-14 14:58:25 +04:00
|
|
|
doCommand: function(command)
|
1999-09-16 05:46:30 +04:00
|
|
|
{
|
|
|
|
switch ( command )
|
|
|
|
{
|
|
|
|
case "cmd_selectAll":
|
|
|
|
if ( dirTree )
|
|
|
|
{
|
|
|
|
dump("select all now!!!!!!" + "\n");
|
|
|
|
dirTree.selectAll();
|
|
|
|
}
|
|
|
|
break;
|
1999-09-16 09:46:03 +04:00
|
|
|
|
|
|
|
case "cmd_delete":
|
1999-11-02 06:55:59 +03:00
|
|
|
case "button_delete":
|
1999-09-16 09:46:03 +04:00
|
|
|
if ( dirTree )
|
1999-12-04 06:11:36 +03:00
|
|
|
top.addressbook.deleteAddressBooks(dirTree.database, dirTree, dirTree.selectedItems);
|
1999-09-16 09:46:03 +04:00
|
|
|
break;
|
1999-09-16 05:46:30 +04:00
|
|
|
}
|
1999-11-05 05:21:47 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
onEvent: function(event)
|
|
|
|
{
|
|
|
|
dump("onEvent("+event+")\n");
|
|
|
|
// on blur events set the menu item texts back to the normal values
|
|
|
|
if ( event == 'blur' )
|
|
|
|
{
|
|
|
|
goSetMenuValue('cmd_delete', 'valueDefault');
|
|
|
|
}
|
1999-09-16 05:46:30 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2000-02-06 00:21:56 +03:00
|
|
|
function InitCommonJS()
|
|
|
|
{
|
|
|
|
dirTree = document.getElementById('dirTree');
|
|
|
|
resultsTree = document.getElementById('resultsTree');
|
|
|
|
}
|
|
|
|
|
1999-09-16 05:46:30 +04:00
|
|
|
function SetupCommandUpdateHandlers()
|
|
|
|
{
|
|
|
|
// dir pane
|
2000-02-06 00:21:56 +03:00
|
|
|
if ( dirTree )
|
|
|
|
dirTree.controllers.appendController(DirPaneController);
|
1999-09-16 05:46:30 +04:00
|
|
|
|
|
|
|
// results pane
|
2000-02-06 00:21:56 +03:00
|
|
|
if ( resultsTree )
|
|
|
|
resultsTree.controllers.appendController(ResultsPaneController);
|
1999-09-16 05:46:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-08-27 11:07:34 +04:00
|
|
|
function AbNewCard()
|
1999-08-02 22:22:58 +04:00
|
|
|
{
|
1999-08-27 11:07:34 +04:00
|
|
|
var selectedAB = 0;
|
2000-02-06 00:21:56 +03:00
|
|
|
if ( dirTree && dirTree.selectedItems && (dirTree.selectedItems.length == 1) )
|
|
|
|
selectedAB = dirTree.selectedItems[0].getAttribute('id');
|
1999-08-27 11:07:34 +04:00
|
|
|
|
|
|
|
goNewCardDialog(selectedAB);
|
1999-08-02 22:22:58 +04:00
|
|
|
}
|
|
|
|
|
1999-08-27 11:07:34 +04:00
|
|
|
function AbEditCard()
|
1999-08-02 22:22:58 +04:00
|
|
|
{
|
|
|
|
var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
|
|
|
|
rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
|
|
|
|
|
1999-08-24 01:35:22 +04:00
|
|
|
if ( resultsTree.selectedItems && resultsTree.selectedItems.length == 1 )
|
1999-08-02 22:22:58 +04:00
|
|
|
{
|
1999-08-24 01:35:22 +04:00
|
|
|
var uri = resultsTree.selectedItems[0].getAttribute('id');
|
1999-08-02 22:22:58 +04:00
|
|
|
var card = rdf.GetResource(uri);
|
|
|
|
card = card.QueryInterface(Components.interfaces.nsIAbCard);
|
2000-02-06 00:21:56 +03:00
|
|
|
goEditCardDialog(resultsTree.getAttribute('ref'), card, top.gUpdateCardView);
|
1999-08-02 22:22:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function AbNewMessage()
|
|
|
|
{
|
2000-01-28 09:20:44 +03:00
|
|
|
var msgComposeType = Components.interfaces.nsIMsgCompType;
|
|
|
|
var msgComposFormat = Components.interfaces.nsIMsgCompFormat;
|
1999-08-02 22:22:58 +04:00
|
|
|
var msgComposeService = Components.classes["component://netscape/messengercompose"].getService();
|
|
|
|
msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService);
|
|
|
|
|
2000-01-28 09:20:44 +03:00
|
|
|
msgComposeService.OpenComposeWindowWithValues(null, msgComposeType.New, msgComposFormat.Default,
|
|
|
|
GetSelectedAddresses(), null, null,
|
|
|
|
null, null, null, null, null);
|
1999-08-02 22:22:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function GetSelectedAddresses()
|
|
|
|
{
|
|
|
|
var item, uri, rdf, cardResource, card;
|
|
|
|
var selectedAddresses = "";
|
|
|
|
|
|
|
|
rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
|
|
|
|
rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
|
|
|
|
|
1999-08-24 01:35:22 +04:00
|
|
|
if ( resultsTree.selectedItems && resultsTree.selectedItems.length )
|
1999-08-02 22:22:58 +04:00
|
|
|
{
|
1999-08-24 01:35:22 +04:00
|
|
|
for ( item = 0; item < resultsTree.selectedItems.length; item++ )
|
1999-08-02 22:22:58 +04:00
|
|
|
{
|
1999-08-24 01:35:22 +04:00
|
|
|
uri = resultsTree.selectedItems[item].getAttribute('id');
|
1999-08-02 22:22:58 +04:00
|
|
|
cardResource = rdf.GetResource(uri);
|
|
|
|
card = cardResource.QueryInterface(Components.interfaces.nsIAbCard);
|
|
|
|
if ( selectedAddresses )
|
|
|
|
selectedAddresses += ",";
|
1999-12-07 09:17:43 +03:00
|
|
|
selectedAddresses += "\"" + card.displayName + "\" <" + card.primaryEmail + ">";
|
1999-08-02 22:22:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return selectedAddresses;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-11 03:15:25 +04:00
|
|
|
function SelectFirstAddressBook()
|
1999-08-02 22:22:58 +04:00
|
|
|
{
|
1999-09-11 03:15:25 +04:00
|
|
|
var body = document.getElementById('dirTreeBody');
|
2000-02-06 00:21:56 +03:00
|
|
|
if ( dirTree && body )
|
1999-09-11 03:15:25 +04:00
|
|
|
{
|
|
|
|
var treeitems = body.getElementsByTagName('treeitem');
|
|
|
|
if ( treeitems && treeitems.length > 0 )
|
|
|
|
{
|
2000-02-06 00:21:56 +03:00
|
|
|
dirTree.selectItem(treeitems[0]);
|
1999-09-11 03:15:25 +04:00
|
|
|
ChangeDirectoryByDOMNode(treeitems[0]);
|
|
|
|
}
|
|
|
|
}
|
1999-08-02 22:22:58 +04:00
|
|
|
}
|
|
|
|
|
2000-02-06 00:21:56 +03:00
|
|
|
function SelectFirstCard()
|
|
|
|
{
|
|
|
|
var body = GetResultsTreeChildren();
|
|
|
|
|
|
|
|
if ( resultsTree && body )
|
|
|
|
{
|
|
|
|
var treeitems = body.getElementsByTagName('treeitem');
|
|
|
|
if ( treeitems && treeitems.length > 0 )
|
|
|
|
{
|
|
|
|
resultsTree.selectItem(treeitems[0]);
|
|
|
|
ResultsPaneSelectionChange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-12 06:22:11 +04:00
|
|
|
function DirPaneSelectionChange()
|
|
|
|
{
|
1999-11-12 05:41:50 +03:00
|
|
|
if ( dirTree && dirTree.selectedItems && (dirTree.selectedItems.length == 1) )
|
|
|
|
{
|
|
|
|
ChangeDirectoryByDOMNode(dirTree.selectedItems[0]);
|
|
|
|
}
|
1999-09-12 06:22:11 +04:00
|
|
|
else
|
|
|
|
{
|
1999-11-12 05:41:50 +03:00
|
|
|
if ( resultsTree )
|
|
|
|
{
|
|
|
|
ClearResultsTreeSelection();
|
|
|
|
resultsTree.setAttribute('ref', null);
|
|
|
|
}
|
1999-09-12 06:22:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-11 03:15:25 +04:00
|
|
|
function ChangeDirectoryByDOMNode(dirNode)
|
1999-08-02 22:22:58 +04:00
|
|
|
{
|
1999-09-11 03:15:25 +04:00
|
|
|
var uri = dirNode.getAttribute('id');
|
|
|
|
|
1999-11-12 05:41:50 +03:00
|
|
|
if ( resultsTree )
|
|
|
|
{
|
|
|
|
if ( uri != resultsTree.getAttribute('ref') )
|
|
|
|
{
|
|
|
|
ClearResultsTreeSelection();
|
|
|
|
resultsTree.setAttribute('ref', uri);
|
2000-02-06 00:21:56 +03:00
|
|
|
WaitUntilDocumentIsLoaded();
|
|
|
|
SortToPreviousSettings();
|
|
|
|
SelectFirstCard();
|
1999-11-12 05:41:50 +03:00
|
|
|
}
|
|
|
|
}
|
1999-08-02 22:22:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function ResultsPaneSelectionChange()
|
|
|
|
{
|
1999-11-12 05:41:50 +03:00
|
|
|
if ( top.gUpdateCardView )
|
|
|
|
top.gUpdateCardView();
|
|
|
|
}
|
|
|
|
|
|
|
|
function ClearResultsTreeSelection()
|
|
|
|
{
|
|
|
|
if ( resultsTree )
|
|
|
|
resultsTree.clearItemSelection();
|
|
|
|
}
|
|
|
|
|
2000-02-06 00:21:56 +03:00
|
|
|
function RedrawResultsTree()
|
|
|
|
{
|
|
|
|
if ( resultsTree )
|
|
|
|
{
|
|
|
|
var ref = resultsTree.getAttribute('ref');
|
|
|
|
resultsTree.setAttribute('ref', ref);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function RememberResultsTreeSelection()
|
1999-11-12 05:41:50 +03:00
|
|
|
{
|
2000-02-06 00:21:56 +03:00
|
|
|
var selectionArray = 0;
|
1999-11-12 05:41:50 +03:00
|
|
|
|
2000-02-06 00:21:56 +03:00
|
|
|
if ( resultsTree )
|
|
|
|
{
|
|
|
|
var selectedItems = resultsTree.selectedItems;
|
|
|
|
var numSelected = selectedItems.length;
|
|
|
|
|
|
|
|
selectionArray = new Array(numSelected);
|
|
|
|
|
|
|
|
for ( var i = 0; i < numSelected; i++ )
|
|
|
|
{
|
|
|
|
selectionArray[i] = selectedItems[i].getAttribute("id");
|
|
|
|
dump("selectionArray["+i+"] = " + selectionArray[i] + "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return selectionArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
function RestoreResultsTreeSelection(selectionArray)
|
|
|
|
{
|
|
|
|
if ( resultsTree && selectionArray )
|
|
|
|
{
|
|
|
|
var numSelected = selectionArray.length;
|
|
|
|
|
|
|
|
WaitUntilDocumentIsLoaded();
|
|
|
|
|
|
|
|
var rowElement;
|
|
|
|
for ( var i = 0 ; i < numSelected; i++ )
|
|
|
|
{
|
|
|
|
rowElement = document.getElementById(selectionArray[i]);
|
|
|
|
resultsTree.addItemToSelection(rowElement);
|
|
|
|
if ( rowElement && (i==0) )
|
|
|
|
resultsTree.ensureElementIsVisible(rowElement);
|
|
|
|
}
|
|
|
|
ResultsPaneSelectionChange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function WaitUntilDocumentIsLoaded()
|
|
|
|
{
|
|
|
|
// FIX ME - we should really have this function available in a global place that does not
|
|
|
|
// require that we have access to mailnews code (msgNavigationService) from address book.
|
|
|
|
var msgNavigationService = Components.classes['component://netscape/messenger/msgviewnavigationservice'].getService();
|
|
|
|
msgNavigationService= msgNavigationService.QueryInterface(Components.interfaces.nsIMsgViewNavigationService);
|
|
|
|
|
|
|
|
msgNavigationService.EnsureDocumentIsLoaded(document);
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetResultsTreeChildren()
|
|
|
|
{
|
|
|
|
if ( resultsTree && resultsTree.childNodes )
|
1999-08-02 22:22:58 +04:00
|
|
|
{
|
2000-02-06 00:21:56 +03:00
|
|
|
for ( var index = resultsTree.childNodes.length - 1; index >= 0; index-- )
|
1999-11-12 05:41:50 +03:00
|
|
|
{
|
2000-02-06 00:21:56 +03:00
|
|
|
if ( resultsTree.childNodes[index].tagName == 'treechildren' )
|
1999-11-12 05:41:50 +03:00
|
|
|
{
|
2000-02-06 00:21:56 +03:00
|
|
|
return(resultsTree.childNodes[index]);
|
1999-11-12 05:41:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetResultsTreeItem(row)
|
|
|
|
{
|
|
|
|
var treechildren = GetResultsTreeChildren();
|
|
|
|
|
|
|
|
if ( treechildren && row > 0)
|
|
|
|
{
|
|
|
|
var treeitems = treechildren.getElementsByTagName('treeitem');
|
|
|
|
if ( treeitems && treeitems.length >= row )
|
|
|
|
return treeitems[row-1];
|
1999-08-02 22:22:58 +04:00
|
|
|
}
|
1999-11-12 05:41:50 +03:00
|
|
|
return null;
|
1999-08-02 22:22:58 +04:00
|
|
|
}
|
|
|
|
|
1999-08-20 00:12:19 +04:00
|
|
|
function SortResultPane(column, sortKey)
|
|
|
|
{
|
|
|
|
var node = document.getElementById(column);
|
2000-02-06 00:21:56 +03:00
|
|
|
if (!node) return(false);
|
|
|
|
|
2000-03-17 02:12:50 +03:00
|
|
|
var sortDirection = "ascending";
|
2000-02-06 00:21:56 +03:00
|
|
|
var currentDirection = node.getAttribute('sortDirection');
|
2000-03-17 02:12:50 +03:00
|
|
|
if ( currentDirection == "ascending" )
|
2000-02-06 00:21:56 +03:00
|
|
|
sortDirection = "descending";
|
2000-03-17 02:12:50 +03:00
|
|
|
else
|
|
|
|
sortDirection = "ascending";
|
|
|
|
|
|
|
|
UpdateSortIndicator(column, sortDirection);
|
2000-02-06 00:21:56 +03:00
|
|
|
|
|
|
|
DoSort(column, sortKey, sortDirection);
|
2000-03-17 02:12:50 +03:00
|
|
|
|
2000-02-06 00:21:56 +03:00
|
|
|
SaveSortSetting(column, sortKey, sortDirection);
|
|
|
|
return(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function DoSort(column, key, direction)
|
|
|
|
{
|
1999-08-28 04:42:33 +04:00
|
|
|
var isupports = Components.classes["component://netscape/rdf/xul-sort-service"].getService();
|
|
|
|
if (!isupports) return(false);
|
|
|
|
|
|
|
|
var xulSortService = isupports.QueryInterface(Components.interfaces.nsIXULSortService);
|
|
|
|
if (!xulSortService) return(false);
|
1999-08-20 00:12:19 +04:00
|
|
|
|
2000-02-06 00:21:56 +03:00
|
|
|
var node = document.getElementById(column);
|
|
|
|
|
|
|
|
if ( node )
|
|
|
|
{
|
|
|
|
var selectionArray = RememberResultsTreeSelection();
|
2000-03-17 02:02:49 +03:00
|
|
|
if (selectionArray.length)
|
|
|
|
{
|
|
|
|
xulSortService.Sort(node, key, direction);
|
|
|
|
ClearResultsTreeSelection() ;
|
|
|
|
WaitUntilDocumentIsLoaded();
|
|
|
|
RestoreResultsTreeSelection(selectionArray);
|
|
|
|
}
|
2000-02-06 00:21:56 +03:00
|
|
|
}
|
|
|
|
}
|
1999-08-20 00:12:19 +04:00
|
|
|
|
2000-02-06 00:21:56 +03:00
|
|
|
function SortToPreviousSettings()
|
|
|
|
{
|
|
|
|
if ( dirTree && resultsTree )
|
|
|
|
{
|
|
|
|
var ref = resultsTree.getAttribute('ref');
|
|
|
|
var folder = document.getElementById(ref);
|
|
|
|
if ( folder )
|
|
|
|
{
|
|
|
|
var column = folder.getAttribute('sortColumn');
|
|
|
|
var key = folder.getAttribute('sortKey');
|
|
|
|
var direction = folder.getAttribute('sortDirection');
|
|
|
|
|
|
|
|
if ( !column || !key )
|
|
|
|
{
|
|
|
|
column = "NameColumn";
|
|
|
|
key = 'http://home.netscape.com/NC-rdf#Name';
|
|
|
|
}
|
|
|
|
if ( !direction )
|
|
|
|
direction = 'ascending';
|
|
|
|
|
2000-03-17 02:12:50 +03:00
|
|
|
UpdateSortIndicator(column,direction);
|
|
|
|
|
2000-02-06 00:21:56 +03:00
|
|
|
DoSort(column, key, direction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-08-20 00:12:19 +04:00
|
|
|
|
2000-02-06 00:21:56 +03:00
|
|
|
function SaveSortSetting(column, key, direction)
|
|
|
|
{
|
|
|
|
if ( dirTree && resultsTree )
|
|
|
|
{
|
|
|
|
var ref = resultsTree.getAttribute('ref');
|
|
|
|
var folder = document.getElementById(ref);
|
|
|
|
if ( folder )
|
|
|
|
{
|
|
|
|
folder.setAttribute('sortColumn', column);
|
|
|
|
folder.setAttribute('sortKey', key);
|
|
|
|
folder.setAttribute('sortDirection', direction);
|
|
|
|
}
|
|
|
|
}
|
1999-08-20 00:12:19 +04:00
|
|
|
}
|
2000-03-17 02:12:50 +03:00
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// Sets the column header sort icon based on the requested
|
|
|
|
// column and direction.
|
|
|
|
//
|
|
|
|
// Notes:
|
|
|
|
// (1) This function relies on the first part of the
|
|
|
|
// <treecell id> matching the <treecol id>. The treecell
|
|
|
|
// id must have a "Header" suffix.
|
|
|
|
// (2) By changing the "sortDirection" attribute, a different
|
|
|
|
// CSS style will be used, thus changing the icon based on
|
|
|
|
// the "sortDirection" parameter.
|
|
|
|
//------------------------------------------------------------
|
|
|
|
function UpdateSortIndicator(column,sortDirection)
|
|
|
|
{
|
|
|
|
// Find the <treerow> element
|
|
|
|
var treerow = document.getElementById("headRow");
|
|
|
|
var id = column + "Header";
|
|
|
|
|
|
|
|
if (treerow)
|
|
|
|
{
|
|
|
|
// Grab all of the <treecell> elements
|
|
|
|
var treecell = treerow.getElementsByTagName("treecell");
|
|
|
|
if (treecell)
|
|
|
|
{
|
|
|
|
// Loop through each treecell...
|
|
|
|
var node_count = treecell.length;
|
|
|
|
for (var i=0; i < node_count; i++)
|
|
|
|
{
|
|
|
|
// Is this the requested column ?
|
|
|
|
if (id == treecell[i].getAttribute("id"))
|
|
|
|
{
|
|
|
|
// Set the sortDirection so the class (CSS) will add the
|
|
|
|
// appropriate icon to the header cell
|
|
|
|
treecell[i].setAttribute('sortDirection',sortDirection);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// This is not the sorted row
|
|
|
|
treecell[i].removeAttribute('sortDirection');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|