Automatic TOC Syncing in WebWorks Help 3.0

WebWorks Help 3.0 can "sync" the TOC (that is, expand the necessary entries on the Contents tab to display the entry corresponding to the page you're looking at). By default, it only syncs when you click a button, but you can customize the template so that the TOC syncs automatically as needed.

By default, syncing forces the nav frame to display the Contents tab. However, if you're using the Index or Search, you might not want the nav frame to switch over to Contents. If the first Index or Search link you click isn't what you're looking for, you don't want to have to click back to choose another one. To avoid this problem, this automatic syncing only happens:

This modification also removes the "Show in Contents" button from the toolbar (when the navigation frame is visible).

To replicate this, you need to modify three files under your template's Support directory:

If you've made no other changes to these files, you can simply use the links above to download each file and save it over your local copy. To make the changes in your own files, see below.

Tip: Syncing the TOC does not collapse the TOC entries that are already expanded, it only expands lines as needed to show the target line. To make the target line easier to identify, you can also highlight the the target TOC line in bold.

In javascpt.js:

Edit the WWHJavaScript_StartChangeTab function as follows:

function  WWHJavaScript_StartChangeTab(ParamIndex)
{
  if (( ! this.mbChangingTabs) &&
      ((this.mCurrentTab == -1) ||
       (this.mCurrentTab != ParamIndex)))
  {
    // Signal that we are changing tabs
    //
    this.mbChangingTabs = true;

    // Record current scroll position
    //
    if (this.mCurrentTab != -1)
    {
      this.mPanels.fSaveScrollPosition();
    }

    // Update tab index
    //
    this.mCurrentTab = ParamIndex;

    // Update tab frame and panel frame
    //
    this.mTabs.fDisplayTab();
    this.mPanels.fDisplayPanel();

    // If we're switching to the TOC, sync it up.
    if (ParamIndex == "0")
    {
      WWHFrame.WWHControls.fSyncTOC();
    }
  }
}

In help.js:

Edit the WWHHelp_DocumentBookkeeping function as follows:

function  WWHHelp_DocumentBookkeeping(ParamURL)
{
  // Highlight search words
  //
  if (typeof WWHFrame.WWHHighlightWords != "undefined")
  {
    WWHFrame.WWHHighlightWords.fExec();
  }

  // Update controls
  //
  WWHFrame.WWHControls.fUpdateHREF(ParamURL);

  // Sync the TOC, if it's visible.
  if (!WWHControls.fSansNavigation() && WWHFrame.WWHJavaScript.mCurrentTab == "0")
  {
    WWHFrame.WWHControls.fSyncTOC();
  }

  // Update window title, if possible
  //
  if (ParamURL.indexOf("wwhelp/wwhimpl/common/html/default.htm") == -1)
  {
    if (WWHFrame.WWHBrowserInfo.mBrowser != 1)  // Shorthand for Netscape
    {
      WWHFrame.document.title = this.fHREFToTitle(ParamURL);
    }
  }
}

In controls.js:

  1. Edit the WWHControls_LeftHTML function as follows (other lines shown for context):

    ...
      if (this.fSansNavigation())
      {
        HTML += "  <td width=\"23\">\n";
        HTML += "   <a href=\"javascript:WWHFrame.WWHControls.fSyncTOC();\">";
        HTML += "<img name=\"WWHFrameSetIcon\" alt=\"" + WWHFrame.WWHHelp.mMessages.mShowNavigationIconLabel + "\" border=\"0\" src=\"../images/frameset.gif\" width=\"23\" height=\"21\">";
        HTML += "</a>";
        HTML += "</td>\n";
      }
      else if (!WWHJavaScript && Settings.mbSyncContentsEnabled) 
      { // Display the Sync TOC button only in Java mode.
        HTML += "  <td width=\"23\">\n";
        HTML += "   <a href=\"javascript:WWHFrame.WWHControls.fSyncTOC();\">";
        HTML += "<img name=\"WWHSyncIcon\" alt=\"" + WWHFrame.WWHHelp.mMessages.mSyncIconLabel + "\" border=\"0\" src=\"../images/syncx.gif\" width=\"23\" height=\"21\">";
        HTML += "</a>";
        HTML += "  </td>\n";
      }
    
      if (Settings.mbPrevEnabled)
      {
    ...
  2. Edit the WWHControls_UpdateHREF function as follows (other lines shown for context):

    ...
      if (this.fSansNavigation())
      {
        ;  // Nothing to do
      }
      else if (!WWHJavaScript && Settings.mbSyncContentsEnabled)
      { // Only need to update the Sync TOC button when in Java mode.
        if (this.mSyncPrevNext[0] != null)
        {
          IconURL =  Prefix + "wwhelp/wwhimpl/common/images/sync.gif";
        }
        else
        {
          IconURL = Prefix + "wwhelp/wwhimpl/common/images/syncx.gif";
        }
        ControlsDocument.images["WWHSyncIcon"].src = IconURL;
      }
    
      // Set Previous Icon
      //
    ...


© 2003 The Doc Side™. All Rights Reserved.