browser/base/content/browser-customization.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial