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

  1. function  Popup_Object(ParamThisAccessor,
  2.                        ParamDocReferenceAsString,
  3.                        ParamPopupTranslateFunc,
  4.                        ParamPopupFormatFunc,
  5.                        ParamDivID,
  6.                        ParamTextID,
  7.                        ParamTimeout,
  8.                        ParamOffsetX,
  9.                        ParamOffsetY,
  10.                        ParamWidth)
  11. {
  12.   var  Agent;
  13.  
  14.  
  15.   this.mThisAccessor = ParamThisAccessor;
  16.   this.mDocRefString = ParamDocReferenceAsString;
  17.   this.mDocReference = null;
  18.   this.mDivID        = ParamDivID;
  19.   this.mTextID       = ParamTextID;
  20.   this.mTimeout      = (ParamTimeout > 0) ? ParamTimeout : 0;
  21.   this.mOffsetX      = ParamOffsetX;
  22.   this.mOffsetY      = ParamOffsetY;
  23.   this.mWidth        = ParamWidth;
  24.   this.mbIE40        = false;
  25.  
  26.   // Determine if this is IE 4.0
  27.   //
  28.   Agent = navigator.userAgent.toLowerCase();
  29.   if (Agent.indexOf("msie") != -1)
  30.   {
  31.     var  VersionString;
  32.     var  MSIEVersionString;
  33.     var  Version;
  34.  
  35.  
  36.     VersionString = navigator.appVersion.toLowerCase();
  37.     MSIEVersionString = VersionString.substring(VersionString.indexOf("msie") + 4);
  38.     Version = parseFloat(MSIEVersionString);
  39.     if ((Version >= 4.0) &&
  40.         (Version < 4.1))
  41.     {
  42.       this.mbIE40 = true;
  43.     }
  44.   }
  45.  
  46.   // Updated when popup triggered
  47.   //
  48.   this.mbVisible  = false;
  49.   this.mPositionX = 0;
  50.   this.mPositionY = 0;
  51.   this.mText      = "";
  52.  
  53.   this.fTranslate = ParamPopupTranslateFunc;
  54.   this.fFormat    = ParamPopupFormatFunc;
  55.   this.fShow      = Popup_Show;
  56.   this.fPopup     = Popup_Popup;
  57.   this.fHide      = Popup_Hide;
  58. }
  59.  
  60. function  Popup_Show(ParamText,
  61.                      ParamEvent)
  62. {
  63.   // Reset the timeout operation to display the popup
  64.   //
  65.   if (this.mSetTimeoutID != null)
  66.   {
  67.     clearTimeout(this.mSetTimeoutID);
  68.  
  69.     this.mSetTimeoutID = null;
  70.   }
  71.  
  72.   // Check to see if there is anything to display
  73.   //
  74.   if ((ParamText != null) &&
  75.       (ParamEvent != null))
  76.   {
  77.     var  bStartTimer = false;
  78.  
  79.  
  80.     // Need to update our reference everytime
  81.     // in case document gets rewritten via JavaScript
  82.     //
  83.     this.mDocReference = eval(this.mDocRefString);
  84.  
  85.     if (this.mDocReference.layers != null)
  86.     {
  87.       this.mPositionX = ParamEvent.layerX;
  88.       this.mPositionY = ParamEvent.layerY;
  89.  
  90.       this.mText = ParamText;
  91.  
  92.       bStartTimer = true;
  93.     }
  94.     else if (this.mDocReference.all != null)
  95.     {
  96.       this.mPositionX = this.mDocReference.body.scrollLeft + ParamEvent.x;
  97.       this.mPositionY = this.mDocReference.body.scrollTop  + ParamEvent.y;
  98.  
  99.       // Workaround for IE 4.0 on Windows
  100.       //
  101.       if (this.mbIE40)
  102.       {
  103.         this.mPositionX = ParamEvent.x;
  104.         this.mPositionY = ParamEvent.y;
  105.       }
  106.  
  107.       this.mText = ParamText;
  108.  
  109.       // Setting the position here before it is displayed
  110.       // corrects a bug under IE 5 on the Macintosh
  111.       //
  112.       this.mDocReference.all[this.mDivID].style.pixelLeft = this.mPositionX + this.mOffsetX;
  113.       this.mDocReference.all[this.mDivID].style.pixelTop  = this.mPositionY + this.mOffsetY;
  114.  
  115.       bStartTimer = true;
  116.     }
  117.  
  118.     if (bStartTimer == true)
  119.     {
  120.       this.mSetTimeoutID = setTimeout(this.mThisAccessor + ".fPopup()", this.mTimeout);
  121.     }
  122.   }
  123. }
  124.  
  125. function  Popup_Popup()
  126. {
  127.   if (this.mSetTimeoutID != null)
  128.   {
  129.     if (this.mDocReference.layers != null)
  130.     {
  131.       var  FormattedText;
  132.  
  133.  
  134.       FormattedText = this.fFormat(this.fTranslate(this.mText));
  135.  
  136.       this.mDocReference.layers[this.mDivID].document.open();
  137.       this.mDocReference.layers[this.mDivID].document.write(FormattedText);
  138.       this.mDocReference.layers[this.mDivID].document.close();
  139.  
  140.       // Position the popup
  141.       //
  142.       this.mDocReference.layers[this.mDivID].left = this.mPositionX + this.mOffsetX;
  143.       this.mDocReference.layers[this.mDivID].top  = this.mPositionY + this.mOffsetY;
  144.  
  145.       // Show the popup
  146.       //
  147.       this.mDocReference.layers[this.mDivID].visibility = "visible";
  148.  
  149.       this.mbVisible = true;
  150.     }
  151.     else if (this.mDocReference.all != null)
  152.     {
  153.       var  TranslatedText;
  154.  
  155.  
  156.       TranslatedText = this.fTranslate(this.mText);
  157.  
  158.       this.mDocReference.all[this.mTextID].innerHTML = TranslatedText;
  159.  
  160.       this.mDocReference.all[this.mDivID].style.pixelLeft = this.mPositionX + this.mOffsetX;
  161.       this.mDocReference.all[this.mDivID].style.pixelTop  = this.mPositionY + this.mOffsetY;
  162.  
  163.       this.mDocReference.all[this.mDivID].style.visibility = "visible";
  164.  
  165.       this.mbVisible = true;
  166.     }
  167.   }
  168.  
  169.   // Clear the setTimeout ID tracking field
  170.   // to indicate that we're done.
  171.   //
  172.   this.mSetTimeoutID = null;
  173. }
  174.  
  175. function  Popup_Hide()
  176. {
  177.   // Cancel the setTimeout value that would have
  178.   // displayed the popup
  179.   //
  180.   if (this.mSetTimeoutID != null)
  181.   {
  182.     clearTimeout(this.mSetTimeoutID);
  183.  
  184.     this.mSetTimeoutID = null;
  185.   }
  186.  
  187.   // Shutdown the popup
  188.   //
  189.   if (this.mbVisible == true)
  190.   {
  191.     if (this.mDocReference.layers != null)
  192.     {
  193.       this.mDocReference.layers[this.mDivID].visibility = "hidden";
  194.     }
  195.     else if (this.mDocReference.all != null)
  196.     {
  197.       this.mDocReference.all[this.mDivID].style.visibility = "hidden";
  198.     }
  199.   }
  200.  
  201.   this.mbVisible = false;
  202. }
  203.