rem: if ( dirTree && dirTree.selectedItems && (dirTree.selectedItems.length == 1) ) { ChangeDirectoryByDOMNode(dirTree.selectedItems[0]); } else { if ( resultsTree ) { ClearResultsTreeSelection(); resultsTree.setAttribute('ref', null); } } } 
add: if (dirTree && dirTree.selectedItems && (dirTree.selectedItems.length == 1)) ChangeDirectoryByDOMNode(dirTree.selectedItems[0]); else { if (resultsTree) { ClearResultsTreeSelection(); resultsTree.setAttribute("ref", null); } }  function ChangeDirectoryByDOMNode(dirNode) { var uri = dirNode.getAttribute("id");  if (resultsTree) { if (uri != resultsTree.getAttribute("ref")) { ClearResultsTreeSelection(); resultsTree.setAttribute("ref", uri); WaitUntilDocumentIsLoaded(); SortToPreviousSettings(); SelectFirstCard(); } } }  function ResultsPaneSelectionChange() { if ("gUpdateCardView" in top) top.gUpdateCardView();  if ("gDialogResultsPaneSelectionChanged" in top) top.gDialogResultsPaneSelectionChanged(); }  function ClearResultsTreeSelection() { if (resultsTree) resultsTree.clearItemSelection(); }  function RedrawResultsTree() { if (resultsTree) { var ref = resultsTree.getAttribute("ref"); resultsTree.setAttribute("ref", ref); } }  function RememberResultsTreeSelection() { var selectionArray = 0;  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() {   var msgNavigationService = omponents.classes["@mozilla.org/messenger/msgviewnavigationservice;1"].getService(); msgNavigationService= msgNavigationService.QueryInterface(Components.interfaces.nsIMsgViewNavigationService); msgNavigationService.EnsureDocumentIsLoaded(document); }  function GetResultsTreeChildren() { if (resultsTree && resultsTree.childNodes) { for (var index = resultsTree.childNodes.length - 1; index >= 0; index--) { if (resultsTree.childNodes[index].localName == "treechildren") return(resultsTree.childNodes[index]); } } 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]; } return null; }  function SortResultPane(column, sortKey) { var node = document.getElementById(column); if (!node) return false;  var sortDirection = "ascending"; var currentDirection = node.getAttribute("sortDirection");  if (currentDirection == "ascending") sortDirection = "descending"; else sortDirection = "ascending";  UpdateSortIndicator(column, sortDirection);  DoSort(column, sortKey, sortDirection);  SaveSortSetting(column, sortKey, sortDirection);  return true; }  function DoSort(column, key, direction) { var isupports = Components.classes["@mozilla.org/rdf/xul-sort-service;1"].getService(); if (!isupports) return false;  var xulSortService = isupports.QueryInterface(Components.interfaces.nsIXULSortService); if (!xulSortService) return false;  var node = document.getElementById(column);  if (node) { var selectionArray = RememberResultsTreeSelection(); if (selectionArray.length) { xulSortService.Sort(node, key, direction); ClearResultsTreeSelection(); WaitUntilDocumentIsLoaded(); RestoreResultsTreeSelection(selectionArray); } else { try { xulSortService.Sort(node, key, direction); WaitUntilDocumentIsLoaded(); } catch(ex) { dump("failed to do sort\n"); } } } return true; } 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: } if (!direction) direction = "ascending";  UpdateSortIndicator(column,direction);  DoSort(column, key, direction); } } }  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); } } }              function UpdateSortIndicator(column,sortDirection) {  var treerow = document.getElementById("headRow"); var id = column + "Header";  if (treerow) {  var treecell = treerow.getElementsByTagName("treecell"); if (treecell) {  var node_count = treecell.length; for (var i=0; i < node_count; i++) {  if (id == treecell[i].getAttribute("id")) {   treecell[i].setAttribute("sortDirection", sortDirection); } else {  treecell[i].removeAttribute("sortDirection"); } } } } }  function AbNewList() { var selectedAB = 0; if (dirTree && dirTree.selectedItems && (dirTree.selectedItems.length == 1)) selectedAB = dirTree.selectedItems[0].getAttribute("id");  window.openDialog("chrome: "", "chrome,titlebar,resizeable=no", {selectedAB:selectedAB}); }   function goEditListDialog(abURI, listURI) { window.openDialog("chrome: "", "chrome,titlebar,resizeable=no", {abURI:abURI, listURI:listURI}); } 
context: function DirPaneSelectionChange(){	if ( dirTree && dirTree.selectedItems && (dirTree.selectedItems.length == 1) )	{		ChangeDirectoryByDOMNode(dirTree.selectedItems[0]);	}	else		{		if ( resultsTree )		{			ClearResultsTreeSelection();			resultsTree.setAttribute('ref', null);		}	}}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/0bae2ed72e9748283256fed72e6330994a6cb0fd/abCommon.js/buggy/mailnews/addrbook/resources/content/abCommon.js