From 16df5dbf3cc1cb102c68f78f5f543a78f508f1d4 Mon Sep 17 00:00:00 2001 From: "mnyromyr%tprac.de" Date: Fri, 1 Jul 2005 23:17:30 +0000 Subject: [PATCH] Bug 298841: first lessButton in edit virtual folder not fully functional; p=Henrik Skupin , r=me, sr=neil, a=cbeard --- .../content/virtualFolderProperties.js | 9 +--- .../resources/content/searchTermOverlay.js | 41 ++++++++----------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/mailnews/base/resources/content/virtualFolderProperties.js b/mailnews/base/resources/content/virtualFolderProperties.js index ff2a4cf7682..a3d7d23aa3a 100644 --- a/mailnews/base/resources/content/virtualFolderProperties.js +++ b/mailnews/base/resources/content/virtualFolderProperties.js @@ -105,14 +105,9 @@ function onLoad() function setupSearchRows(aSearchTerms) { if (aSearchTerms && aSearchTerms.Count() > 0) - { - // load the search terms for the folder - initializeSearchRows(nsMsgSearchScope.offlineMail, aSearchTerms); - if (aSearchTerms.Count() == 1) - document.getElementById("less0").setAttribute("disabled", "true"); - } + initializeSearchRows(nsMsgSearchScope.offlineMail, aSearchTerms); // load the search terms for the folder else - onMore(null, 0); + onMore(null); } function updateOnlineSearchState() diff --git a/mailnews/base/search/resources/content/searchTermOverlay.js b/mailnews/base/search/resources/content/searchTermOverlay.js index e3334294372..dcef18ab873 100644 --- a/mailnews/base/search/resources/content/searchTermOverlay.js +++ b/mailnews/base/search/resources/content/searchTermOverlay.js @@ -195,7 +195,7 @@ function initializeBooleanWidgets() function initializeSearchRows(scope, searchTerms) { - for (i = 0; i < searchTerms.Count(); i++) { + for (var i = 0; i < searchTerms.Count(); i++) { var searchTerm = searchTerms.QueryElementAt(i, nsIMsgSearchTerm); createSearchRow(i, scope, searchTerm); gTotalSearchTerms++; @@ -204,56 +204,51 @@ function initializeSearchRows(scope, searchTerms) updateRemoveRowButton(); } -// enables/disables tless button for the first row of search terms. +// enables/disables the less button for the first row of search terms. function updateRemoveRowButton() { var firstListItem = gSearchTermList.getItemAtIndex(0); if (firstListItem) - firstListItem.lastChild.lastChild.lastChild.disabled = gTotalSearchTerms == 1; + firstListItem.lastChild.lastChild.lastChild.setAttribute("disabled", gTotalSearchTerms == 1); } // Returns the actual list item row index in the list of search rows // that contains the passed in element id. function getSearchRowIndexForElement(aElement) { - var listitem = aElement; - while (listitem) -{ - if (listitem.localName == "listitem") - break; - listitem = listitem.parentNode; - } - - return gSearchTermList.getIndexOfItem(listitem); + var listItem = aElement; + + while (listItem && listItem.localName != "listitem") + listItem = listItem.parentNode; + + return gSearchTermList.getIndexOfItem(listItem); } function onMore(event) { // if we have an event, extract the list row index and use that as the row number // for our insertion point. If there is no event, append to the end.... + var rowIndex; - var rowIndex = gSearchTermList.getRowCount(); if (event) - rowIndex = getSearchRowIndexForElement(event.target) + 1; + rowIndex = getSearchRowIndexForElement(event.target) + 1; + else + rowIndex = gSearchTermList.getRowCount(); createSearchRow(rowIndex, gSearchScope, null); - gTotalSearchTerms++; + gTotalSearchTerms++; updateRemoveRowButton(); - // the user just added a term, so scroll to it + // the user just added a term, so scroll to it gSearchTermList.ensureIndexIsVisible(rowIndex); } function onLess(event) { - if (gTotalSearchTerms > 1) + if (event && gTotalSearchTerms > 1) { - var rowIndex; - if (event) -{ - removeSearchRow(getSearchRowIndexForElement(event.target)); - --gTotalSearchTerms; - } + removeSearchRow(getSearchRowIndexForElement(event.target)); + --gTotalSearchTerms; } updateRemoveRowButton();