117668 - convert help to outliner. r=oeschger sr=hewitt

git-svn-id: svn://10.0.0.236/trunk@111411 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
blakeross%telocity.com
2002-01-05 08:32:34 +00:00
parent 4eeea60a15
commit 5d9a89f460
2 changed files with 55 additions and 79 deletions

View File

@@ -1,6 +1,10 @@
//-------- global variables
var gBrowser;
var gRDF = null;
var gBuilder = null;
const kRDFContractID = "@mozilla.org/rdf/rdf-service;1";
const kRDFIID = Components.interfaces.nsIRDFService;
// The key object is used to define special context strings that, when appended to
// the url for the help window itself, load specific content. For example, the uri:
@@ -160,38 +164,6 @@ function init()
webProgress.addProgressListener(window.XULBrowserWindow);
}
// select the item in the tree called "Dialog Help" if the window was loaded from a dialog
function setContext() {
var items = document.getElementsByAttribute("helplink", "chrome://help/locale/context_help.html");
if (items.length) {
var tree = document.getElementById("help-toc-tree");
try { tree.selectItem(items[0].parentNode.parentNode); } catch(ex) { dump("can't select in toc: " + ex + "\n"); }
}
}
function selectTOC(link_attr) {
var items = document.getElementsByAttribute("helplink", link_attr);
if (items.length) {
openTwistyTo(items[0]);
var tree = document.getElementById("help-toc-tree");
try { tree.selectItem(items[0].parentNode.parentNode); } catch(ex) { dump("can't select in toc: " + ex + "\n"); }
}
}
// open parent nodes for the selected node
// until you get to the top of the tree
function openTwistyTo(selectedURINode)
{
var parent = selectedURINode.parentNode;
var tree = document.getElementById("help-toc-tree");
if (parent == tree)
return;
parent.setAttribute("open", "true");
openTwistyTo(parent);
}
function getWebNavigation()
{
return gBrowser.webNavigation;
@@ -222,6 +194,23 @@ function goHome() {
loadURI("chrome://help/locale/welcome_help.html");
}
function selectItem() {
var outliner = document.getElementById("help-toc-outliner");
if (!gBuilder)
gBuilder = outliner.outlinerBoxObject.outlinerBody.builder.QueryInterface(Components.interfaces.nsIXULOutlinerBuilder);
var source = gBuilder.getResourceAtIndex(outliner.outlinerBoxObject.selection.currentIndex);
if (!gRDF)
gRDF = Components.classes[kRDFContractID].getService(kRDFIID);
var property = gRDF.GetResource("http://home.netscape.com/NC-rdf#link");
var target = outliner.outlinerBoxObject.outlinerBody.database.GetTarget(source, property, true);
if (target)
target = target.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
loadURI(target);
}
function print()
{
try {

View File

@@ -115,7 +115,7 @@
<!-- the two help panes (sidebar & content) -->
<hbox flex="1">
<vbox id="helpsidebar-box">
<vbox id="helpsidebar-box" flex="10">
<separator class="thin"/>
<tabbox flex="1">
<tabs>
@@ -124,51 +124,38 @@
</tabs>
<tabpanels flex="1">
<hbox id="help-toc">
<tree id="help-toc-tree" ref="urn:root" flex="1*"
datasources="chrome://help/locale/help-toc.rdf"
containment="http://home.netscape.com/NC-rdf#subheadings"
onselect="loadURI(this.selectedItems[0].firstChild.firstChild.getAttribute('helplink'));">>
<template>
<rule>
<conditions>
<content uri="?uri"/>
<triple subject="?uri"
predicate="http://home.netscape.com/NC-rdf#subheadings"
object="?subheadings" />
<member container="?subheadings" child="?subheading"/>
</conditions>
<bindings>
<binding subject="?subheading"
predicate="http://home.netscape.com/NC-rdf#name"
object="?name" />
<binding subject="?subheading"
predicate="http://home.netscape.com/NC-rdf#link"
object="?link" />
</bindings>
<action>
<treechildren>
<treeitem uri="?subheading">
<treerow>
<treecell class="treecell-indent"
label="?name"
helplink="?link"/>
</treerow>
</treeitem>
</treechildren>
</action>
</rule>
</template>
<treecolgroup>
<treecol flex="1*" />
</treecolgroup>
<!-- because the outermost treechildren needs "flex='1'" -->
<treechildren flex="1*"/>
</tree>
<outliner id="help-toc-outliner" flex="1">
<outlinerbody datasources="chrome://help/locale/help-toc.rdf"
flex="1" ref="urn:root"
containment="http://home.netscape.com/NC-rdf#subheadings"
onselect="selectItem();">
<template>
<rule>
<conditions>
<outlinerrow uri="?uri"/>
<triple subject="?uri"
predicate="http://home.netscape.com/NC-rdf#subheadings"
object="?subheadings" />
<member container="?subheadings" child="?subheading"/>
</conditions>
<bindings>
<binding subject="?subheading"
predicate="http://home.netscape.com/NC-rdf#name"
object="?name" />
</bindings>
<action>
<outlinerrow uri="?subheading">
<outlinercell ref="Column" label="?name"/>
</outlinerrow>
</action>
</rule>
</template>
</outlinerbody>
<outlinercols>
<outlinercol flex="1" id="Column" primary="true" />
</outlinercols>
</outliner>
</hbox>
<hbox id="help-index">
@@ -189,7 +176,7 @@
</splitter>
<!-- this stuff lifted from navigator.xul -->
<vbox id="appcontent" flex="3">
<vbox id="appcontent" flex="5">
<!-- this box is temporary, pending XBLified <browser> -->
<hbox id="browser" flex="1">
<!-- type attribute is used by frame construction to locate iframes