From 49c8da4a8e05b34befd18650628e827e9f80f0c3 Mon Sep 17 00:00:00 2001 From: "hangas%netscape.com" Date: Thu, 16 Mar 2000 23:12:50 +0000 Subject: [PATCH] Fix for 32015 (adding sort direction indicators to address book column headers) submitted by Becki Sanford , modified by me, r=mscott --- .../addrbook/resources/content/abCommon.js | 61 +++++++++++++++++-- .../content/abResultsTreeOverlay.xul | 8 +-- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/mailnews/addrbook/resources/content/abCommon.js b/mailnews/addrbook/resources/content/abCommon.js index 80cbf0b1436b..e5da1b7d7b1a 100644 --- a/mailnews/addrbook/resources/content/abCommon.js +++ b/mailnews/addrbook/resources/content/abCommon.js @@ -393,16 +393,17 @@ function SortResultPane(column, sortKey) var node = document.getElementById(column); if (!node) return(false); - // sort!!! - var sortDirection; + var sortDirection = "ascending"; var currentDirection = node.getAttribute('sortDirection'); - if ( currentDirection == "descending" ) - sortDirection = "ascending"; - else + if ( currentDirection == "ascending" ) sortDirection = "descending"; + else + sortDirection = "ascending"; + + UpdateSortIndicator(column, sortDirection); DoSort(column, sortKey, sortDirection); - + SaveSortSetting(column, sortKey, sortDirection); return(true); } @@ -450,6 +451,8 @@ function SortToPreviousSettings() if ( !direction ) direction = 'ascending'; + UpdateSortIndicator(column,direction); + DoSort(column, key, direction); } } @@ -469,3 +472,49 @@ function SaveSortSetting(column, key, direction) } } } + +//------------------------------------------------------------ +// Sets the column header sort icon based on the requested +// column and direction. +// +// Notes: +// (1) This function relies on the first part of the +// matching the . 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 element + var treerow = document.getElementById("headRow"); + var id = column + "Header"; + + if (treerow) + { + // Grab all of the 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'); + } + } + } + } +} + diff --git a/mailnews/addrbook/resources/content/abResultsTreeOverlay.xul b/mailnews/addrbook/resources/content/abResultsTreeOverlay.xul index 16afd047620b..e6d84578d2c7 100644 --- a/mailnews/addrbook/resources/content/abResultsTreeOverlay.xul +++ b/mailnews/addrbook/resources/content/abResultsTreeOverlay.xul @@ -62,10 +62,10 @@ Rights Reserved. - - - - + + + +