home *** CD-ROM | disk | FTP | other *** search
/ ftp.novell.com / 2014.06.ftp.novell.com.tar / ftp.novell.com / forge / camtasia.msi / Cabs.w1.cab / CamtasiaTheater.chm1 / scripts / popup.js < prev    next >
Text File  |  2009-08-10  |  10KB  |  307 lines

  1. // Copyright (c) 2002-2003 Quadralay Corporation.  All rights reserved.
  2. //
  3.  
  4. function  HTMLHelpPopup_Object(ParamThisPopupRef,
  5.                                ParamWindowRef,
  6.                                ParamNotifyClickedFunction,
  7.                                ParamDivID,
  8.                                ParamTextID,
  9.                                ParamTimeout,
  10.                                ParamOffsetX,
  11.                                ParamOffsetY,
  12.                                ParamWidth)
  13. {
  14.   this.mThisPopupRef = ParamThisPopupRef;
  15.   this.mWindowRef    = ParamWindowRef;
  16.   this.mDivID        = ParamDivID;
  17.   this.mTextID       = ParamTextID;
  18.   this.mTimeout      = (ParamTimeout > 0) ? ParamTimeout : 0;
  19.   this.mOffsetX      = ParamOffsetX;
  20.   this.mOffsetY      = ParamOffsetY;
  21.   this.mWidth        = ParamWidth;
  22.  
  23.  
  24.   // Updated when popup triggered
  25.   //
  26.   this.mbVisible     = false;
  27.   this.mPositionX    = 0;
  28.   this.mPositionY    = 0;
  29.   this.mText         = "";
  30.   this.mSetTimeoutID = null;
  31.  
  32.   this.fNotifyClicked = ParamNotifyClickedFunction;
  33.   this.fFormat        = HTMLHelpPopup_Format;
  34.   this.fDivTagText    = HTMLHelpPopup_DivTagText;
  35.   this.fShow          = HTMLHelpPopup_Show;
  36.   this.fPositionPopup = HTMLHelpPopup_PositionPopup;
  37.   this.fPopup         = HTMLHelpPopup_Popup;
  38.   this.fHide          = HTMLHelpPopup_Hide;
  39.  
  40.   // Preload graphics
  41.   //
  42.   HTMLHelpPopupUtility_PreloadImages();
  43. }
  44.  
  45. function  HTMLHelpPopupUtility_PreloadImages()
  46. {
  47.   var  VarImage;
  48.  
  49.  
  50.   VarImage = new Image();
  51.   VarImage.src = "images/spc1w2h.gif";
  52.   VarImage.src = "images/spc2w1h.gif";
  53.   VarImage.src = "images/spc1w7h.gif";
  54.   VarImage.src = "images/spc5w1h.gif";
  55. }
  56.  
  57. function  HTMLHelpPopup_Format(ParamWidth,
  58.                                ParamTextID,
  59.                                ParamText)
  60. {
  61.   var  VarHTML   = "";
  62.   var  BackgroundColor = "#FFFFCC";
  63.   var  BorderColor     = "#999999";
  64.   var  ReqSpacer1w2h   = "<img src=\"images/spc1w2h.gif\" width=1 height=2>";
  65.   var  ReqSpacer2w1h   = "<img src=\"images/spc2w1h.gif\" width=2 height=1>";
  66.   var  ReqSpacer1w7h   = "<img src=\"images/spc1w7h.gif\" width=1 height=7>";
  67.   var  ReqSpacer5w1h   = "<img src=\"images/spc5w1h.gif\" width=5 height=1>";
  68.   var  Spacer1w2h      = ReqSpacer1w2h;
  69.   var  Spacer2w1h      = ReqSpacer2w1h;
  70.   var  Spacer1w7h      = ReqSpacer1w7h;
  71.   var  Spacer5w1h      = ReqSpacer5w1h;
  72.  
  73.  
  74.   VarHTML += "<table width=\"" + ParamWidth + "\" border=0 cellspacing=0 cellpadding=0 bgcolor=\"" + BackgroundColor + "\">";
  75.   VarHTML += " <tr>";
  76.   VarHTML += "  <td height=2 colspan=5 bgcolor=\"" + BorderColor + "\">" + Spacer1w2h + "</td>";
  77.   VarHTML += " </tr>";
  78.  
  79.   VarHTML += " <tr>";
  80.   VarHTML += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  81.   VarHTML += "  <td height=7 colspan=3>" + Spacer1w7h + "</td>";
  82.   VarHTML += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  83.   VarHTML += " </tr>";
  84.  
  85.   VarHTML += " <tr>";
  86.   VarHTML += "  <td bgcolor=\"" + BorderColor + "\">" + ReqSpacer2w1h + "</td>";
  87.   VarHTML += "  <td>" + ReqSpacer5w1h + "</td>";
  88.   VarHTML += "  <td width=\"100%\" id=\"" + ParamTextID + "\">" + ParamText + "</td>";
  89.   VarHTML += "  <td>" + ReqSpacer5w1h + "</td>";
  90.   VarHTML += "  <td bgcolor=\"" + BorderColor + "\">" + ReqSpacer2w1h + "</td>";
  91.   VarHTML += " </tr>";
  92.  
  93.   VarHTML += " <tr>";
  94.   VarHTML += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  95.   VarHTML += "  <td height=7 colspan=3>" + Spacer1w7h + "</td>";
  96.   VarHTML += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  97.   VarHTML += " </tr>";
  98.  
  99.   VarHTML += " <tr>";
  100.   VarHTML += "  <td height=2 colspan=5 bgcolor=\"" + BorderColor + "\">" + Spacer1w2h + "</td>";
  101.   VarHTML += " </tr>";
  102.   VarHTML += "</table>";
  103.  
  104.   return VarHTML;
  105. }
  106.  
  107. function  HTMLHelpPopup_DivTagText()
  108. {
  109.   var  VarDivTagText = "";
  110.  
  111.  
  112.   // Emit DIV tag
  113.   //
  114.   VarDivTagText += "<div id=\"" + this.mDivID + "\" style=\"position: absolute ; z-index: 1 ; visibility: hidden ; display: none ; top: 0px ; left: 0px\" onClick=\"javascript:" + this.mThisPopupRef + ".fNotifyClicked();\">\n";
  115.   VarDivTagText += this.fFormat(this.mWidth, this.mTextID, "Popup");
  116.   VarDivTagText += "</div>\n";
  117.  
  118.   return VarDivTagText;
  119. }
  120.  
  121. function  HTMLHelpPopup_Show(ParamText,
  122.                              ParamEvent)
  123. {
  124.   var  VarDocument = eval(this.mWindowRef + ".document");
  125.  
  126.  
  127.   // Reset the timeout operation to display the popup
  128.   //
  129.   if (this.mSetTimeoutID != null)
  130.   {
  131.     clearTimeout(this.mSetTimeoutID);
  132.  
  133.     this.mSetTimeoutID = null;
  134.   }
  135.  
  136.   // Check to see if there is anything to display
  137.   //
  138.   if ((ParamText != null) &&
  139.       (ParamEvent != null))
  140.   {
  141.     if ((typeof(VarDocument.documentElement) != "undefined") &&
  142.         (typeof(VarDocument.documentElement.clientWidth) != "undefined") &&
  143.         (typeof(VarDocument.documentElement.clientHeight) != "undefined") &&
  144.         ((VarDocument.documentElement.scrollLeft != 0) ||
  145.          (VarDocument.documentElement.scrollTop != 0)))
  146.     {
  147.       this.mPositionX = VarDocument.documentElement.scrollLeft + ParamEvent.x;
  148.       this.mPositionY = VarDocument.documentElement.scrollTop  + ParamEvent.y;
  149.     }
  150.     else
  151.     {
  152.       this.mPositionX = VarDocument.body.scrollLeft + ParamEvent.x;
  153.       this.mPositionY = VarDocument.body.scrollTop  + ParamEvent.y;
  154.     }
  155.  
  156.     this.mText = ParamText;
  157.  
  158.     this.mSetTimeoutID = setTimeout(this.mThisPopupRef + ".fPopup()", this.mTimeout);
  159.   }
  160. }
  161.  
  162. function  HTMLHelpPopup_PositionPopup()
  163. {
  164.   var  VarDocument = eval(this.mWindowRef + ".document");
  165.   var  NewPositionX;
  166.   var  NewPositionY;
  167.   var  VisibleOffsetX;
  168.   var  VisibleOffsetY;
  169.   var  PopupWidth;
  170.   var  PopupHeight;
  171.  
  172.  
  173.   // Calculate new position for popup
  174.   //
  175.   NewPositionX = this.mPositionX + this.mOffsetX;
  176.   NewPositionY = this.mPositionY + this.mOffsetY;
  177.  
  178.   // Attempt to determine DIV tag dimensions
  179.   //
  180.   PopupWidth = this.mWidth;
  181.   if (VarDocument.all[this.mDivID].offsetWidth > PopupWidth)
  182.   {
  183.     PopupWidth = VarDocument.all[this.mDivID].offsetWidth;
  184.   }
  185.   PopupHeight = 60;  // Guess a value
  186.   if (VarDocument.all[this.mDivID].offsetHeight > PopupHeight)
  187.   {
  188.     PopupHeight = VarDocument.all[this.mDivID].offsetHeight;
  189.   }
  190.  
  191.   // Calculate maximum values for X and Y such that the
  192.   // popup will remain visible
  193.   //
  194.   if ((typeof(VarDocument.documentElement) != "undefined") &&
  195.       (typeof(VarDocument.documentElement.clientWidth) != "undefined") &&
  196.       (typeof(VarDocument.documentElement.clientHeight) != "undefined") &&
  197.       ((VarDocument.documentElement.clientWidth != 0) ||
  198.        (VarDocument.documentElement.clientHeight != 0)))
  199.   {
  200.     VisibleOffsetX = VarDocument.documentElement.clientWidth  - this.mOffsetX - PopupWidth;
  201.     VisibleOffsetY = VarDocument.documentElement.clientHeight - this.mOffsetY - PopupHeight;
  202.   }
  203.   else
  204.   {
  205.     VisibleOffsetX = VarDocument.body.clientWidth  - this.mOffsetX - PopupWidth;
  206.     VisibleOffsetY = VarDocument.body.clientHeight - this.mOffsetY - PopupHeight;
  207.   }
  208.   if (VisibleOffsetX < 0)
  209.   {
  210.     VisibleOffsetX = 0;
  211.   }
  212.   if (VisibleOffsetY < 0)
  213.   {
  214.     VisibleOffsetY = 0;
  215.   }
  216.  
  217.   // Confirm popup will be visible and adjust if necessary
  218.   //
  219.   if ((typeof(VarDocument.documentElement) != "undefined") &&
  220.       (typeof(VarDocument.documentElement.clientWidth) != "undefined") &&
  221.       (typeof(VarDocument.documentElement.clientHeight) != "undefined") &&
  222.       ((VarDocument.documentElement.scrollLeft != 0) ||
  223.        (VarDocument.documentElement.scrollTop != 0)))
  224.   {
  225.     if (NewPositionX > (VarDocument.documentElement.scrollLeft + VisibleOffsetX))
  226.     {
  227.       NewPositionX = VarDocument.documentElement.scrollLeft + VisibleOffsetX;
  228.     }
  229.     if (NewPositionY > (VarDocument.documentElement.scrollTop + VisibleOffsetY))
  230.     {
  231.       NewPositionY = VarDocument.documentElement.scrollTop + VisibleOffsetY;
  232.     }
  233.   }
  234.   else
  235.   {
  236.     if (NewPositionX > (VarDocument.body.scrollLeft + VisibleOffsetX))
  237.     {
  238.       NewPositionX = VarDocument.body.scrollLeft + VisibleOffsetX;
  239.     }
  240.     if (NewPositionY > (VarDocument.body.scrollTop + VisibleOffsetY))
  241.     {
  242.       NewPositionY = VarDocument.body.scrollTop + VisibleOffsetY;
  243.     }
  244.   }
  245.  
  246.   // Set popup position
  247.   //
  248.   VarDocument.all[this.mDivID].style.pixelLeft = NewPositionX;
  249.   VarDocument.all[this.mDivID].style.pixelTop  = NewPositionY;
  250. }
  251.  
  252. function  HTMLHelpPopup_Popup()
  253. {
  254.   var  VarDocument = eval(this.mWindowRef + ".document");
  255.  
  256.  
  257.   if (this.mSetTimeoutID != null)
  258.   {
  259.     // Set popup contents
  260.     //
  261.     VarDocument.all[this.mTextID].innerHTML = this.mText;
  262.  
  263.     // Position the popup
  264.     //
  265.     VarDocument.all[this.mDivID].style.display = "block";
  266.     this.fPositionPopup();
  267.  
  268.     // Show the popup
  269.     //
  270.     VarDocument.all[this.mDivID].style.visibility = "visible";
  271.     this.mbVisible = true;
  272.   }
  273.  
  274.   // Clear the setTimeout ID tracking field
  275.   // to indicate that we're done.
  276.   //
  277.   this.mSetTimeoutID = null;
  278. }
  279.  
  280. function  HTMLHelpPopup_Hide()
  281. {
  282.   var  VarDocument;
  283.  
  284.  
  285.   // Cancel the setTimeout value that would have
  286.   // displayed the popup
  287.   //
  288.   if (this.mSetTimeoutID != null)
  289.   {
  290.     clearTimeout(this.mSetTimeoutID);
  291.  
  292.     this.mSetTimeoutID = null;
  293.   }
  294.  
  295.   // Shutdown the popup
  296.   //
  297.   if (this.mbVisible == true)
  298.   {
  299.     VarDocument = eval(this.mWindowRef + ".document");
  300.  
  301.     VarDocument.all[this.mDivID].style.visibility = "hidden";
  302.     VarDocument.all[this.mDivID].style.display    = "none";
  303.   }
  304.  
  305.   this.mbVisible = false;
  306. }
  307.