diff --git a/suite/browser/navigator.js b/suite/browser/navigator.js index 810d36a6925..af91839f079 100644 --- a/suite/browser/navigator.js +++ b/suite/browser/navigator.js @@ -620,8 +620,56 @@ function BrowserHome() loadURI(homePage); } +function OpenBookmarkGroup(element, datasource) +{ + if (!datasource) + return; + + var id = element.getAttribute("id"); + var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"] + .getService(Components.interfaces.nsIRDFService); + var resource = rdf.GetResource(id, true); + return OpenBookmarkGroupFromResource(resource, datasource, rdf); +} + +function OpenBookmarkGroupFromResource(resource, datasource, rdf) { + var urlResource = rdf.GetResource("http://home.netscape.com/NC-rdf#URL"); + var rdfContainer = Components.classes["@mozilla.org/rdf/container;1"].getService(Components.interfaces.nsIRDFContainer); + rdfContainer.Init(datasource, resource); + var containerChildren = rdfContainer.GetElements(); + var tabPanels = gBrowser.mPanelContainer.childNodes; + var tabCount = tabPanels.length; + var index = 0; + while (containerChildren.hasMoreElements()) { + var resource = containerChildren.getNext().QueryInterface(Components.interfaces.nsIRDFResource); + var target = datasource.GetTarget(resource, urlResource, true); + if (target) { + var uri = target.QueryInterface(Components.interfaces.nsIRDFLiteral).Value; + if (index < tabCount) + tabPanels[index].loadURI(uri, null, nsIWebNavigation.LOAD_FLAGS_NONE); + else + gBrowser.addTab(uri); + index++; + } + } + + if (index == 0) + return; // If the bookmark group was completely invalid, just bail. + + // Select the first tab in the group. + var tabs = gBrowser.mTabContainer.childNodes; + gBrowser.selectedTab = tabs[0]; + + // Close any remaining open tabs that are left over. + for (var i = tabCount-1; i >= index; i--) + gBrowser.removeTab(tabs[i]); +} + function OpenBookmarkURL(node, datasources) { + if (node.getAttribute("group") == "true") + OpenBookmarkGroup(node, datasources); + if (node.getAttribute("container") == "true") return; diff --git a/suite/browser/navigator.xul b/suite/browser/navigator.xul index 97dc38f1467..ce5465a61b5 100644 --- a/suite/browser/navigator.xul +++ b/suite/browser/navigator.xul @@ -281,15 +281,13 @@ Contributor(s): ______________________________________. --> ref="NC:PersonalToolbarFolder" flags="dont-test-empty" rdf:type="http://home.netscape.com/NC-rdf#Folder" oncommand="OpenBookmarkURL(event.target, document.getElementById('innermostBox').database)"> - - -