home *** CD-ROM | disk | FTP | other *** search
/ Thomson (Residential) / TGSTPv7203.iso / mac / Documentation / HTML / TG585n_nl / wwhelp / wwhimpl / common / scripts / related.js < prev    next >
Text File  |  2007-10-04  |  13KB  |  339 lines

  1. // Copyright (c) 2000-2001 Quadralay Corporation.  All rights reserved.
  2. //
  3.  
  4. function  WWHRelatedTopics_Object()
  5. {
  6.   this.mRelatedTopicList = new Array();
  7.   this.mPopup            = new WWHPopup_Object("WWHFrame.WWHRelatedTopics.mPopup",
  8.                                                "WWHFrame.WWHContentFrame.WWHDocumentFrame",
  9.                                                WWHRelatedTopicsPopup_Translate,
  10.                                                WWHRelatedTopicsPopup_Format,
  11.                                                "WWHRelatedTopicsDIV", "WWHRelatedTopicsText", 10, 0, 0,
  12.                                                WWHFrame.WWHHelp.mSettings.mRelatedTopics.mWidth);
  13.  
  14.   this.fClear        = WWHRelatedTopics_Clear;
  15.   this.fAdd          = WWHRelatedTopics_Add;
  16.   this.fHTML         = WWHRelatedTopics_HTML;
  17.   this.fDisplayTopic = WWHRelatedTopics_DisplayTopic;
  18.   this.fUpdate       = WWHRelatedTopics_Update;
  19.   this.fShow         = WWHRelatedTopics_Show;
  20.   this.fShowAtEvent  = WWHRelatedTopics_ShowAtEvent;
  21.   this.fHide         = WWHRelatedTopics_Hide;
  22.   this.fInlineHTML   = WWHRelatedTopics_InlineHTML;
  23. }
  24.  
  25. function  WWHRelatedTopics_Clear()
  26. {
  27.   this.mRelatedTopicList.length = 0;
  28. }
  29.  
  30. function  WWHRelatedTopics_Add(ParamText,
  31.                                ParamContext,
  32.                                ParamFileURL)
  33. {
  34.   this.mRelatedTopicList[this.mRelatedTopicList.length] = new WWHRelatedTopicEntry_Object(ParamText, ParamContext, ParamFileURL);
  35. }
  36.  
  37. function  WWHRelatedTopics_HTML()
  38. {
  39.   var  HTML = new WWHStringBuffer_Object();
  40.   var  Settings = WWHFrame.WWHHelp.mSettings.mRelatedTopics;
  41.   var  MaxIndex;
  42.   var  Index;
  43.   var  ContextBook;
  44.  
  45.  
  46.   for (MaxIndex = this.mRelatedTopicList.length, Index = 0 ; Index < MaxIndex ; Index++)
  47.   {
  48.     ContextBook = WWHFrame.WWHHelp.mBooks.fGetContextBook(this.mRelatedTopicList[Index].mContext);
  49.     if (ContextBook != null)
  50.     {
  51.       HTML.fAppend("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">");
  52.       HTML.fAppend("<tr>");
  53.       HTML.fAppend("<td width=\"17\" valign=\"top\">");
  54.       HTML.fAppend("<a");
  55.       HTML.fAppend(" href=\"javascript:WWHFrame.WWHRelatedTopics.fDisplayTopic(" + Index + ");\">");
  56.       HTML.fAppend("<img border=\"0\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/common/images/doc.gif\" width=\"17\" height=\"17\">");
  57.       HTML.fAppend("</a>");
  58.       HTML.fAppend("</td>");
  59.       HTML.fAppend("<td width=\"100%\" align=\"left\" valign=\"top\">");
  60.       HTML.fAppend("<a");
  61.       HTML.fAppend(" href=\"javascript:WWHFrame.WWHRelatedTopics.fDisplayTopic(" + Index + ");\"");
  62.       HTML.fAppend(" style=\"text-decoration: none ; color: " + Settings.mForegroundColor + " ; " + Settings.mFontStyle + "\">");
  63.       HTML.fAppend(this.mRelatedTopicList[Index].mText);
  64.       HTML.fAppend("</a>");
  65.       HTML.fAppend("</td>");
  66.       HTML.fAppend("</tr>");
  67.       HTML.fAppend("</table>\n");
  68.     }
  69.   }
  70.  
  71.   return HTML.fGetBuffer();
  72. }
  73.  
  74. function  WWHRelatedTopics_DisplayTopic(ParamIndex)
  75. {
  76.   var  ContextBook;
  77.   var  RelatedTopicURL = null;
  78.  
  79.  
  80.   ContextBook = WWHFrame.WWHHelp.mBooks.fGetContextBook(this.mRelatedTopicList[ParamIndex].mContext);
  81.   if (ContextBook != null)
  82.   {
  83.     RelatedTopicURL = WWHFrame.WWHHelp.mBaseURL + ContextBook.mDirectory + this.mRelatedTopicList[ParamIndex].mFileURL;
  84.  
  85.     // Hide popup to prevent JavaScript errors before displaying target document
  86.     //
  87.     this.fHide();
  88.  
  89.     WWHFrame.WWHHelp.fSetDocumentHREF(RelatedTopicURL, false);
  90.   }
  91. }
  92.  
  93. function  WWHRelatedTopics_Update()
  94. {
  95.   // Clear list of topics
  96.   //
  97.   this.fClear();
  98.  
  99.   // Load related topics if defined
  100.   //
  101.   if (typeof WWHFrame.WWHContentFrame.WWHDocumentFrame.WWHDefineRelatedTopics == "function")
  102.   {
  103.     WWHFrame.WWHContentFrame.WWHDocumentFrame.WWHDefineRelatedTopics(this);
  104.   }
  105. }
  106.  
  107. function  WWHRelatedTopicEntry_Object(ParamText,
  108.                                       ParamContext,
  109.                                       ParamFileURL)
  110. {
  111.   this.mText    = ParamText;
  112.   this.mContext = ParamContext;
  113.   this.mFileURL = ParamFileURL;
  114. }
  115.  
  116. function  WWHRelatedTopics_Show()
  117. {
  118.   var  FakeEvent;
  119.  
  120.  
  121.   // Create dummy event to pass to popup show command
  122.   //
  123.   FakeEvent = new WWHRelatedTopicsPopup_FakeEvent_Object();
  124.  
  125.   // Assign coordinates to event base on browser type
  126.   // Place event at far right and allow popup code to handle repositioning for display
  127.   //
  128.   if (WWHFrame.WWHBrowserInfo.mBrowser == 1)  // Shorthand for Netscape 4.x
  129.   {
  130.     FakeEvent.layerX = WWHFrame.WWHContentFrame.WWHDocumentFrame.innerWidth + WWHFrame.WWHContentFrame.WWHDocumentFrame.pageXOffset;
  131.     FakeEvent.layerY = WWHFrame.WWHContentFrame.WWHDocumentFrame.pageYOffset;
  132.   }
  133.   else if (WWHFrame.WWHBrowserInfo.mBrowser == 2)  // Shorthand for IE
  134.   {
  135.     FakeEvent.x = WWHFrame.WWHContentFrame.WWHDocumentFrame.document.body.clientWidth;
  136.     FakeEvent.y = 0;
  137.   }
  138.   else if (WWHFrame.WWHBrowserInfo.mBrowser == 4)  // Shorthand for Netscape 6.x (Mozilla)
  139.   {
  140.     FakeEvent.layerX = WWHFrame.WWHContentFrame.WWHDocumentFrame.innerWidth + WWHFrame.WWHContentFrame.WWHDocumentFrame.pageXOffset;
  141.     FakeEvent.layerY = WWHFrame.WWHContentFrame.WWHDocumentFrame.pageYOffset;
  142.   }
  143.  
  144.   // Show popup
  145.   //
  146.   this.fShowAtEvent(FakeEvent);
  147. }
  148.  
  149. function  WWHRelatedTopics_ShowAtEvent(ParamEvent)
  150. {
  151.   var  RelatedTopicsHTML;
  152.  
  153.  
  154.   // Show popup
  155.   //
  156.   this.fUpdate();
  157.   RelatedTopicsHTML = this.fHTML();
  158.   if (RelatedTopicsHTML.length > 0)
  159.   {
  160.     this.mPopup.fShow(RelatedTopicsHTML, ParamEvent);
  161.   }
  162. }
  163.  
  164. function  WWHRelatedTopics_Hide()
  165. {
  166.   this.mPopup.fHide();
  167. }
  168.  
  169. function  WWHRelatedTopics_InlineHTML()
  170. {
  171.   var  HTML = "";
  172.   var  Settings = WWHFrame.WWHHelp.mSettings.mRelatedTopics;
  173.   var  AnchorAttributes;
  174.   var  ForegroundColor;
  175.   var  BackgroundColor;  
  176.   var  BorderColor;
  177.   var  ImageDir;
  178.   var  FontFamily = "";
  179.   var  FontSize;
  180.  
  181.  
  182.   if (Settings.mbInlineEnabled)
  183.   {
  184.     AnchorAttributes = "href=\"javascript:WWHShowRelatedTopicsHREF();\"";
  185.     AnchorAttributes += " onClick=\"WWHShowRelatedTopicsPopup((document.all||document.getElementById||document.layers)?event:null);\"";
  186.  
  187.     ForegroundColor = Settings.mInlineForegroundColor;
  188.     BackgroundColor = Settings.mInlineBackgroundColor;  
  189.     BorderColor     = Settings.mInlineBorderColor;
  190.     ImageDir        = WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/common/images";
  191.  
  192.     // Determine font family if running Netscape 4.x
  193.     // Required due to errors processing style attributes
  194.     //
  195.     if (WWHFrame.WWHBrowserInfo.mBrowser == 1)  // Shorthand for Netscape 4.x
  196.     {
  197.       FontFamily = WWHStringUtilities_ExtractStyleAttribute("font-family", Settings.mInlineFontStyle);
  198.       FontSize   = WWHStringUtilities_ExtractStyleAttribute("font-size", Settings.mInlineFontStyle);
  199.     }
  200.  
  201.     HTML += "<div class=\"WWHInlineRelatedTopics\">";
  202.     HTML += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  203.     HTML += "<tr>";
  204.     HTML += "<td valign=\"bottom\">";
  205.     HTML += "<nobr>";
  206.     if (FontFamily.length > 0)
  207.     {
  208.       HTML += "<font face=\"" + FontFamily + "\" point-size=\"" + FontSize + "\" color=\"" + ForegroundColor + "\">";
  209.     }
  210.     HTML += "<a";
  211.     if (FontFamily.length == 0)
  212.     {
  213.       HTML += " style=\"text-decoration: none ; color: " + ForegroundColor + " ; " + Settings.mInlineFontStyle + "\"";
  214.     }
  215.     HTML += " " + AnchorAttributes + ">";
  216.     HTML += WWHFrame.WWHHelp.mMessages.mRelatedTopicsIconLabel;
  217.     HTML += "</a>";
  218.     HTML += " ";
  219.     if (FontFamily.length > 0)
  220.     {
  221.       HTML += "</font>";
  222.     }
  223.     HTML += "</nobr>";
  224.     HTML += "</td>";
  225.     HTML += "<td valign=\"bottom\">";
  226.     HTML += "<a " + AnchorAttributes + ">";
  227.     HTML += "<img border=\"0\" src=\"" + ImageDir + "/relatedi.gif\">";
  228.     HTML += "</a>";
  229.     HTML += "</td>";
  230.     HTML += "</tr>";
  231.     HTML += "</table>";
  232.     HTML += "</div>";
  233.   }
  234.  
  235.   return HTML;
  236. }
  237.  
  238. function  WWHRelatedTopicsPopup_FakeEvent_Object()
  239. {
  240. }
  241.  
  242. function  WWHRelatedTopicsPopup_Translate(ParamText)
  243. {
  244.   return ParamText;
  245. }
  246.  
  247. function  WWHRelatedTopicsPopup_Format(ParamWidth,
  248.                                        ParamTextID,
  249.                                        ParamText)
  250. {
  251.   var  FormattedText        = "";
  252.   var  Settings             = WWHFrame.WWHHelp.mSettings.mRelatedTopics;
  253.   var  ImageDir             = WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/common/images";
  254.   var  BackgroundColor      = Settings.mBackgroundColor;
  255.   var  BorderColor          = Settings.mBorderColor;
  256.   var  TitleForegroundColor = Settings.mTitleForegroundColor;
  257.   var  TitleBackgroundColor = Settings.mTitleBackgroundColor;
  258.   var  ReqSpacer1w2h        = "<img src=\"" + ImageDir + "/spc1w2h.gif\" width=1 height=2>";
  259.   var  ReqSpacer2w1h        = "<img src=\"" + ImageDir + "/spc2w1h.gif\" width=2 height=1>";
  260.   var  ReqSpacer4w4h        = "<img src=\"" + ImageDir + "/spacer4.gif\" width=4 height=4>";
  261.   var  Spacer1w2h           = ReqSpacer1w2h;
  262.   var  Spacer2w1h           = ReqSpacer2w1h;
  263.   var  Spacer4w4h           = ReqSpacer4w4h;
  264.  
  265.  
  266.   // Netscape 6.x (Mozilla) renders table cells with graphics
  267.   // incorrectly inside of <div> tags that are rewritten on the fly
  268.   //
  269.   if (WWHFrame.WWHBrowserInfo.mBrowser == 4)  // Shorthand for Netscape 6.x (Mozilla)
  270.   {
  271.     Spacer1w2h = "";
  272.     Spacer2w1h = "";
  273.     Spacer4w4h = "";
  274.   }
  275.  
  276.   FormattedText += "<table width=\"" + ParamWidth + "\" border=0 cellspacing=0 cellpadding=0 bgcolor=\"" + BackgroundColor + "\">";
  277.   FormattedText += " <tr>";
  278.   FormattedText += "  <td height=2 colspan=6 bgcolor=\"" + BorderColor + "\">" + Spacer1w2h + "</td>";
  279.   FormattedText += " </tr>";
  280.  
  281.   FormattedText += " <tr>";
  282.   FormattedText += "  <td height=4 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  283.   FormattedText += "  <td height=4 colspan=4>" + Spacer4w4h + "</td>";
  284.   FormattedText += "  <td height=4 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  285.   FormattedText += " </tr>";
  286.  
  287.   FormattedText += " <tr>";
  288.   FormattedText += "  <td height=4 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  289.   FormattedText += "  <td height=4>" + Spacer4w4h + "</td>";
  290.   FormattedText += "  <td height=4 colspan=2 bgcolor=\"" + TitleBackgroundColor + "\">" + Spacer4w4h + "</td>";
  291.   FormattedText += "  <td height=4>" + Spacer4w4h + "</td>";
  292.   FormattedText += "  <td height=4 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  293.   FormattedText += " </tr>";
  294.  
  295.   FormattedText += " <tr>";
  296.   FormattedText += "  <td bgcolor=\"" + BorderColor + "\">" + ReqSpacer2w1h + "</td>";
  297.   FormattedText += "  <td>" + ReqSpacer4w4h + "</td>";
  298.   FormattedText += "  <td bgcolor=\"" + TitleBackgroundColor + "\" width=\"100%\" align=\"left\" valign=\"middle\"><nobr><span style=\"" + Settings.mTitleFontStyle + " ; color: " + TitleForegroundColor + "\">" + ReqSpacer4w4h + "" + WWHFrame.WWHHelp.mMessages.mRelatedTopicsIconLabel + "</span></nobr></td>";
  299.   FormattedText += "  <td bgcolor=\"" + TitleBackgroundColor + "\" width=\"16\" align=\"right\" valign=\"middle\"><nobr><a href=\"javascript:WWHFrame.WWHRelatedTopics.fHide();\"><img src=\"" + ImageDir + "/close.gif\" border=0 width=16 height=15></a>" + ReqSpacer4w4h + "</nobr></td>";
  300.   FormattedText += "  <td>" + ReqSpacer4w4h + "</td>";
  301.   FormattedText += "  <td bgcolor=\"" + BorderColor + "\">" + ReqSpacer2w1h + "</td>";
  302.   FormattedText += " </tr>";
  303.  
  304.   FormattedText += " <tr>";
  305.   FormattedText += "  <td height=4 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  306.   FormattedText += "  <td height=4>" + Spacer4w4h + "</td>";
  307.   FormattedText += "  <td height=4 colspan=2 bgcolor=\"" + TitleBackgroundColor + "\">" + Spacer4w4h + "</td>";
  308.   FormattedText += "  <td height=4>" + Spacer4w4h + "</td>";
  309.   FormattedText += "  <td height=4 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  310.   FormattedText += " </tr>";
  311.  
  312.   FormattedText += " <tr>";
  313.   FormattedText += "  <td height=4 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  314.   FormattedText += "  <td height=4 colspan=4>" + Spacer4w4h + "</td>";
  315.   FormattedText += "  <td height=4 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  316.   FormattedText += " </tr>";
  317.  
  318.   FormattedText += " <tr>";
  319.   FormattedText += "  <td bgcolor=\"" + BorderColor + "\">" + ReqSpacer2w1h + "</td>";
  320.   FormattedText += "  <td>" + ReqSpacer4w4h + "</td>";
  321.   FormattedText += "  <td colspan=2 width=\"100%\" id=\"" + ParamTextID + "\">" + ParamText + "</td>";
  322.   FormattedText += "  <td>" + ReqSpacer4w4h + "</td>";
  323.   FormattedText += "  <td bgcolor=\"" + BorderColor + "\">" + ReqSpacer2w1h + "</td>";
  324.   FormattedText += " </tr>";
  325.  
  326.   FormattedText += " <tr>";
  327.   FormattedText += "  <td height=4 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  328.   FormattedText += "  <td height=4 colspan=4>" + Spacer4w4h + "</td>";
  329.   FormattedText += "  <td height=4 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  330.   FormattedText += " </tr>";
  331.  
  332.   FormattedText += " <tr>";
  333.   FormattedText += "  <td height=2 colspan=6 bgcolor=\"" + BorderColor + "\">" + Spacer1w2h + "</td>";
  334.   FormattedText += " </tr>";
  335.   FormattedText += "</table>";
  336.  
  337.   return FormattedText;
  338. }
  339.