Bug 188910 - focus is in the searchbox of the bookmarks/history sidebar when opening a new window; should only be there when opening the sidebar, patch by Steffen Wilberg (steffen.wilberg@web.de), r=mconnor@myrealbox.com

This commit is contained in:
mconnor%myrealbox.com 2004-05-23 02:21:21 +00:00
parent 0111a7739f
commit ff5baff067

View File

@ -2745,8 +2745,25 @@ function toggleSidebar(aCommandID, forceOpen) {
sidebarBox.setAttribute("src", url);
sidebarBox.setAttribute("sidebarcommand", elt.id);
sidebarTitle.setAttribute("value", title);
if (aCommandID != "viewWebPanelsSidebar") { // no searchbox there
// if the sidebar we want is already constructed, focus the searchbox
if ((aCommandID == "viewBookmarksSidebar" && sidebar.contentDocument.getElementById("bookmarksPanel"))
|| (aCommandID == "viewHistorySidebar" && sidebar.contentDocument.getElementById("history-panel")))
sidebar.contentDocument.getElementById("search-box").focus();
// otherwiese, attach an onload handler
else
sidebar.addEventListener("load", asyncFocusSearchBox, true);
}
}
function asyncFocusSearchBox(event)
{
var sidebar = document.getElementById("sidebar");
var searchBox = sidebar.contentDocument.getElementById("search-box");
searchBox.focus();
sidebar.removeEventListener("load", asyncFocusSearchBox, true);
}
function openPreferences()
{
openDialog("chrome://browser/content/pref/pref.xul","PrefWindow",