Backport of Bug 729197 - Make Quick Filter Bar toggle work for glodaList tabs. r=bwinton,a=Standard8.
authorMike Conley <mconley@mozilla.com>
Tue, 21 Feb 2012 21:54:35 -0500
changeset 10198 52d70cf70e062ba69ca24c0207c11d664401bb61
parent 10197 17b0b1d4af4d70c55c14b4e2b6266dd07d0c2fc6
child 10199 5b08357336fb99dba4e07ed494aabf973ba1bb56
push idunknown
push userunknown
push dateunknown
reviewersbwinton, Standard8
bugs729197
Backport of Bug 729197 - Make Quick Filter Bar toggle work for glodaList tabs. r=bwinton,a=Standard8.
mail/base/content/quickFilterBar.js
--- a/mail/base/content/quickFilterBar.js
+++ b/mail/base/content/quickFilterBar.js
@@ -80,38 +80,56 @@ let QuickFilterBarMuxer = {
 
   /**
    * Decide whether to display the filter bar toggle button whenever a folder
    *  display is made active.  makeActive is what triggers the display of
    *  account central so this is the perfect spot to do so.
    */
   onMakeActive: function QFBM_onMakeActive(aFolderDisplay) {
     let tab = aFolderDisplay._tabInfo;
-    let appropriate = ("quickFilter" in tab._ext) &&
-                        aFolderDisplay.displayedFolder &&
-                        !aFolderDisplay.displayedFolder.isServer;
-    let qfbButton = document.getElementById("qfb-show-filter-bar");
-    if (qfbButton)
-      qfbButton.style.visibility = (appropriate ? "visible" : "hidden");
-
+    this._updateToggle(tab);
     // The case in that previous aFolderDisplay is showing a normal folder is
-    //  handled by onLoadingFolder. Here we handle the case where previous
+    // handled by onLoadingFolder. Here we handle the case where previous
     // aFolderDisplay shows an account folder instead (this cannot be done
     // in onLoadingFolder because that event is not raised).
     if (!aFolderDisplay.displayedFolder ||
         aFolderDisplay.displayedFolder.isServer) {
       let filterer = this.maybeActiveFilterer;
       if (!filterer)
         return;
       // Clear displayedFolder to force next onLoadingFolder to recreate the view
       filterer.displayedFolder = null;
     }
   },
 
   /**
+   * Based on the passed in 3pane aTabInfo, determine whether or not the
+   * quickFilter toggle should be enabled, and set it appropriately.
+   */
+  _updateToggle: function QFBM__updateToggle(aTabInfo) {
+    let folderDisplay = aTabInfo.folderDisplay;
+
+    let hasQuickFilter = "quickFilter" in aTabInfo._ext;
+    let isFolderView = (aTabInfo.mode.name == "folder" &&
+                        folderDisplay.displayedFolder &&
+                        !folderDisplay.displayedFolder.isServer);
+    let isGlodaList = aTabInfo.mode.name == "glodaList";
+    let appropriate = hasQuickFilter && (isGlodaList || isFolderView);
+
+    let qfbButton = document.getElementById("qfb-show-filter-bar");
+
+    if (qfbButton) {
+      qfbButton.style.visibility = (appropriate ? "visible" : "hidden");
+      if (!appropriate)
+        qfbButton.checked = false;
+    }
+  },
+
+
+  /**
    * Clear out our state when notified the user has changed folders and re-apply
    *  search constraints if we are in sticky mode.  It is important that we
    *  re-apply search constraints here in onLoadingFolder as this is the only
    *  notification we receive where we have a chance to avoid creating a view
    *  just to nuke it and re-create it with our new search constraints shortly
    *  afterwards.
    */
   onLoadingFolder: function QFBM_onFolderChanged(aFolderDisplay,
@@ -436,16 +454,17 @@ let QuickFilterBarMuxer = {
     if (aTab.mode.name == "folder" ||
         aTab.mode.name == "glodaList") {
       let modelTab =
         this.tabmail.getTabInfoForCurrentOrFirstModeInstance(aTab.mode);
       let oldFilterer = (modelTab && ("quickFilter" in modelTab._ext)) ?
                           modelTab._ext.quickFilter : undefined;
       aTab._ext.quickFilter = new QuickFilterState(oldFilterer);
       this.updateSearch(aTab);
+      this._updateToggle(aTab);
     }
   },
 
   onTabRestored: function QFBM_onTabRestored(aTab, aState, aFirstTab) {
     let filterer = aTab._ext.quickFilter = new QuickFilterState(null, aState);
     this.updateSearch(aTab);
     if (aTab == this.tabmail.currentTabInfo)
       this.reflectFiltererState(filterer, aTab.folderDisplay);