alecf%netscape.com 868ac4081c Fix for bug 138299 - switch consumers of nsIWindowMediator service to use the non-RDF contractID, in preparation for bug 132175
r=danm, sr=jag


git-svn-id: svn://10.0.0.236/trunk@120272 18797224-902f-48f8-a5cc-f745e15eee43
2002-04-30 01:36:59 +00:00

37 lines
1.3 KiB
JavaScript
Executable File

const MOZ_HELP_URI = "chrome://help/content/help.xul";
const MOZILLA_HELP = "chrome://help/locale/mozillahelp.rdf";
var helpFileURI = MOZILLA_HELP;
// Call this function to display a help topic.
// uri: [chrome uri of rdf help file][?topic]
function openHelp(topic) {
var topWindow = locateHelpWindow(helpFileURI);
if ( topWindow ) {
topWindow.focus();
topWindow.displayTopic(topic);
} else {
var encodedURI = encodeURIComponent(helpFileURI + "?" + ((topic)?topic:""));
window.open(MOZ_HELP_URI + "?" + encodedURI, "_blank", "chrome,menubar,toolbar,dialog=no,resizable,scrollbars");
}
}
function setHelpFileURI(rdfURI) {
helpFileURI = rdfURI;
}
// Locate mozilla:help window (if any) opened for this help file uri.
function locateHelpWindow(helpFileURI) {
var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
var iterator = windowManagerInterface.getEnumerator( "mozilla:help");
var topWindow = null;
while (iterator.hasMoreElements()) {
var aWindow = iterator.getNext();
if (aWindow.getHelpFileURI() == helpFileURI) {
topWindow = aWindow;
break;
}
}
return topWindow;
}