2013-03-26 14:23:23 -07:00
|
|
|
# -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Customization handler prepares this browser window for entering and exiting
|
2013-05-17 12:29:05 -07:00
|
|
|
* customization mode by handling customizationstarting and customizationending
|
2013-03-26 14:23:23 -07:00
|
|
|
* events.
|
|
|
|
*/
|
|
|
|
let CustomizationHandler = {
|
|
|
|
handleEvent: function(aEvent) {
|
|
|
|
switch(aEvent.type) {
|
2013-05-17 12:29:05 -07:00
|
|
|
case "customizationstarting":
|
|
|
|
this._customizationStarting();
|
2013-03-26 14:23:23 -07:00
|
|
|
break;
|
2013-05-17 12:29:05 -07:00
|
|
|
case "customizationending":
|
|
|
|
this._customizationEnding(aEvent.detail);
|
2013-03-26 14:23:23 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-06-29 01:25:56 -07:00
|
|
|
isCustomizing: function() {
|
|
|
|
return document.documentElement.hasAttribute("customizing") ||
|
|
|
|
document.documentElement.hasAttribute("customize-exiting");
|
|
|
|
},
|
|
|
|
|
2013-05-17 12:29:05 -07:00
|
|
|
_customizationStarting: function() {
|
2013-03-26 14:23:23 -07:00
|
|
|
// Disable the toolbar context menu items
|
|
|
|
let menubar = document.getElementById("main-menubar");
|
|
|
|
for (let childNode of menubar.childNodes)
|
|
|
|
childNode.setAttribute("disabled", true);
|
|
|
|
|
|
|
|
let cmd = document.getElementById("cmd_CustomizeToolbars");
|
|
|
|
cmd.setAttribute("disabled", "true");
|
|
|
|
|
|
|
|
let splitter = document.getElementById("urlbar-search-splitter");
|
|
|
|
if (splitter) {
|
|
|
|
splitter.parentNode.removeChild(splitter);
|
|
|
|
}
|
|
|
|
|
|
|
|
CombinedStopReload.uninit();
|
|
|
|
PlacesToolbarHelper.customizeStart();
|
2013-05-13 10:04:32 -07:00
|
|
|
BookmarkingUI.customizeStart();
|
2013-03-26 14:23:23 -07:00
|
|
|
DownloadsButton.customizeStart();
|
|
|
|
},
|
|
|
|
|
2013-05-17 12:29:05 -07:00
|
|
|
_customizationEnding: function(aDetails) {
|
2013-03-26 14:23:23 -07:00
|
|
|
// Update global UI elements that may have been added or removed
|
|
|
|
if (aDetails.changed) {
|
|
|
|
gURLBar = document.getElementById("urlbar");
|
|
|
|
|
|
|
|
gProxyFavIcon = document.getElementById("page-proxy-favicon");
|
|
|
|
gHomeButton.updateTooltip();
|
|
|
|
gIdentityHandler._cacheElements();
|
|
|
|
XULBrowserWindow.init();
|
|
|
|
|
|
|
|
#ifndef XP_MACOSX
|
|
|
|
updateEditUIVisibility();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Hacky: update the PopupNotifications' object's reference to the iconBox,
|
|
|
|
// if it already exists, since it may have changed if the URL bar was
|
|
|
|
// added/removed.
|
|
|
|
if (!window.__lookupGetter__("PopupNotifications")) {
|
|
|
|
PopupNotifications.iconBox =
|
|
|
|
document.getElementById("notification-popup-box");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PlacesToolbarHelper.customizeDone();
|
2013-05-13 10:04:32 -07:00
|
|
|
BookmarkingUI.customizeDone();
|
2013-03-26 14:23:23 -07:00
|
|
|
DownloadsButton.customizeDone();
|
|
|
|
|
|
|
|
// The url bar splitter state is dependent on whether stop/reload
|
|
|
|
// and the location bar are combined, so we need this ordering
|
|
|
|
CombinedStopReload.init();
|
|
|
|
UpdateUrlbarSearchSplitterState();
|
|
|
|
|
|
|
|
// Update the urlbar
|
|
|
|
if (gURLBar) {
|
|
|
|
URLBarSetURI();
|
|
|
|
XULBrowserWindow.asyncUpdateUI();
|
2013-05-13 10:04:32 -07:00
|
|
|
BookmarkingUI.updateStarState();
|
2013-03-26 14:23:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Re-enable parts of the UI we disabled during the dialog
|
|
|
|
let menubar = document.getElementById("main-menubar");
|
|
|
|
for (let childNode of menubar.childNodes)
|
|
|
|
childNode.setAttribute("disabled", false);
|
|
|
|
let cmd = document.getElementById("cmd_CustomizeToolbars");
|
|
|
|
cmd.removeAttribute("disabled");
|
|
|
|
|
|
|
|
gBrowser.selectedBrowser.focus();
|
|
|
|
}
|
|
|
|
}
|