Bug 503847 - Quick search does not remember selection on restart. r=philor, a=blocking-thunderbird3
authorAndrew Sutherland <asutherland@asutherland.org>
Tue, 14 Jul 2009 20:00:47 -0700
changeset 3061 916b3ed62ca7defbc05179ccc3fe859247f0dbec
parent 3060 8bcda0062daee7f017ef767823d9fa6a06df5643
child 3062 c7415baf5df07486031dd7e913f6271aecf2d5bc
push id2494
push userbugmail@asutherland.org
push dateWed, 15 Jul 2009 03:01:01 +0000
treeherdercomm-central@916b3ed62ca7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilor, blocking-thunderbird3
bugs503847
Bug 503847 - Quick search does not remember selection on restart. r=philor, a=blocking-thunderbird3
mail/base/content/search.xml
--- a/mail/base/content/search.xml
+++ b/mail/base/content/search.xml
@@ -238,50 +238,38 @@
                          onclick="onClearSearch(); return false;"
                          chromedir="&locale.dir;"/>
     </content>
 
     <implementation>
       <constructor>
         <![CDATA[
           // initialize the quick search mode based on the checked menu item
-          var desiredQuickSearchMode = document.getElementById('quick-search-menupopup').getAttribute('value');             
-          
-          var menuItems = document.getElementById('quick-search-menupopup').getElementsByAttribute('value', '*');
-          var selectedMenuItem;
-          for (var index = 0; index < menuItems.length; index++) 
-            if (menuItems[index].getAttribute("value") == desiredQuickSearchMode)
-            {
-              selectedMenuItem = menuItems[index];
-              break;
-            }
-          
-          // if we failed to find selectedMenuItemVal in our array of menuitems
-          // then just use the first menu item in the array (surely we have at least one menu item!)
-          // This scenario happens when we decide to obsolete/delete search modes from 
-          // the quick search drop down.
-          if (!selectedMenuItem && menuItems.length) {
-            selectedMenuItem = menuItems[0];
+          // (getAttribute returns a string so "0" is still true...)
+          this.mQuickSearchMode  =
+            document.getElementById('quick-search-menupopup')
+                    .getAttribute('value') ||
+            QuickSearchConstants.kQuickSearchFromOrSubject.toString();
 
-            selectedMenuItem.setAttribute('checked', 'true');
-            this.mQuickSearchMode =
-              selectedMenuItem.getAttribute("value");
-          }
+          var selectedMenuItem =
+            document.getElementById('quick-search-menupopup')
+                    .getElementsByAttribute('value', this.mQuickSearchMode)[0];
+          selectedMenuItem.setAttribute('checked', 'true');
 
           this.setSearchCriteriaText();
         ]]>
       </constructor>
 
       <property name="showingSearchCriteria" onget="return this.getAttribute('searchCriteria') == 'true';"
                 onset="this.setAttribute('searchCriteria', val); return val;"/>
 
       <property name="clearButtonHidden" onget="return document.getElementById('quick-search-clearbutton').getAttribute('clearButtonHidden') == 'true';"
                 onset="document.getElementById('quick-search-clearbutton').setAttribute('clearButtonHidden', val); return val;"/>
 
-      <field name="mQuickSearchMode">0</field>
+      <field name="mQuickSearchMode">null</field>
 
       // DND Observer
       <field name="searchInputDNDObserver" readonly="true"><![CDATA[
       ({
         inputSearch: this,
 
         onDrop: function (aEvent, aXferData, aDragSession)
         {