home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 June / PCpro_2006_06.ISO / files / mstools / journalviewer_setup.exe / Microsoft Windows Journal Viewer.msi / Data1.cab / JntView.chm / popup.htc < prev   
Encoding:
Text File  |  2002-10-31  |  6.5 KB  |  229 lines

  1. <PUBLIC:COMPONENT URN="urn:msdn-microsoft-com:workshop" >
  2.   
  3.   <PUBLIC:ATTACH   EVENT="ondocumentready" HANDLER="DoInit" />
  4.  
  5.    <SCRIPT LANGUAGE="JScript">
  6.  
  7. var oPopup;
  8. var oPopupDoc;
  9. var dtText, ddText;
  10. var termFound;
  11. var xmlDoc;
  12. var TabletPopupHref;
  13. var OrgHref;
  14. var sVer;
  15.  
  16. //*****************************Start Localizable Strings**********************************  <PUBLIC:ATTACH   EVENT="onclick" HANDLER="onClickTriage" />
  17. //***************************************************************************************
  18.  
  19. var bodyFontFamily = "Verdana";
  20. var bodyFontSize  = "8pt";
  21. var bodyPadding  = "8pt";
  22. var bodyBorder  = "1px solid #000000";
  23. var bodyBackground  = "#ffffd0";
  24. var strError = "No definition available.";
  25.  
  26.  
  27. //*****************************End Localizable Strings**********************************
  28. //***************************************************************************************
  29.  
  30.  
  31.  
  32.  
  33. //Load the popup and initialize the popup when page is loaded
  34. function DoInit()
  35. {
  36.   if (navigator.appName == "Microsoft Internet Explorer") {
  37.         sVer = navigator.appVersion;
  38.         var MSPos = sVer.indexOf("MSIE");
  39.         var PeriodPos = sVer.indexOf(".", MSPos);
  40.         sVer = sVer.substring(MSPos + (PeriodPos - (MSPos+1)), PeriodPos);
  41.         
  42.         if (sVer < 6)
  43.         {
  44.           attachEvent ('onclick', killPopups);
  45.           RemoveATags();
  46.           }
  47.         else
  48.         {
  49.            attachEvent ('onclick', onClickTriage);
  50.            oPopup = window.createPopup();
  51.            loadPopup();
  52.         }
  53.   
  54.       }
  55.       
  56.  
  57. }
  58.  
  59. function killPopups()
  60. {
  61.    if (event.srcElement.id.toLowerCase() == "tabletpopup")
  62.    {
  63.       window.event.returnValue = false;
  64.   }
  65.   //this is if the element was a <b> tag in an anchor.
  66.   else if (event.srcElement.parentElement.id.toLowerCase() == "tabletpopup")
  67.     {
  68.       window.event.returnValue = false;
  69.   }
  70. }
  71.  
  72. function RemoveATags()
  73. {
  74.  
  75.   var aTags = bodyID.all.tags("A");
  76.   for (i = 0; i < aTags.length; i++)
  77.   {
  78.     if (aTags[i].id.toLowerCase() == "tabletpopup")
  79.     {
  80.       aTags[i].style.color = "#000000";
  81.       aTags[i].style.textDecoration = "none";
  82.       aTags[i].style.cursor = "default";
  83.     }
  84.   }
  85. }
  86.  
  87.  
  88.  
  89. //*****************************glossary popup functions**********************************
  90. //***************************************************************************************
  91. function loadPopup()
  92. {
  93.   //load up the glossary xml file
  94.   //format the hrefs  so they don't link to another page
  95.   var aTags;
  96.   var strHref, strNewLoc;
  97.   var locPos;
  98.   
  99.   //special case check for tab_hb or tabsys because of different folder structures
  100.   strHref = window.location.href;
  101.   locPos = strHref.toLowerCase().indexOf("source/");
  102.   strNewLoc = strHref.substr(0,locPos);
  103.  
  104.  
  105.   xmlDoc = new ActiveXObject ("MSXML.DOMDocument");
  106.   xmlDoc.async = false;
  107.   xmlDoc.load (strNewLoc + "euglossary.xml");
  108.   ShowContents();
  109.  
  110. }
  111.  
  112. //This just formats and sets up the popup body
  113. function ShowContents()
  114. {
  115.  oPopup.document.body.style.fontFamily = bodyFontFamily;
  116.  oPopup.document.body.style.fontSize = bodyFontSize;
  117.  oPopup.document.body.style.padding = bodyPadding;
  118.  oPopup.document.body.style.border = bodyBorder;
  119.  oPopup.document.body.style.background = bodyBackground;
  120.  
  121. }
  122.  
  123. //load in the term and then search the glossary for it, if not found then 
  124. // error out if not found
  125. function showPop(srcTag)
  126. {
  127.   //this is the main function that displays the popup.
  128.   //first we will do a check on the source word for an id for the popup,
  129.   //if that comes up with a match then we are good, 
  130.   //if we don't have a term then show some sort of error text
  131.   var srcTagText, orgSrcText;
  132.   var PopupString;
  133.   var HrefPos;
  134.   srcTagText = Trim(srcTag.innerText);
  135.   orgSrcText = srcTagText;
  136.   oPopupDoc = oPopup.document.body;
  137.   oPopupDoc.innerHTML = " ";
  138.   termFound = false;
  139.   
  140.   HrefPos = TabletPopupHref.indexOf("topic=");
  141.   TabletPopupHref = TabletPopupHref.substring(HrefPos + 6);
  142.   srcTagText = TabletPopupHref;
  143.  
  144.   dtText = orgSrcText;
  145.   CheckforTerm(srcTagText); 
  146.   
  147.  
  148.   //finally if term not found at all, show error text.
  149.   if (termFound == false)
  150.   {
  151.      ddText = strError;
  152.   }
  153.    
  154.   //create the text to insert into the popup
  155.   PopupString = "<p><b>" + dtText + "</b>";
  156.   PopupString += "<br>" + ddText + "</p>";
  157.   oPopupDoc.innerHTML = PopupString;
  158.   
  159.   oPopup.show(0, 0, 400, 8, srcTag);    // Show the popup at an arbitrary size.
  160.   var textSize = oPopupDoc.createTextRange();
  161.   var wPop = textSize.boundingWidth + oPopupDoc.offsetWidth - oPopupDoc.clientWidth;    // Get the size of the text.
  162.   var hPop = oPopupDoc.scrollHeight;
  163.   oPopup.hide();
  164.   
  165.   oPopup.show(0,16,wPop,hPop + 13, srcTag);
  166.   
  167.   
  168. }
  169.  
  170. function CheckforTerm(searchTerm)
  171. {
  172.    //this checks the xml file to find the term
  173.    
  174.    var entryNode, termNode, defNode;
  175.    
  176.    //Look for the passed id and find the entry with that id
  177.    entryNode = xmlDoc.selectSingleNode("//entry[./@id = '" + searchTerm.toLowerCase() +"']");
  178.    if (entryNode != null)
  179.    {
  180.      
  181.      // termNode = entryNode.selectSingleNode("./term"); //if we want to use the Term in the glossary to display in the popup
  182.      // dtText = termNode.text; 
  183.      defNode = entryNode.selectSingleNode("./definition");
  184.      ddText = defNode.text;
  185.      termFound = true;
  186.    }
  187.  
  188. }
  189.  
  190. function onClickTriage()
  191. {
  192.   //this just checks to see if the element clicked on was a popup term
  193.   //Then set the class, get the href (for the id), and set a fake href
  194.   //then call the popup function
  195.    
  196.   if (event.srcElement.id.toLowerCase() == "tabletpopup")
  197.    {
  198.       TabletPopupHref = event.srcElement.href;
  199.       event.srcElement.className = TabletPopupHref;
  200.       OrgHref = TabletPopupHref;
  201.       window.event.returnValue = false;
  202.       showPop(event.srcElement);
  203.   }
  204.   //this is if the element was a <b> tag in an anchor.
  205.   else if (event.srcElement.parentElement.id.toLowerCase() == "tabletpopup")
  206.     {
  207.       var parNode = event.srcElement.parentElement;
  208.       TabletPopupHref = parNode.href;
  209.       parNode.className = TabletPopupHref;
  210.       window.event.returnValue = false;
  211.       showPop(parNode);
  212.   }
  213.  
  214. }
  215.  
  216. function Trim(strString)
  217.   //removes trailing and leading spaces
  218.   var trimmedString;
  219.   trimmedString = strString.replace(/^ */,"");
  220.   trimmedString = trimmedString.replace(/ *$/,"");
  221.   return trimmedString;
  222. }
  223.  
  224. //*****************************END glossary popup functions******************************
  225. //***************************************************************************************
  226.  
  227.    </SCRIPT>
  228. </PUBLIC:COMPONENT>