home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha Extra 2002 March / CMYCHA200203_EXTRA_broken.iso / Przegladarki / NetscapeSetupB.exe / bin / chrome / help.jar / content / help / contextHelp.js next >
Text File  |  2002-04-09  |  1KB  |  37 lines

  1. const MOZ_HELP_URI = "chrome://help/content/help.xul";
  2. const MOZILLA_HELP = "chrome://help/locale/mozillahelp.rdf";
  3. var helpFileURI = MOZILLA_HELP;
  4.  
  5. // Call this function to display a help topic.
  6. // uri: [chrome uri of rdf help file][?topic]
  7. function openHelp(topic) {
  8.   var topWindow = locateHelpWindow(helpFileURI);
  9.   if ( topWindow ) {
  10.     topWindow.focus();
  11.     topWindow.displayTopic(topic);
  12.   } else {
  13.       var encodedURI = encodeURIComponent(helpFileURI + "?" + ((topic)?topic:""));  
  14.       window.open(MOZ_HELP_URI + "?" + encodedURI, "_blank", "chrome,menubar,toolbar,dialog=no,resizable,scrollbars");
  15.   }
  16. }
  17.  
  18. function setHelpFileURI(rdfURI) {
  19.   helpFileURI = rdfURI; 
  20. }
  21.  
  22. // Locate mozilla:help window (if any) opened for this help file uri.
  23. function locateHelpWindow(helpFileURI) {
  24.   var windowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();
  25.   var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
  26.   var iterator = windowManagerInterface.getEnumerator( "mozilla:help");
  27.   var topWindow = null;
  28.   while (iterator.hasMoreElements()) {
  29.     var aWindow = iterator.getNext();
  30.     if (aWindow.getHelpFileURI() == helpFileURI) {
  31.       topWindow = aWindow;
  32.       break;  
  33.     }  
  34.   }
  35.   return topWindow;
  36. }
  37.