home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 November / Chip_2003-11_cd2.bin / ruzne / painter / PAINTE~2.cab / _FF6E88BFCD4A4558A335E9A4A386704F < prev    next >
Text File  |  2003-01-06  |  9KB  |  336 lines

  1. // Copyright (c) 2000-2001 Quadralay Corporation.  All rights reserved.
  2. // 
  3.  
  4. function  WWHelpFrameSet_WWHelp_Object()
  5. {
  6.   this.mBookDirList = new Array();
  7.  
  8.   this.fAddBookDir = WWHelpFrameSet_WWHelp_AddBookDir;
  9. }
  10.  
  11. function  WWHelpFrameSet_WWHelp_AddBookDir(ParamBookDir)
  12. {
  13.   this.mBookDirList.length++;
  14.  
  15.   if (ParamBookDir == ".")
  16.   {
  17.     this.mBookDirList[this.mBookDirList.length - 1] = "";
  18.   }
  19.   else
  20.   {
  21.     this.mBookDirList[this.mBookDirList.length - 1] = escape(ParamBookDir) + "/";
  22.   }
  23. }
  24.  
  25. function  WWHelpFrameSet_Popup_Object()
  26. {
  27. }
  28.  
  29. function  WWHelpFrameSet_PopupBook_Object(ParamBookDir)
  30. {
  31.   this.mBookDir = ParamBookDir;
  32.   this.mPopups  = new WWHelpFrameSet_Popup_Object();
  33. }
  34.  
  35. function  WWHelpFrameSet_Object(ParamDocumentFrame)
  36. {
  37.   var  BrowserDetect = new BrowserDetect_Object();
  38.   var  Parts;
  39.  
  40.  
  41.   this.mBrowser  = BrowserDetect.mBrowser;
  42.   this.mPlatform = BrowserDetect.mPlatform;
  43.  
  44.   this.mBaseURL = location.href.substring(0, location.href.lastIndexOf("/"));
  45.   Parts = this.mBaseURL.split("/wwhelp/java/html");
  46.   if (Parts[0] == this.mBaseURL)
  47.   {
  48.     Parts = this.mBaseURL.split("/wwhelp/js/html");
  49.   }
  50.   this.mBaseURL = Parts[0] + "/";
  51.  
  52.   this.mBookDirList      = null;
  53.   this.mCurrentBookIndex = -1;
  54.   this.mPopups           = new WWHelpFrameSet_Popup_Object();
  55.   this.mBookTag          = null;
  56.   this.mTopicTag         = null;
  57.   this.mContextHREF      = null;
  58.   this.mLinkHREF         = null;
  59.   this.mPopup            = new Popup_Object("WWHelpTopFrame.WWHelpFrameSet.mPopup", ParamDocumentFrame,
  60.                                             WWHelpPopup_PopupTranslate, WWHelpPopup_PopupFormat,
  61.                                             "WWHelpPopupDIV", "WWHelpPopupText", 500, 12, 20, 200);
  62.  
  63.   // Included from "handlers.js"
  64.   //
  65.   this.fUpdateFavorite = WWHelpFrameSet_UpdateFavorite;
  66.   this.fSyncTOC        = WWHelpFrameSet_SyncTOC;
  67.  
  68.   // Functions defined in this file
  69.   //
  70.   this.fExecute               = WWHelpFrameSet_Execute;
  71.   this.fParseHREF             = WWHelpFrameSet_ParseHREF;
  72.   this.fLoadData              = WWHelpFrameSet_LoadData;
  73.   this.fProcessBook           = WWHelpFrameSet_ProcessBook;
  74.   this.fLoadPopups            = WWHelpFrameSet_LoadPopups;
  75.   this.fCheckContext          = WWHelpFrameSet_CheckContext;
  76.   this.fIncrementCurBookIndex = WWHelpFrameSet_IncrementCurBookIndex;
  77.   this.fGetPopup              = WWHelpFrameSet_GetPopup;
  78.   this.fShowPopup             = WWHelpFrameSet_ShowPopup;
  79.   this.fHidePopup             = WWHelpFrameSet_HidePopup;
  80.   this.fClickedPopup          = WWHelpFrameSet_ClickedPopup;
  81. }
  82.  
  83. function  WWHelpFrameSet_Execute(ParamHREF,
  84.                                  ParamBookDirList)
  85. {
  86.   this.mBookDirList = ParamBookDirList;
  87.  
  88.   this.fParseHREF(ParamHREF);
  89.   this.fLoadData();
  90. }
  91.  
  92. function  WWHelpFrameSet_ParseHREF(ParamHREF)
  93. {
  94.   // Reset context tags
  95.   //
  96.   this.mBookTag  = null;
  97.   this.mTopicTag = null;
  98.  
  99.   // Check for possible context specification
  100.   //
  101.   if (ParamHREF.indexOf("?") != -1)
  102.   {
  103.     var  Parts;
  104.     var  ContextMarker = "context=";
  105.     var  TopicMarker   = "topic=";
  106.  
  107.  
  108.     Parts = ParamHREF.split("?");
  109.  
  110.     // Check for our context tags
  111.     //
  112.     if ((Parts[1].indexOf("&") != -1) &&
  113.         (Parts[1].indexOf(ContextMarker) != -1) &&
  114.         (Parts[1].indexOf(TopicMarker) != -1))
  115.     {
  116.       var  MaxIndex;
  117.       var  Index;
  118.  
  119.  
  120.       Parts = Parts[1].split("&");
  121.  
  122.       // Set context and topic, if specified
  123.       //
  124.       for (MaxIndex = Parts.length, Index = 0 ; Index < MaxIndex ; Index++)
  125.       {
  126.         if (Parts[Index].indexOf(ContextMarker) == 0)
  127.         {
  128.           this.mBookTag  = Parts[Index].substring(ContextMarker.length, Parts[Index].length);
  129.         }
  130.         if (Parts[Index].indexOf(TopicMarker) == 0)
  131.         {
  132.           this.mTopicTag = Parts[Index].substring(TopicMarker.length, Parts[Index].length);
  133.         }
  134.       }
  135.  
  136.       // Make certain we have both a BookTag and TopicTag
  137.       // Otherwise, reset them
  138.       //
  139.       if ((this.mBookTag  == null) ||
  140.           (this.mTopicTag == null))
  141.       {
  142.         this.mBookTag  = null;
  143.         this.mTopicTag = null;
  144.       }
  145.     }
  146.   }
  147. }
  148.  
  149. function  WWHelpFrameSet_LoadData()
  150. {
  151.   var  MaxIndex;
  152.   var  Index;
  153.  
  154.  
  155.   this.mContextHREF = null;
  156.  
  157.   this.mCurrentBookIndex = 0;
  158.   for (MaxIndex = this.mBookDirList.length, Index = 0 ; Index < MaxIndex ; Index++)
  159.   {
  160.     document.writeln("<script type=\"text/javascript\" language=\"JavaScript\" src=\"../../../" + this.mBookDirList[Index] + "wwhdata/common/context.js\"></script>");
  161.     document.writeln("<script type=\"text/javascript\" language=\"JavaScript\" src=\"../../../" + this.mBookDirList[Index] + "wwhdata/common/popups.js\"></script>");
  162.  
  163.     if ((this.mBookTag  != null) &&
  164.         (this.mTopicTag != null))
  165.     {
  166.       document.writeln("<script type=\"text/javascript\" language=\"JavaScript\" src=\"../../../" + this.mBookDirList[Index] + "wwhdata/common/topics.js\"></script>");
  167.     }
  168.  
  169.     document.writeln("<script type=\"text/javascript\" language=\"JavaScript\" src=\"../../common/scripts/frmset1s.js\"></script>");
  170.     document.writeln("<script type=\"text/javascript\" language=\"JavaScript\" src=\"../../common/scripts/frmset2s.js\"></script>");
  171.   }
  172. }
  173.  
  174. function  WWHelpFrameSet_ProcessBook(ParamBookContextFunc,
  175.                                      ParamPopupsFunc,
  176.                                      ParamMatchTopicFunc)
  177. {
  178.   var  Context;
  179.  
  180.  
  181.   // Get current book context
  182.   //
  183.   Context = ParamBookContextFunc();
  184.  
  185.   // Load up popups for this book
  186.   //
  187.   this.fLoadPopups(Context, ParamPopupsFunc);
  188.  
  189.   // Check for context match
  190.   //
  191.   this.fCheckContext(Context, ParamMatchTopicFunc);
  192. }
  193.  
  194. function  WWHelpFrameSet_LoadPopups(ParamContext,
  195.                                     ParamPopupsFunc)
  196. {
  197.   var  ContextPopups = new WWHelpFrameSet_PopupBook_Object(this.mBookDirList[this.mCurrentBookIndex]);
  198.  
  199.  
  200.   // Add entry for the current book dir and context
  201.   //
  202.   this.mPopups[ParamContext] = ContextPopups;
  203.  
  204.   // Now load the popups for the book
  205.   //
  206.   ParamPopupsFunc(ContextPopups.mPopups);
  207. }
  208.  
  209. function  WWHelpFrameSet_CheckContext(ParamContext,
  210.                                       ParamMatchTopicFunc)
  211. {
  212.   if (ParamMatchTopicFunc != null)
  213.   {
  214.     if ((this.mBookTag  != null) &&
  215.         (this.mTopicTag != null))
  216.     {
  217.       if (ParamContext == this.mBookTag)
  218.       {
  219.         if (this.mContextHREF == null)
  220.         {
  221.           this.mContextHREF = ParamMatchTopicFunc(this.mTopicTag);
  222.  
  223.           if (this.mContextHREF != null)
  224.           {
  225.             this.mContextHREF = "../../../" + this.mBookDirList[this.mCurrentBookIndex] + this.mContextHREF;
  226.           }
  227.         }
  228.       }
  229.     }
  230.   }
  231. }
  232.  
  233. function  WWHelpFrameSet_IncrementCurBookIndex()
  234. {
  235.   // Increment CurrentBookIndex
  236.   //
  237.   if (this.mCurrentBookIndex != -1)
  238.   {
  239.     if (this.mCurrentBookIndex < this.mBookDirList.length)
  240.     {
  241.       this.mCurrentBookIndex++;
  242.     }
  243.     else  // We're done!
  244.     {
  245.       this.mCurrentBookIndex = -1;
  246.     }
  247.   }
  248. }
  249.  
  250. function  WWHelpFrameSet_GetPopup(ParamContext,
  251.                                   ParamLink)
  252. {
  253.   var  ContextPopups;
  254.   var  BookDir = "";
  255.   var  PopupText = "";
  256.  
  257.  
  258.   // Match the context
  259.   //
  260.   ContextPopups = this.mPopups[ParamContext];
  261.   if (ContextPopups != null)
  262.   {
  263.     // Match the link
  264.     //
  265.     BookDir   = ContextPopups.mBookDir;
  266.     PopupText = ContextPopups.mPopups[ParamLink];
  267.   }
  268.  
  269.   return new Array(BookDir, PopupText);
  270. }
  271.  
  272. function  WWHelpFrameSet_ShowPopup(ParamContext,
  273.                                    ParamLink,
  274.                                    ParamEvent)
  275. {
  276.   var  PopupData;
  277.   var  PopupText;
  278.  
  279.  
  280.   // Get the popup text
  281.   //
  282.   PopupData = this.fGetPopup(ParamContext, ParamLink);
  283.   PopupText = PopupData[1];
  284.  
  285.   if ((PopupData != null) &&
  286.       (PopupText != null))
  287.   {
  288.     if (PopupText.length > 0)
  289.     {
  290.       this.mPopup.fShow(PopupText, ParamEvent);
  291.     }
  292.   }
  293. }
  294.  
  295. function  WWHelpFrameSet_HidePopup()
  296. {
  297.   this.mPopup.fHide();
  298. }
  299.  
  300. function  WWHelpFrameSet_ClickedPopup(ParamContext,
  301.                                       ParamLink)
  302. {
  303.   var  LinkHREF = "#";
  304.   var  PopupData;
  305.  
  306.  
  307.   // IE unescapes stuff for us, so we'll escape it right back
  308.   //
  309.   if (this.mBrowser == 2)  // Shorthand for IE
  310.   {
  311.     var  Parts;
  312.  
  313.  
  314.     Parts = ParamLink.split("#");
  315.     Parts[0] = escape(Parts[0]);
  316.     ParamLink = Parts.join("#");
  317.   }
  318.  
  319.   // Get the popup text
  320.   //
  321.   PopupData = this.fGetPopup(ParamContext, ParamLink);
  322.  
  323.   if (PopupData[0] != null)  // BookDir is valid
  324.   {
  325.     // Trim off the base filename and then up two levels
  326.     //
  327.     LinkHREF = this.mBaseURL + PopupData[0] + ParamLink;
  328.   }
  329.  
  330.   // Hide the popup if it is visible
  331.   //
  332.   this.mPopup.fHide();
  333.  
  334.   return LinkHREF;
  335. }
  336.