home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2006 April / DPPRO0406DVD.ISO / Essentials / Programming / Eclipse SDK / eclipse-SDK-3.1.1-win32.exe / eclipse / plugins / org.eclipse.help_3.1.0.jar / livehelp.js < prev    next >
Encoding:
JavaScript  |  2005-09-29  |  2.3 KB  |  80 lines

  1. /*******************************************************************************
  2.  * Copyright (c) 2000, 2005 IBM Corporation and others.
  3.  * All rights reserved. This program and the accompanying materials 
  4.  * are made available under the terms of the Eclipse Public License v1.0
  5.  * which accompanies this distribution, and is available at
  6.  * http://www.eclipse.org/legal/epl-v10.html
  7.  * 
  8.  * Contributors:
  9.  *     IBM Corporation - initial API and implementation
  10.  *******************************************************************************/
  11.  
  12. /**
  13.  * Private helper function for use by other (public) functions. 
  14.  */
  15. function findHelpTop() {
  16.     var helpTop;
  17.     for (helpTop=self; helpTop; helpTop = helpTop.parent){
  18.         if (helpTop.liveActionInternal){
  19.             break;
  20.         }
  21.         if (helpTop==helpTop.parent){
  22.             break;
  23.         }
  24.     }
  25.     return helpTop;
  26. }
  27.  
  28. /**
  29.  * Call this Javascript method to trigger a specified live help action
  30.  * in the workbench. 
  31.  * The parameters for liveAction  are:
  32.  * - the id of the plug-in that contains the action
  33.  * - the name of the class that implements the action
  34.  * - the String that will be passed to the live help action using setInitializationString
  35.  */
  36.  
  37. function liveAction(pluginId, className, argument)
  38. {
  39.     // find top help frameset
  40.     var helpTop=findHelpTop();
  41.     if (helpTop != null && helpTop.liveActionInternal){
  42.         return helpTop.liveActionInternal(helpTop, pluginId, className, argument);
  43.     } else if (helpTop == self){
  44.         // no frames, possibly help view
  45.         var url= window.location.href;
  46.         
  47.         var i = url.indexOf("?");
  48.         if(i>0)
  49.             url=url.substring(0, i);
  50.         
  51.         i = url.indexOf("/ntopic/");
  52.         if(i < 0) {
  53.             // not help view
  54.             return;
  55.         }
  56.     
  57.         url=url.substring(0, i+1);
  58.         var encodedArg=encodeURIComponent(argument);
  59.         url=url+"livehelp/?pluginID="+pluginId+"&class="+className+"&arg="+encodedArg+"&nocaching="+Math.random();
  60.         window.location.href = url;
  61.     }
  62. }
  63.  
  64. /**
  65.  * Show specified topic in the Contents tree.
  66.  * The topic must be passed as a URL string.
  67.  * Example:
  68.  *  // include the script first
  69.  *  <script src="../org.eclipse.help/livehelp.js"></script>
  70.  *  ......
  71.  *  // show specified topic in the tree
  72.  *  showTopicInContents(window.location.href); 
  73.  */
  74. function showTopicInContents(topic) {
  75.         var helpTop=findHelpTop();
  76.         if (helpTop != null && helpTop.showTopicInContentsInternal){
  77.             return helpTop.showTopicInContentsInternal(helpTop, topic);
  78.         }
  79. }
  80.