home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 August / 08_02.iso / software / cb5 / files / Bryce5TrialVersion.exe / data1.cab / HelpFiles / wwhelp / js / scripts / tabsf.js < prev    next >
Encoding:
JavaScript  |  2001-07-16  |  5.6 KB  |  148 lines

  1. function  Tabs_Object(ParamWWHelp)
  2. {
  3.   this.mWWHelp = ParamWWHelp;
  4.  
  5.   this.mMessageKeys = new Array("Tabs TOC", "Tabs Index", "Tabs Search", "Tabs Favorites");
  6.   this.mXYPosition  = new Array(new Array(0,0), new Array(0,0), new Array(0,0), new Array(0,0));
  7.   this.mCurrentTab  = -1;
  8.  
  9.   this.fChangeTab        = Tabs_ChangeTab;
  10.   this.fUpdateXYPosition = Tabs_UpdateXYPosition;
  11.   this.fGenerateStyles   = Tabs_GenerateStyles;
  12.   this.fDisplayTabs      = Tabs_DisplayTabs;
  13. }
  14.  
  15. function  Tabs_ChangeTab(ParamTabIndex)
  16. {
  17.   this.fUpdateXYPosition();
  18.  
  19.   this.mCurrentTab = ParamTabIndex;
  20.  
  21.   WWHelpTopFrame.WWHNavigation.WWHTabs.location.href = this.mWWHelp.mBaseURL + "wwhelp/js/html/tabs.htm";
  22.   WWHelpTopFrame.WWHNavigation.WWHSync.location.href = this.mWWHelp.mBaseURL + "wwhelp/js/html/sync.htm";
  23. }
  24.  
  25. function  Tabs_UpdateXYPosition()
  26. {
  27.   if (this.mWWHelp.mBrowser == 1)  // Shorthand for Netscape
  28.   {
  29.     this.mXYPosition[this.mCurrentTab][0] = WWHelpTopFrame.WWHNavigation.WWHSync.window.pageXOffset;
  30.     this.mXYPosition[this.mCurrentTab][1] = WWHelpTopFrame.WWHNavigation.WWHSync.window.pageYOffset;
  31.   }
  32.   else if (this.mWWHelp.mBrowser == 2)  // Shorthand for IE
  33.   {
  34.     this.mXYPosition[this.mCurrentTab][0] = WWHelpTopFrame.WWHNavigation.WWHSync.document.body.scrollLeft;
  35.     this.mXYPosition[this.mCurrentTab][1] = WWHelpTopFrame.WWHNavigation.WWHSync.document.body.scrollTop;
  36.   }
  37. }
  38.  
  39. function  Tabs_GenerateStyles()
  40. {
  41.   // Generate style section
  42.   //
  43.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("<style type=\"text/css\">");
  44.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln(" <!--");
  45.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("  a  { text-decoration: none ;");
  46.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("       color: " + this.mWWHelp.mMessages["Tabs Default Text Color"] + " }");
  47.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("  th { color: " + this.mWWHelp.mMessages["Tabs Selected Text Color"] + " ;");
  48.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("       font-family: " + this.mWWHelp.mMessages["Font Family"] + " ;");
  49.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("       font-size: " + this.mWWHelp.mMessages["Font Size"] + " }");
  50.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("  td { color: " + this.mWWHelp.mMessages["Tabs Default Text Color"] + " ;");
  51.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("       font-family: " + this.mWWHelp.mMessages["Font Family"] + " ;");
  52.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("       font-size: " + this.mWWHelp.mMessages["Font Size"] + " }");
  53.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln(" -->");
  54.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("</style>");
  55. }
  56.  
  57. function  Tabs_DisplayTabs()
  58. {
  59.   var  NumDisplayedTabs;
  60.   var  MaxIndex;
  61.   var  Index;
  62.   var  Height = 24;
  63.   var  Width  = 80;
  64.   var  CellType;
  65.   var  BackgoundColor;
  66.   var  WrapPrefix;
  67.   var  WrapSuffix;
  68.   var  OnClick;
  69.   var  bInitDisplay = false;
  70.  
  71.  
  72.   // Calculate width based on number of displayed tabs
  73.   //
  74.   NumDisplayedTabs = 0;
  75.   for (MaxIndex = this.mMessageKeys.length, Index = 0 ; Index < MaxIndex ; Index++)
  76.   {
  77.     if (this.mWWHelp.mMessages[this.mMessageKeys[Index]].length > 0)
  78.     {
  79.       NumDisplayedTabs++;
  80.     }
  81.   }
  82.  
  83.   if (NumDisplayedTabs < 0)
  84.   {
  85.     NumDisplayedTabs = 1;
  86.   }
  87.  
  88.   Width = "\"" + 100/NumDisplayedTabs + "%\"";
  89.  
  90.   // Setup table for tab display
  91.   //
  92.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("<table border=0 cellspacing=2 cellpadding=0 width=\"100%\">");
  93.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("<tr>");
  94.  
  95.   for (MaxIndex = this.mMessageKeys.length, Index = 0 ; Index < MaxIndex ; Index++)
  96.   {
  97.     // Only display tabs with display names
  98.     //
  99.     if (this.mWWHelp.mMessages[this.mMessageKeys[Index]])
  100.     {
  101.       // Initialize mCurrentTab (only occurs on initial load)
  102.       //
  103.       if (this.mCurrentTab == -1)
  104.       {
  105.         // Update tab area and sync area as well
  106.         //
  107.         this.mCurrentTab = Index;
  108.         bInitDisplay = true;
  109.       }
  110.  
  111.       // Display anchor only if not selected
  112.       //
  113.       if (Index == this.mCurrentTab)
  114.       {
  115.         CellType = "th";
  116.         BackgroundColor = this.mWWHelp.mMessages["Tabs Selected Tab Color"];
  117.         WrapPrefix = "<b>";
  118.         WrapSuffix = "</b>";
  119.         OnClick = "";
  120.       }
  121.       else
  122.       {
  123.         CellType = "td";
  124.         BackgroundColor = this.mWWHelp.mMessages["Tabs Default Tab Color"];
  125.         WrapPrefix = "<b><a href=\"javascript:WWHelpTopFrame.WWHelp.mTabs.fChangeTab(" + Index + ");\">";
  126.         WrapSuffix = "</a></b>";
  127.         OnClick = " onClick=\"WWHelpTopFrame.WWHelp.mTabs.fChangeTab(" + Index + ");\"";
  128.       }
  129.  
  130.       WWHelpTopFrame.WWHNavigation.WWHTabs.document.write("<" + CellType + " nowrap align=center height=" + Height + " width=" + Width + " bgcolor=\"" + BackgroundColor + "\"" + OnClick + ">");
  131.       WWHelpTopFrame.WWHNavigation.WWHTabs.document.write(WrapPrefix);
  132.       WWHelpTopFrame.WWHNavigation.WWHTabs.document.write(this.mWWHelp.mMessages[this.mMessageKeys[Index]]);
  133.       WWHelpTopFrame.WWHNavigation.WWHTabs.document.write(WrapSuffix);
  134.       WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("</" + CellType + ">");
  135.     }
  136.   }
  137.  
  138.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("</tr>");
  139.   WWHelpTopFrame.WWHNavigation.WWHTabs.document.writeln("</table>");
  140.  
  141.   // Initialize display by calling change tab (only occurs on initial load)
  142.   //
  143.   if (bInitDisplay)
  144.   {
  145.     setTimeout("WWHelpTopFrame.WWHelp.mTabs.fChangeTab(" + this.mCurrentTab + ");", 100);
  146.   }
  147. }
  148.