home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 March / PCWorld_2007-03_cd.bin / komunikace / nvu / nvu-1.0-cs-CZ.win32.installer.exe / chrome / helpcs.jar / content / help / contextHelp.js < prev    next >
Text File  |  2005-06-21  |  1KB  |  48 lines

  1.  
  2. const MOZILLA_CONTENT_PACK = "chrome://help/locale/nvu.rdf";
  3.  
  4. var helpFileURI = MOZILLA_CONTENT_PACK;
  5.  
  6. function openHelp(topic, contentPack)
  7. {
  8.   helpFileURI = contentPack || helpFileURI;
  9.  
  10.   var topWindow = locateHelpWindow(helpFileURI);
  11.  
  12.   if ( topWindow ) {
  13.     topWindow.focus();
  14.     topWindow.displayTopic(topic);
  15.   } else {
  16.     const params = Components.classes["@mozilla.org/embedcomp/dialogparam;1"]
  17.                              .createInstance(Components.interfaces.nsIDialogParamBlock);
  18.     params.SetNumberStrings(2);
  19.     params.SetString(0, helpFileURI);
  20.     params.SetString(1, topic);
  21.     const ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
  22.                          .getService(Components.interfaces.nsIWindowWatcher);
  23.     ww.openWindow(null, "chrome://help/content/help.xul", "_blank", "chrome,all,dialog=no", params);
  24.   }
  25. }
  26.  
  27. function setHelpFileURI(rdfURI)
  28. {
  29.   helpFileURI = rdfURI;
  30. }
  31.  
  32. function locateHelpWindow(contentPack) {
  33.     const windowManagerInterface = Components
  34.         .classes['@mozilla.org/appshell/window-mediator;1'].getService()
  35.         .QueryInterface(Components.interfaces.nsIWindowMediator);
  36.     const iterator = windowManagerInterface.getEnumerator("mozilla:help");
  37.     var topWindow = null;
  38.     var aWindow;
  39.  
  40.     while (iterator.hasMoreElements()) {
  41.         aWindow = iterator.getNext();
  42.         if (aWindow.getHelpFileURI() == contentPack) {
  43.             topWindow = aWindow;
  44.         }
  45.     }
  46.     return topWindow;
  47. }
  48.