Mozilla Cross-Reference mozilla-central
mozilla/ browser/ base/ content/ browser-customization.js
Hg Log
Hg Blame
Diff file
Raw file
view using tree:
1 # -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 
6 /**
7  * Customization handler prepares this browser window for entering and exiting
8  * customization mode by handling customizationstarting and customizationending
9  * events.
10  */
11 let CustomizationHandler = {
12   handleEvent: function(aEvent) {
13     switch(aEvent.type) {
14       case "customizationstarting":
15         this._customizationStarting();
16         break;
17       case "customizationchange":
18         this._customizationChange();
19         break;
20       case "customizationending":
21         this._customizationEnding(aEvent.detail);
22         break;
23     }
24   },
25 
26   isCustomizing: function() {
27     return document.documentElement.hasAttribute("customizing");
28   },
29 
30   _customizationStarting: function() {
31     // Disable the toolbar context menu items
32     let menubar = document.getElementById("main-menubar");
33     for (let childNode of menubar.childNodes)
34       childNode.setAttribute("disabled", true);
35 
36     let cmd = document.getElementById("cmd_CustomizeToolbars");
37     cmd.setAttribute("disabled", "true");
38 
39     UpdateUrlbarSearchSplitterState();
40 
41     CombinedStopReload.uninit();
42     PlacesToolbarHelper.customizeStart();
43     DownloadsButton.customizeStart();
44 
45     // The additional padding on the sides of the browser
46     // can cause the customize tab to get clipped.
47     let tabContainer = gBrowser.tabContainer;
48     if (tabContainer.getAttribute("overflow") == "true") {
49       let tabstrip = tabContainer.mTabstrip;
50       tabstrip.ensureElementIsVisible(gBrowser.selectedTab, true);
51     }
52   },
53 
54   _customizationChange: function() {
55     gHomeButton.updatePersonalToolbarStyle();
56     PlacesToolbarHelper.customizeChange();
57   },
58 
59   _customizationEnding: function(aDetails) {
60     // Update global UI elements that may have been added or removed
61     if (aDetails.changed) {
62       gURLBar = document.getElementById("urlbar");
63 
64       gProxyFavIcon = document.getElementById("page-proxy-favicon");
65       gHomeButton.updateTooltip();
66       gIdentityHandler._cacheElements();
67       XULBrowserWindow.init();
68 
69 #ifndef XP_MACOSX
70       updateEditUIVisibility();
71 #endif
72 
73       // Hacky: update the PopupNotifications' object's reference to the iconBox,
74       // if it already exists, since it may have changed if the URL bar was
75       // added/removed.
76       if (!window.__lookupGetter__("PopupNotifications")) {
77         PopupNotifications.iconBox =
78           document.getElementById("notification-popup-box");
79       }
80 
81     }
82 
83     PlacesToolbarHelper.customizeDone();
84     DownloadsButton.customizeDone();
85 
86     // The url bar splitter state is dependent on whether stop/reload
87     // and the location bar are combined, so we need this ordering
88     CombinedStopReload.init();
89     UpdateUrlbarSearchSplitterState();
90 
91     // Update the urlbar
92     if (gURLBar) {
93       URLBarSetURI();
94       XULBrowserWindow.asyncUpdateUI();
95     }
96 
97     // Re-enable parts of the UI we disabled during the dialog
98     let menubar = document.getElementById("main-menubar");
99     for (let childNode of menubar.childNodes)
100       childNode.setAttribute("disabled", false);
101     let cmd = document.getElementById("cmd_CustomizeToolbars");
102     cmd.removeAttribute("disabled");
103 
104     gBrowser.selectedBrowser.focus();
105   }
106 }
107 
view http://hg.mozilla.org/mozilla-central/rev/ /browser/base/content/browser-customization.js