home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / Office.en-us / OfficeLR.cab / MSQRY32.CHM_0001_1033 / html / ofvbanli.js < prev    next >
Text File  |  2003-06-25  |  5KB  |  168 lines

  1. ∩╗┐// ofvbanli.js
  2. // Purpose: Navigation hyperlink functions for Office VBA Help
  3. // This file contains the functions used by the inline frame.
  4. // Created: 09/01/1999 WadeT
  5. // Change history:
  6. // -Moved functions used by the inline frame into this file to avoid timing issues, 11/2/99 WadeT
  7. // -Added code to use navhidden class if the specifics nav list is empty, 1/26/00 WadeT
  8. // -Added code to gray out example link if there is no example, 06/13/00 Nick
  9.  
  10. // Global variables and constants
  11. var iDefHeight=200;    // Default height and width of hyperlink list popup window
  12. var iDefWidth=250;
  13.  
  14. // Event handlers: Capture various window and document events
  15. document.onreadystatechange=doIt;
  16. document.onclick=window.parent.closeList;
  17. document.onkeypress=handleEnterPressed;
  18.  
  19. // Function: Translate Enter key press to mouse click
  20. function handleEnterPressed() {
  21.     window.event.cancelBubble=true;
  22.     if (window.event.keyCode==13) event.srcElement.click();
  23.     }
  24. // Function: Add nav links text to parent after frame is loaded
  25. function doIt() {
  26.     if (document.readyState=="complete") setTimeout("addNavLinks();",50);
  27.     }
  28. // Function: Enable and disable navigation links
  29. function addNavLinks() {
  30.     var bFound,listcoll;
  31.     var coll=window.parent.document.all.tags("DIV");
  32.  
  33.     // Display the description toggle text
  34. //Uncomment/comment the following 2 lines to enable show/hide descriptions
  35. //    ofVBADescToggle.innerHTML=lookupString("show");
  36. //    ofVBADescToggle.tabIndex=0;
  37.     if (coll.length) {
  38.         // If tags exist, examine all DIVs in the topic
  39.         for (var i=0;i<coll.length;i++) {
  40.             // Process the nav link spans
  41.             if (coll[i].className.toLowerCase()=="ofvbanav") {
  42.                 coll=coll[i].all.tags("SPAN")
  43.                 for (var i2=0;i2<coll.length;i2++) {
  44.                     with (coll[i2]) {
  45.                         // Replace any nav reusable text spans with localized strings
  46.                         if ((className.toLowerCase()=="ofvbanavreuse") && (id!=null)) {
  47.                             innerHTML=lookupString(id.toLowerCase());
  48.                             }
  49.                         if (id.toLowerCase()=="example") {
  50.                             tabIndex=0;
  51.  
  52.                             //check to see if there is an example                            
  53.                             var bExampleExists,exColl;
  54.                             bExampleExists=false;
  55.                             exColl=window.parent.document.all.tags("A");
  56.                             for (var iEx=0;iEx<exColl.length;iEx++) {
  57.                                 if (exColl[iEx].name=="#example") {                                    
  58.                                     bExampleExists=true;                                    
  59.                                     break;
  60.                                     }                                
  61.                                 }                            
  62.                             //if there is no example, gray out the example link
  63.                             if (!bExampleExists) {
  64.                                 className="ofvbanavunused";
  65.                                 tabIndex=-1;
  66.                                 onclick="";
  67.                                 }            
  68.                             }                                
  69.                         else {
  70.                             bFound=false;
  71.                             // If the DIV appears in the link file, show it
  72.                             listcoll=window.document.all.tags("DIV");
  73.                             for (var i3=0;i3<listcoll.length;i3++) {
  74.                                 if (id.toLowerCase()==listcoll[i3].id.toLowerCase()) {
  75.                                     tabIndex=0;
  76.                                     bFound=true;
  77.                                     break;
  78.                                     }
  79.                                 }
  80.                             if (!bFound) {
  81.                                 if (id.toLowerCase()=="specifics") {
  82.                                     // Hide the hyperlink list
  83.                                     className="ofvbanavhidden";
  84.                                     tabIndex=-1;
  85.                                     onclick="";
  86.                                     }
  87.                                 else {
  88.                                     // Grey out the hyperlink list
  89.                                     className="ofvbanavunused";
  90.                                     tabIndex=-1;
  91.                                     onclick="";
  92.                                     }
  93.                                 }
  94.                             }
  95.                         }
  96.                     }
  97.                 // If a nav section was found, exit after processing it
  98.                 break;
  99.                 }
  100.             }
  101.         }
  102.     }
  103. // Function: Lookup the localized string in the string table
  104. function lookupString(sKey) {
  105.     var sRecord,sAltText;
  106.  
  107.     with (document.ofVBANavText) {
  108.         // Set the filter value and get the first record
  109.         Filter="INDEX="+sKey;
  110.         Reset();
  111.         sRecord=recordset; 
  112.         }
  113.     // If data was returned, get the string
  114.     if (!sRecord.EOF) {
  115.         sRecord.moveFirst();
  116.         sAltText=sRecord.fields("TEXT").value;
  117.         }
  118.     else {
  119.         // Otherwise return an empty string
  120.         sAltText="";
  121.         }
  122.     return sAltText;
  123.     }
  124. // Function: Show or hide hyperlink topic descriptions
  125. function toggleDesc(bChk) {
  126.     var sToggleText,iTop;
  127.     var sDispStyle="";
  128.     var iHeight=iDefHeight;
  129.     var coll=document.all.tags("SPAN");
  130.  
  131.     if (coll.length) {
  132.         // If spans exist, prevent events from bubbling up to parent handlers
  133.         window.event.cancelBubble=true;
  134.         // For all descriptive spans, change the display style setting to its opposite value
  135.         for (var i=0;i<coll.length;i++) {
  136.             if (coll[i].className.toLowerCase()=="ofvbadesc") {
  137.                 if (sDispStyle.length==0) {
  138.                     if (coll[i].style.display=="none") {
  139.                         sDispStyle="inline";
  140.                         sToggleText="hide";
  141.                         }
  142.                     else {
  143.                         sDispStyle="none";
  144.                         sToggleText="show";
  145.                         }
  146.                     }
  147.                 coll[i].style.display=sDispStyle;
  148.                 ofVBADescToggle.innerHTML=lookupString(sToggleText);
  149.                 }
  150.             }
  151.         with (window.parent.ofVBAISpan) {
  152.             // Calculate the top left position of the popup window
  153.             style.display="inline";
  154.             // Set the default vertical and horizontal position
  155.             iTop=style.pixelTop;
  156.             // Adjust the vertical position and height for short windows
  157.             if ((offsetHeight>0)&&(offsetHeight<iHeight)) iHeight=offsetHeight;
  158.             }
  159.         with (document.body) {
  160.             if (iTop+iHeight>scrollTop+offsetHeight) iTop=scrollTop+offsetHeight-iHeight-0;
  161.             if (iTop<scrollTop) iTop=scrollTop;
  162.             if (iHeight>offsetHeight) iHeight=offsetHeight-20;
  163.             }
  164.         // Position the popup window
  165.         window.parent.ofVBAISpan.style.pixelHeight=iHeight;
  166.         }
  167.     }
  168.