home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 December / PCWorld_2002-12_cd.bin / Software / Topware / wmp99xrc / mpsetup.exe / wmploc.DLL / HTML / TOC.HTC < prev    next >
Encoding:
HTML Component  |  2002-10-28  |  6.0 KB  |  189 lines

  1. <PUBLIC:COMPONENT lightWeight=true>
  2. <PUBLIC:EVENT name="onitemselect" ID="doselect">
  3. <PUBLIC:ATTACH EVENT="oncontentready" ONEVENT="load()" />
  4. <PUBLIC:ATTACH EVENT="onmouseout"  ONEVENT="mouseout()" />
  5. <PUBLIC:ATTACH EVENT="onmouseover"  ONEVENT="mousemove()" />
  6. <PUBLIC:ATTACH EVENT="onclick" ONEVENT="mouseup()" />
  7. <PUBLIC:PROPERTY NAME="width" />
  8. <PUBLIC:PROPERTY NAME="text" />
  9. <PUBLIC:PROPERTY NAME="dropdowntop" />
  10. <PUBLIC:PROPERTY NAME="dropdownleft" />
  11. <PUBLIC:PROPERTY NAME="menutext" />
  12. <PUBLIC:METHOD NAME="clickItem" />
  13. <PUBLIC:METHOD NAME="itemFocus" />
  14. <PUBLIC:METHOD NAME="itemBlur" />
  15.  
  16. <SCRIPT LANGUAGE="JScript">
  17.  
  18. var fDown = false;
  19. function load() 
  20.     var sLeft, sRight;
  21.     
  22.     if (IsRTLPage())
  23.     {
  24.         sLeft = 'right';
  25.         sRight = 'left';
  26.     }
  27.     else
  28.     {
  29.         sLeft = 'left';
  30.         sRight = 'right';
  31.     }
  32.     
  33.     var s = '<table style="position:relative; z-index: 5;" width=' + width + ' id="' + element.uniqueID + 'small" border=0 cellpadding=0 cellspacing=0><tr>';
  34.     s += '<td height=18 width=9 style="cursor:default"><img id="' + element.uniqueID + 'left" style="display:none" border=0 src="images\\hover-' + sLeft + '.gif"></td>';
  35.     s += '<td height=18 id="' + element.uniqueID + 'mid" style="cursor:default; background: transparent x repeat-x top left" class=textTitle><A class=textTitle href="X" onclick="return false;">' + text + '</a></td>';
  36.     s += '<td id="' + element.uniqueID + 'arrow" style="cursor:default; padding-left:10; background: transparent x repeat-x top left" align=right><img border=0 src="images\\arrow-down.gif"></td>';
  37.     s += '<td height=18 width=9 style="cursor:default"><img id="' + element.uniqueID + 'right" style="display:none" border=0 src="images\\hover-' + sRight + '.gif"></td></tr></table>';
  38.  
  39.     s += '<table width=' + width + ' style="display:none; position:absolute; z-index: 5;" id="' + element.uniqueID + 'menu" border=0 cellpadding=0 cellspacing=0>';
  40.     s += '<td height=18 width=9  valign=top style="cursor:default"><img border=0 src="images\\toc-top-' + sLeft + '.gif"></td>';
  41.     s += '<td height=18 style="cursor:default; background: white url(images\\toc-top.gif) repeat-x top left" class=textTitle><A href="x" onclick="return false;" class=textTitle>' + text + '</a></td>';
  42.     s += '<td style="cursor:default; padding-left:10; background: white url(images\\toc-top.gif) repeat-x top left" align=right><img border=0 src="images\\arrow-up.gif"></td>';
  43.     s += '<td height=18 width=9 valign=top style="cursor:default"><img border=0 src="images\\toc-top-' + sRight + '.gif"></td></tr>';
  44.     
  45.     s += '<tr><td width=9 style="cursor:default; background: white url(images\\toc-' + sLeft + '.gif) repeat-y top left"></td>';
  46.     s += '<td colspan=2 style="background: white url(images\\toc-center.gif) repeat top left">' + BuildMenu() + '</td>';
  47.     s += '<td width=9 style="cursor:default; background: white url(images\\toc-' + sRight + '.gif) repeat-y top left"></td></tr>';
  48.  
  49.     s += '<tr><td width=9 valign=bottom style="cursor:default"><img border=0 src="images\\toc-bottom-' + sLeft + '.gif"></td>';
  50.     s += '<td colspan=2 style="background: white url(images\\toc-bottom.gif) repeat-x bottom left"></td>';
  51.     s += '<td width=9 valign=bottom><img border=0 src="images\\toc-bottom-' + sRight + '.gif"></td></tr>';
  52.  
  53.     s += '</table>';
  54.     
  55.     element.style.height = 18;
  56.     element.innerHTML = s; 
  57. }
  58.  
  59. function BuildMenu()
  60. {
  61.     var s = '<table border=0 cellpadding=2 cellspacing=0>', aList, i;
  62.     
  63.     aList = menutext.split(';');
  64.     for (i = 0; i < aList.length; i++)
  65.     {
  66.         s += '<tr><td width=100%><A href="X" id="' + uniqueID + i + '" onblur="' + uniqueID + '.itemBlur(' + i + ');" onfocus="' + uniqueID + '.itemFocus(' + i + ');" clicknum="' + i + '" class=tocText> ' + aList[i] + ' </a></td></tr>';
  67.     }
  68.     
  69.     return s + '</table>';
  70. }
  71.  
  72. function setImage(iMode) 
  73. {  
  74.     var sKey, sDisplay, id, a, sLeft, sRight;
  75.     
  76.     if (IsRTLPage())
  77.     {
  78.         sLeft = 'right';
  79.         sRight = 'left';
  80.     }
  81.     else
  82.     {
  83.         sLeft = 'left';
  84.         sRight = 'right';
  85.     }
  86.     
  87.     sDisplay = 'inline';
  88.     if (iMode == 1)
  89.         sKey = 'hover';
  90.     else
  91.     {
  92.         sKey = 'normal';
  93.         sDisplay = 'none';
  94.     }
  95.         
  96.     a = element.document.all;
  97.     id = element.uniqueID;
  98.     
  99.     a(id + 'left').src = 'images\\' + sKey + '-' + sLeft + '.gif';
  100.     if (sKey == 'normal')
  101.     {
  102.         a(id + 'mid').style.backgroundImage = '';
  103.         a(id + 'arrow').style.backgroundImage = '';
  104.     }
  105.     else
  106.     {
  107.         a(id + 'mid').style.backgroundImage = 'url(images\\' + sKey + '-center.gif)';
  108.         a(id + 'arrow').style.backgroundImage = 'url(images\\' + sKey + '-center.gif)';
  109.     }
  110.     a(id + 'right').src = 'images\\' + sKey + '-' + sRight + '.gif';
  111.     a(id + 'left').style.display = sDisplay
  112.     a(id + 'right').style.display = sDisplay
  113. }
  114.  
  115. function mouseout() 
  116.     if (!fDown) 
  117.         setImage(0); 
  118.     else
  119.     {
  120.         if (event.srcElement.className == 'tocText')
  121.             event.srcElement.style.backgroundColor = '';
  122.     }
  123. }
  124. function mousemove() 
  125. {    
  126.     if (!fDown) 
  127.         setImage(1); 
  128.     else
  129.     {
  130.         if (event.srcElement.className == 'tocText')
  131.             event.srcElement.style.backgroundColor = 'lightblue';
  132.     }
  133. }
  134.  
  135. var iCurrentFocusItem = -1;
  136. function itemFocus(i)
  137. {
  138.     iCurrentFocusItem = i;
  139. }
  140.  
  141. function itemBlur(i)
  142. {
  143.     iCurrentFocusItem = -1;
  144. }
  145.  
  146. function mouseup() 
  147. {
  148.     var oMenu = element.document.all(element.uniqueID + 'menu')
  149.     fDown = !fDown;
  150.     if (fDown)
  151.         element.setCapture();
  152.     else
  153.     {
  154.         var fClicked = false, oElement;
  155.         element.releaseCapture();
  156.         if (event.srcElement.className == 'tocText')
  157.         {
  158.             fClicked = true;
  159.             oElement = event.srcElement;
  160.         } else if (iCurrentFocusItem != -1)
  161.         {
  162.             fClicked = true;
  163.             oElement = element.document.all(uniqueID + iCurrentFocusItem);
  164.         }
  165.         
  166.         if (fClicked)
  167.         {
  168.             oElement.style.backgroundColor = '';
  169.             window.setTimeout(element.uniqueID + '.clickItem(' + oElement.clicknum + ')', 0);            
  170.         }
  171.     }
  172.         
  173.     element.document.all(element.uniqueID + 'small').style.display = fDown ? 'none' : 'inline';
  174.     oMenu.style.display = fDown ? 'inline' : 'none';
  175. }
  176.  
  177. function clickItem(i)
  178. {
  179.     var e = createEventObject();
  180.     e.item = i;
  181.     doselect.fire(e); 
  182.     return false;
  183. }
  184.  
  185. </SCRIPT>
  186. </PUBLIC:COMPONENT>
  187.