Bug 633497 - Preferences aren't initialized when opened from the app menu [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Fri, 11 Feb 2011 11:57:41 -0800
changeset 67377 1c6a37151d8a0fcdd6ec3fb9a558bec7cfc54cd8
parent 67376 856b0d1e26ced0d73a1a807fa0d59aaec650e3a9
child 67378 b4270e4b624ecbb35f5dc79f50e29f54b8530348
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs633497
Bug 633497 - Preferences aren't initialized when opened from the app menu [r=mfinkle]
mobile/chrome/content/browser-ui.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -377,24 +377,32 @@ var BrowserUI = {
     let elements = this._popup.elements;
     let targetNode = aEvent ? aEvent.target : null;
     while (targetNode && elements.indexOf(targetNode) == -1)
       targetNode = targetNode.parentNode;
     return targetNode ? true : false;
   },
 
   switchPane: function switchPane(aPanelId) {
-    let button = document.getElementsByAttribute("linkedpanel", aPanelId)[0];
-    if (button)
-      button.checked = true;
-
     this.blurFocusedElement();
 
-    let pane = document.getElementById(aPanelId);
-    document.getElementById("panel-items").selectedPanel = pane;
+    let panels = document.getElementById("panel-items")
+    let panel = aPanelId ? document.getElementById(aPanelId) : panels.selectedPanel;
+
+    if (panels.selectedPanel == panel) {
+      // Fire a "select" event anyway so listeners know when the panel is opened.
+      let event = document.createEvent("Events");
+      event.initEvent("select", true, true);
+      panels.dispatchEvent(event);
+    } else {
+      panels.selectedPanel = panel;
+      let button = document.getElementsByAttribute("linkedpanel", aPanelId)[0];
+      if (button)
+        button.checked = true;
+    }
   },
 
   get toolbarH() {
     if (!this._toolbarH) {
       let toolbar = document.getElementById("toolbar-main");
       this._toolbarH = toolbar.boxObject.height;
     }
     return this._toolbarH;
@@ -747,32 +755,25 @@ var BrowserUI = {
   },
 
   isTabsVisible: function isTabsVisible() {
     // The _1, _2 and _3 are to make the js2 emacs mode happy
     let [leftvis,_1,_2,_3] = Browser.computeSidebarVisibility();
     return (leftvis > 0.002);
   },
 
-  showPanel: function showPanel(aPage) {
+  showPanel: function showPanel(aPanelId) {
     if (this.activePanel)
-      this.activePanel = null;
+      this.activePanel = null; // Hide the awesomescreen.
 
     Elements.panelUI.left = 0;
     Elements.panelUI.hidden = false;
     Elements.contentShowing.setAttribute("disabled", "true");
 
-    if (aPage) {
-      this.switchPane(aPage);
-    } else {
-      // Fire a "select" event anyway so listeners know when the panel is opened.
-      let event = document.createEvent("Events");
-      event.initEvent("select", true, true);
-      document.getElementById("panel-items").dispatchEvent(event);
-    }
+    this.switchPane(aPanelId);
   },
 
   hidePanel: function hidePanel() {
     if (!this.isPanelVisible())
       return;
     Elements.panelUI.hidden = true;
     Elements.contentShowing.removeAttribute("disabled");
     this.blurFocusedElement();