home *** CD-ROM | disk | FTP | other *** search
/ ftp.swcp.com / ftp.swcp.com.zip / ftp.swcp.com / mac / mozilla-macos9-1.3.1.sea.bin / Mozilla1.3.1 / Chrome / help.jar / content / help / contextHelp.js < prev    next >
Text File  |  2003-06-07  |  2KB  |  57 lines

  1. /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  * The contents of this file are subject to the Netscape Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/NPL/
  6.  * 
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  * 
  12.  * The Original Code is Mozilla Communicator client code, released
  13.  * March 31, 1998.
  14.  * 
  15.  * The Initial Developer of the Original Code is Netscape
  16.  * Communications Corporation. Portions created by Netscape are
  17.  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
  18.  * Rights Reserved.
  19.  */
  20.  
  21. const MOZ_HELP_URI = "chrome://help/content/help.xul";
  22. const MOZILLA_HELP = "chrome://help/locale/mozillahelp.rdf";
  23. var helpFileURI = MOZILLA_HELP;
  24.  
  25. // Call this function to display a help topic.
  26. // uri: [chrome uri of rdf help file][?topic]
  27. function openHelp(topic) {
  28.   var topWindow = locateHelpWindow(helpFileURI);
  29.   if ( topWindow ) {
  30.     topWindow.focus();
  31.     topWindow.displayTopic(topic);
  32.   } else {
  33.       var encodedURI = encodeURIComponent(helpFileURI + "?" + ((topic)?topic:""));  
  34.       window.open(MOZ_HELP_URI + "?" + encodedURI, "_blank", "chrome,menubar,toolbar,dialog=no,resizable,scrollbars,alwaysRaised");
  35.   }
  36. }
  37.  
  38. function setHelpFileURI(rdfURI) {
  39.   helpFileURI = rdfURI; 
  40. }
  41.  
  42. // Locate mozilla:help window (if any) opened for this help file uri.
  43. function locateHelpWindow(helpFileURI) {
  44.   var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
  45.   var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
  46.   var iterator = windowManagerInterface.getEnumerator( "mozilla:help");
  47.   var topWindow = null;
  48.   while (iterator.hasMoreElements()) {
  49.     var aWindow = iterator.getNext();
  50.     if (aWindow.getHelpFileURI() == helpFileURI) {
  51.       topWindow = aWindow;
  52.       break;  
  53.     }  
  54.   }
  55.   return topWindow;
  56. }
  57.