Bug 643414 - Hide "Undo Disconnect" notification when panel is closed [r=mfinkle]

This commit is contained in:
Matt Brubeck 2011-03-23 08:13:45 -07:00
parent 322645e3a8
commit f820d8fb66
2 changed files with 22 additions and 13 deletions

View File

@ -386,18 +386,22 @@ var BrowserUI = {
let panels = document.getElementById("panel-items")
let panel = aPanelId ? document.getElementById(aPanelId) : panels.selectedPanel;
let oldPanel = panels.selectedPanel;
if (panels.selectedPanel == panel) {
// Fire a "select" event anyway so listeners know when the panel is opened.
let event = document.createEvent("Events");
event.initEvent("select", true, true);
panels.dispatchEvent(event);
} else {
if (oldPanel != panel) {
panels.selectedPanel = panel;
let button = document.getElementsByAttribute("linkedpanel", aPanelId)[0];
if (button)
button.checked = true;
let event = document.createEvent("Events");
event.initEvent("ToolPanelHidden", true, true);
oldPanel.dispatchEvent(event);
}
let event = document.createEvent("Events");
event.initEvent("ToolPanelShown", true, true);
panel.dispatchEvent(event);
},
get toolbarH() {
@ -543,9 +547,7 @@ var BrowserUI = {
};
// Some initialization can be delayed until a panel is selected.
panels.addEventListener("select", function(aEvent) {
if (aEvent.target != panels)
return;
panels.addEventListener("ToolPanelShown", function(aEvent) {
let viewName = panelViews[panels.selectedPanel.id];
if (viewName)
window[viewName].delayedInit();
@ -793,6 +795,11 @@ var BrowserUI = {
Elements.panelUI.hidden = true;
Elements.contentShowing.removeAttribute("disabled");
this.blurFocusedElement();
let panels = document.getElementById("panel-items")
let event = document.createEvent("Events");
event.initEvent("ToolPanelHidden", true, true);
panels.selectedPanel.dispatchEvent(event);
},
isPanelVisible: function isPanelVisible() {

View File

@ -325,12 +325,14 @@ let WeaveGlue = {
} ];
this.showMessage(message, "undo-disconnect", buttons);
// XXX change to an event that fires when panel is changed or closed
setTimeout(function(self) {
let notification = self._msg.getNotificationWithValue("undo-disconnect");
// Hide the notification when the panel is changed or closed.
let panel = document.getElementById("prefs-container");
panel.addEventListener("ToolPanelHidden", function onHide(aEvent) {
panel.removeEventListener(aEvent.type, onHide, false);
let notification = WeaveGlue._msg.getNotificationWithValue("undo-disconnect");
if (notification)
notification.close();
}, 10000, this);
}, false);
Weave.Service.logout();
},