Skip to content

Commit

Permalink
Focus main content area if all panels are hidden.
Browse files Browse the repository at this point in the history
b=89207; r=morse; sr=alecf
  • Loading branch information
sgehani%netscape.com committed Dec 21, 2001
1 parent 1320c4c commit ebb1c35
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions xpfe/components/sidebar/resources/sidebarOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,19 @@ function (panels)
return null;
}

sbPanelList.prototype.visible_panels_exist =
function ()
{
var i;
var panels = this.node.childNodes;
for (i = 2; i < panels.length; i += 2)
{
if (!panels.item(i).hidden)
return true;
}
return false;
}

sbPanelList.prototype.select =
function (panel, force_reload)
{
Expand Down Expand Up @@ -1006,6 +1019,7 @@ function SidebarTogglePanel(panel_menuitem) {
// manipulate the RDF:Seq more easily.
sidebarObj.datasource = RDF.GetDataSource(sidebarObj.datasource_uri);

var did_exclude = false;
var panel_id = panel_menuitem.getAttribute('id');
var panel = sidebarObj.panels.get_panel_from_id(panel_id);
var panel_exclude = panel_menuitem.getAttribute('exclude')
Expand All @@ -1017,6 +1031,7 @@ function SidebarTogglePanel(panel_menuitem) {
RDF.GetLiteral(sidebarObj.component),
true);
panel.exclude();
did_exclude = true;
} else {
// Panel has an exclude string, but it may or may not have the
// current component listed in the string.
Expand All @@ -1032,6 +1047,7 @@ function SidebarTogglePanel(panel_menuitem) {
debug("Adding this component to the exclude list");
new_exclude = new_exclude + " " + sidebarObj.component;
panel.exclude();
did_exclude = true;
}
if (new_exclude == '') {
debug("Removing exclude list");
Expand All @@ -1051,8 +1067,12 @@ function SidebarTogglePanel(panel_menuitem) {
}
}

// force all the sidebars to update
refresh_all_sidebars();
if (did_exclude && !sidebarObj.panels.visible_panels_exist())
// surrender focus to main content area
window._content.focus();
else
// force all the sidebars to update
refresh_all_sidebars();

// Write the modified panels out.
sidebarObj.datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
Expand Down

0 comments on commit ebb1c35

Please sign in to comment.