Bug 729197 - Make Quick Filter Bar toggle work for glodaList tabs. r=bwinton,a=Standard8.
authorMike Conley <mconley@mozilla.com>
Tue, 21 Feb 2012 17:26:29 -0500
changeset 11643 240d12a4dbe264d475a79b251dc78dc8b98de037
parent 11642 80897e9cafe7dfc2b18aa7daa276abd1572691d7
child 11644 a97e6cafdc03488c140d6bdce89508a769d19ec0
push id6
push userbienvenu@nventure.com
push dateWed, 16 May 2012 22:24:51 +0000
treeherdertry-comm-central@ac395aea3008 [default view] [failures only]
reviewersbwinton, Standard8
bugs729197
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,55 @@ 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.disabled = !appropriate;
-
+    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.disabled = !appropriate;
+      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 +453,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);