Bug 886030 - Add events to toolbar change to help customizableui deal with appearing/disappearing toolbars, r=mconley

This commit is contained in:
Gijs Kruitbosch 2013-07-10 14:05:35 +02:00
parent a4ee03cec4
commit 5d30f31f83
2 changed files with 24 additions and 0 deletions

View File

@ -4302,6 +4302,14 @@ function setToolbarVisibility(toolbar, isVisible) {
toolbar.setAttribute(hidingAttribute, !isVisible);
document.persist(toolbar.id, hidingAttribute);
let eventParams = {
detail: {
visible: isVisible
},
bubbles: true
};
let event = new CustomEvent("toolbarvisibilitychange", eventParams);
toolbar.dispatchEvent(event);
PlacesToolbarHelper.init();
BookmarkingUI.onToolbarVisibilityChange();

View File

@ -134,6 +134,8 @@ CustomizeMode.prototype = {
this.visiblePalette.addEventListener("drop", this, true);
this.visiblePalette.addEventListener("dragend", this, true);
window.gNavToolbox.addEventListener("toolbarvisibilitychange", this);
// Same goes for the menu button - if we're customizing, a click to the
// menu button means a quick exit from customization mode.
window.PanelUI.menuButton.addEventListener("click", this, false);
@ -185,6 +187,8 @@ CustomizeMode.prototype = {
yield this.depopulatePalette();
window.gNavToolbox.removeEventListener("toolbarvisibilitychange", this);
window.PanelUI.mainView.removeEventListener("contextmenu", this, true);
this.visiblePalette.removeEventListener("dragstart", this, true);
this.visiblePalette.removeEventListener("dragover", this, true);
@ -570,6 +574,15 @@ CustomizeMode.prototype = {
}.bind(this));
},
_onToolbarVisibilityChange: function(aEvent) {
let toolbar = aEvent.target;
if (aEvent.detail.visible) {
toolbar.setAttribute("customizing", "true");
} else {
toolbar.removeAttribute("customizing");
}
},
onWidgetMoved: function(aWidgetId, aArea, aOldPosition, aNewPosition) {
this._onUIChange();
},
@ -601,6 +614,9 @@ CustomizeMode.prototype = {
handleEvent: function(aEvent) {
switch(aEvent.type) {
case "toolbarvisibilitychange":
this._onToolbarVisibilityChange(aEvent);
break;
case "contextmenu":
aEvent.preventDefault();
aEvent.stopPropagation();