home *** CD-ROM | disk | FTP | other *** search
- <PUBLIC:COMPONENT URN="urn:msdn-microsoft-com:workshop" >
-
- <PUBLIC:ATTACH EVENT="ondocumentready" HANDLER="DoInit" />
-
- <SCRIPT LANGUAGE="JScript">
-
- var oPopup;
- var oPopupDoc;
- var dtText, ddText;
- var termFound;
- var xmlDoc;
- var TabletPopupHref;
- var OrgHref;
- var sVer;
-
- //*****************************Start Localizable Strings********************************** <PUBLIC:ATTACH EVENT="onclick" HANDLER="onClickTriage" />
- //***************************************************************************************
-
- var bodyFontFamily = "Verdana";
- var bodyFontSize = "8pt";
- var bodyPadding = "8pt";
- var bodyBorder = "1px solid #000000";
- var bodyBackground = "#ffffd0";
- var strError = "No definition available.";
-
-
- //*****************************End Localizable Strings**********************************
- //***************************************************************************************
-
-
-
-
- //Load the popup and initialize the popup when page is loaded
- function DoInit()
- {
- if (navigator.appName == "Microsoft Internet Explorer") {
- sVer = navigator.appVersion;
- var MSPos = sVer.indexOf("MSIE");
- var PeriodPos = sVer.indexOf(".", MSPos);
- sVer = sVer.substring(MSPos + (PeriodPos - (MSPos+1)), PeriodPos);
-
- if (sVer < 6)
- {
- attachEvent ('onclick', killPopups);
- RemoveATags();
- }
- else
- {
- attachEvent ('onclick', onClickTriage);
- oPopup = window.createPopup();
- loadPopup();
- }
-
- }
-
-
- }
-
- function killPopups()
- {
- if (event.srcElement.id.toLowerCase() == "tabletpopup")
- {
- window.event.returnValue = false;
- }
- //this is if the element was a <b> tag in an anchor.
- else if (event.srcElement.parentElement.id.toLowerCase() == "tabletpopup")
- {
- window.event.returnValue = false;
- }
- }
-
- function RemoveATags()
- {
-
- var aTags = bodyID.all.tags("A");
- for (i = 0; i < aTags.length; i++)
- {
- if (aTags[i].id.toLowerCase() == "tabletpopup")
- {
- aTags[i].style.color = "#000000";
- aTags[i].style.textDecoration = "none";
- aTags[i].style.cursor = "default";
- }
- }
- }
-
-
-
- //*****************************glossary popup functions**********************************
- //***************************************************************************************
- function loadPopup()
- {
- //load up the glossary xml file
- //format the hrefs so they don't link to another page
- var aTags;
- var strHref, strNewLoc;
- var locPos;
-
- //special case check for tab_hb or tabsys because of different folder structures
- strHref = window.location.href;
- locPos = strHref.toLowerCase().indexOf("source/");
- strNewLoc = strHref.substr(0,locPos);
-
-
- xmlDoc = new ActiveXObject ("MSXML.DOMDocument");
- xmlDoc.async = false;
- xmlDoc.load (strNewLoc + "euglossary.xml");
- ShowContents();
-
- }
-
- //This just formats and sets up the popup body
- function ShowContents()
- {
- oPopup.document.body.style.fontFamily = bodyFontFamily;
- oPopup.document.body.style.fontSize = bodyFontSize;
- oPopup.document.body.style.padding = bodyPadding;
- oPopup.document.body.style.border = bodyBorder;
- oPopup.document.body.style.background = bodyBackground;
-
- }
-
- //load in the term and then search the glossary for it, if not found then
- // error out if not found
- function showPop(srcTag)
- {
- //this is the main function that displays the popup.
- //first we will do a check on the source word for an id for the popup,
- //if that comes up with a match then we are good,
- //if we don't have a term then show some sort of error text
- var srcTagText, orgSrcText;
- var PopupString;
- var HrefPos;
- srcTagText = Trim(srcTag.innerText);
- orgSrcText = srcTagText;
- oPopupDoc = oPopup.document.body;
- oPopupDoc.innerHTML = " ";
- termFound = false;
-
- HrefPos = TabletPopupHref.indexOf("topic=");
- TabletPopupHref = TabletPopupHref.substring(HrefPos + 6);
- srcTagText = TabletPopupHref;
-
- dtText = orgSrcText;
- CheckforTerm(srcTagText);
-
-
- //finally if term not found at all, show error text.
- if (termFound == false)
- {
- ddText = strError;
- }
-
- //create the text to insert into the popup
- PopupString = "<p><b>" + dtText + "</b>";
- PopupString += "<br>" + ddText + "</p>";
- oPopupDoc.innerHTML = PopupString;
-
- oPopup.show(0, 0, 400, 8, srcTag); // Show the popup at an arbitrary size.
- var textSize = oPopupDoc.createTextRange();
- var wPop = textSize.boundingWidth + oPopupDoc.offsetWidth - oPopupDoc.clientWidth; // Get the size of the text.
- var hPop = oPopupDoc.scrollHeight;
- oPopup.hide();
-
- oPopup.show(0,16,wPop,hPop + 13, srcTag);
-
-
- }
-
- function CheckforTerm(searchTerm)
- {
- //this checks the xml file to find the term
-
- var entryNode, termNode, defNode;
-
- //Look for the passed id and find the entry with that id
- entryNode = xmlDoc.selectSingleNode("//entry[./@id = '" + searchTerm.toLowerCase() +"']");
- if (entryNode != null)
- {
-
- // termNode = entryNode.selectSingleNode("./term"); //if we want to use the Term in the glossary to display in the popup
- // dtText = termNode.text;
- defNode = entryNode.selectSingleNode("./definition");
- ddText = defNode.text;
- termFound = true;
- }
-
- }
-
- function onClickTriage()
- {
- //this just checks to see if the element clicked on was a popup term
- //Then set the class, get the href (for the id), and set a fake href
- //then call the popup function
-
- if (event.srcElement.id.toLowerCase() == "tabletpopup")
- {
- TabletPopupHref = event.srcElement.href;
- event.srcElement.className = TabletPopupHref;
- OrgHref = TabletPopupHref;
- window.event.returnValue = false;
- showPop(event.srcElement);
- }
- //this is if the element was a <b> tag in an anchor.
- else if (event.srcElement.parentElement.id.toLowerCase() == "tabletpopup")
- {
- var parNode = event.srcElement.parentElement;
- TabletPopupHref = parNode.href;
- parNode.className = TabletPopupHref;
- window.event.returnValue = false;
- showPop(parNode);
- }
-
- }
-
- function Trim(strString)
- {
- //removes trailing and leading spaces
- var trimmedString;
- trimmedString = strString.replace(/^ */,"");
- trimmedString = trimmedString.replace(/ *$/,"");
- return trimmedString;
- }
-
- //*****************************END glossary popup functions******************************
- //***************************************************************************************
-
- </SCRIPT>
- </PUBLIC:COMPONENT>