From 4c20842e646f1109d9ac69cea7ddbb00262803fc Mon Sep 17 00:00:00 2001 From: "dmose%mozilla.org" Date: Tue, 31 Jan 2006 05:59:11 +0000 Subject: [PATCH] Make Lightning dynamically adapt to new Thunderbird searchbox UI (bug 325140), thanks to Joey Minta for the patch, r=. --- .../content/messenger-overlay-sidebar.js | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/calendar/lightning/content/messenger-overlay-sidebar.js b/calendar/lightning/content/messenger-overlay-sidebar.js index 73f4d6f135e..884d75f9b58 100644 --- a/calendar/lightning/content/messenger-overlay-sidebar.js +++ b/calendar/lightning/content/messenger-overlay-sidebar.js @@ -110,7 +110,10 @@ function showCalendarView(type) if (calendarViewBox.style.visibility == "collapse") { collapseElement(GetMessagePane()); collapseElement(document.getElementById("threadpane-splitter")); - collapseElement(gSearchBox); + var searchBox = findMailSearchBox(); + if (searchBox) { + collapseElement(searchBox); + } uncollapseElement(calendarViewBox); // Thunderbird is smart. It won't reload the message list if the user @@ -193,7 +196,10 @@ function LtnObserveDisplayDeckChange(event) collapseElement(document.getElementById("calendar-view-box")); uncollapseElement(GetMessagePane()); uncollapseElement(document.getElementById("threadpane-splitter")); - uncollapseElement(gSearchBox); + var searchBox = findMailSearchBox(); + if (searchBox) { + uncollapseElement(searchBox); + } } } @@ -237,6 +243,24 @@ function onMouseOverItem(event) { //set the item's context-menu text here } +// After 1.5 was released, the search box was moved into an optional toolbar +// item, with a different ID. This function keeps us compatible with both. +function findMailSearchBox() { + var tb15Box = document.getElementById("searchBox"); + if (tb15Box) { + return tb15Box; + } + + var tb2Box = document.getElementById("searchInput"); + if (tb2Box) { + return tb2Box; + } + + // In later versions, it's possible that a user removed the search box from + // the toolbar. + return null; +} + document.getElementById("displayDeck"). addEventListener("select", LtnObserveDisplayDeckChange, true);