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.

     1 # -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/.
     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   },
    26   isCustomizing: function() {
    27     return document.documentElement.hasAttribute("customizing");
    28   },
    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);
    36     let cmd = document.getElementById("cmd_CustomizeToolbars");
    37     cmd.setAttribute("disabled", "true");
    39     UpdateUrlbarSearchSplitterState();
    41     CombinedStopReload.uninit();
    42     PlacesToolbarHelper.customizeStart();
    43     DownloadsButton.customizeStart();
    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   },
    54   _customizationChange: function() {
    55     gHomeButton.updatePersonalToolbarStyle();
    56     PlacesToolbarHelper.customizeChange();
    57   },
    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");
    64       gProxyFavIcon = document.getElementById("page-proxy-favicon");
    65       gHomeButton.updateTooltip();
    66       gIdentityHandler._cacheElements();
    67       XULBrowserWindow.init();
    69 #ifndef XP_MACOSX
    70       updateEditUIVisibility();
    71 #endif
    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       }
    81     }
    83     PlacesToolbarHelper.customizeDone();
    84     DownloadsButton.customizeDone();
    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();
    91     // Update the urlbar
    92     if (gURLBar) {
    93       URLBarSetURI();
    94       XULBrowserWindow.asyncUpdateUI();
    95     }
    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");
   104     gBrowser.selectedBrowser.focus();
   105   }
   106 }

mercurial