From 2f502a8b9b98b784e56d5c9411a0c82d4b134ec1 Mon Sep 17 00:00:00 2001 From: "rjc%netscape.com" Date: Mon, 30 Aug 1999 09:34:46 +0000 Subject: [PATCH] Add column sorting support for directory component listings. Default to ascending sort on "name" column. --- suite/common/directory/directory.js | 28 +++++++++++++++++++++++++ suite/common/directory/directory.xul | 12 +++++++---- xpfe/components/directory/directory.css | 5 ++--- xpfe/components/directory/directory.js | 28 +++++++++++++++++++++++++ xpfe/components/directory/directory.xul | 12 +++++++---- 5 files changed, 74 insertions(+), 11 deletions(-) diff --git a/suite/common/directory/directory.js b/suite/common/directory/directory.js index 5f04dcd959f..2da469e16c6 100644 --- a/suite/common/directory/directory.js +++ b/suite/common/directory/directory.js @@ -155,3 +155,31 @@ function Boot() setTimeout("Boot()", 0); +function doSort(sortColName) +{ + var node = document.getElementById(sortColName); + if (!node) return(false); + + // determine column resource to sort on + var sortResource = node.getAttribute('resource'); + + // switch between ascending & descending sort (no natural order support) + var sortDirection="ascending"; + var isSortActive = node.getAttribute('sortActive'); + if (isSortActive == "true") + { + var currentDirection = node.getAttribute('sortDirection'); + if (currentDirection == "ascending") + { + sortDirection = "descending"; + } + } + + 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); + xulSortService.Sort(node, sortResource, sortDirection); + + return(false); +} diff --git a/suite/common/directory/directory.xul b/suite/common/directory/directory.xul index 226c143c9cb..ca649c2cc65 100644 --- a/suite/common/directory/directory.xul +++ b/suite/common/directory/directory.xul @@ -26,6 +26,7 @@ @@ -44,7 +45,6 @@ - @@ -52,11 +52,15 @@ + + + + - &directoryWindow.filename.label; - &directoryWindow.contentlength.label; - &directoryWindow.lastmodified.label; + + + diff --git a/xpfe/components/directory/directory.css b/xpfe/components/directory/directory.css index 279274fd16d..3c04ddde1c2 100644 --- a/xpfe/components/directory/directory.css +++ b/xpfe/components/directory/directory.css @@ -22,11 +22,10 @@ */ -tree { - background-color: #ccccdd; +treecol[sortActive="true"] { + background-color: lightgray; } - /* Hide the twisty when type != DIRECTORY (XXX is there a != in CSS) */ treeitem[type="FILE"] > treerow > treecell > .tree-icon > .twisty { list-style-image: none; diff --git a/xpfe/components/directory/directory.js b/xpfe/components/directory/directory.js index 5f04dcd959f..2da469e16c6 100644 --- a/xpfe/components/directory/directory.js +++ b/xpfe/components/directory/directory.js @@ -155,3 +155,31 @@ function Boot() setTimeout("Boot()", 0); +function doSort(sortColName) +{ + var node = document.getElementById(sortColName); + if (!node) return(false); + + // determine column resource to sort on + var sortResource = node.getAttribute('resource'); + + // switch between ascending & descending sort (no natural order support) + var sortDirection="ascending"; + var isSortActive = node.getAttribute('sortActive'); + if (isSortActive == "true") + { + var currentDirection = node.getAttribute('sortDirection'); + if (currentDirection == "ascending") + { + sortDirection = "descending"; + } + } + + 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); + xulSortService.Sort(node, sortResource, sortDirection); + + return(false); +} diff --git a/xpfe/components/directory/directory.xul b/xpfe/components/directory/directory.xul index 226c143c9cb..ca649c2cc65 100644 --- a/xpfe/components/directory/directory.xul +++ b/xpfe/components/directory/directory.xul @@ -26,6 +26,7 @@ @@ -44,7 +45,6 @@ - @@ -52,11 +52,15 @@ + + + + - &directoryWindow.filename.label; - &directoryWindow.contentlength.label; - &directoryWindow.lastmodified.label; + + +