home *** CD-ROM | disk | FTP | other *** search
/ Beginning Direct3D Game Programming / Direct3D.iso / directx / dxf / extras / documentation / directx7 / directx7.chm / dxmedia / foundation / d3drm / js / toc.js < prev    next >
Text File  |  2000-09-22  |  3KB  |  121 lines

  1. var doc = new Object();
  2. var win = new Object();
  3. var image_on = '';
  4. var image_off = '';
  5.  
  6. function TocControl(){
  7.     this.printStr = printStr;
  8.     this.setTarget = setTarget;
  9.     this.setVar = setVar;
  10.     this.tree = tree;
  11. }
  12.  
  13. function setVar(WINDOW, DOCUMENT, IMAGE_ON, IMAGE_OFF){
  14.     win = WINDOW;
  15.     doc = DOCUMENT;
  16.     image_on = IMAGE_ON;
  17.     image_off = IMAGE_OFF;
  18. }
  19.  
  20. function setTarget(str){
  21.     if (win.top != self) {
  22.         if (win.top.frames.length > 1 && win.top.frames[1].name==str) {
  23.             for (i=0; i<doc.links.length; i++) {
  24.                 if (doc.links(i).target=="")
  25.                     doc.links(i).target=str;
  26.             }
  27.         }
  28.     }
  29. }
  30.  
  31. function tree(src){
  32.     //<!--@ Limit response to ALINK and IMAGE type elements-->
  33.     if ((src.tagName == "A")||(src.tagName == "IMG")) {
  34.         var i = 0;
  35.         
  36.         //<!--@ Go upwards parent containers -->
  37.         for (var TAG_PARENT = src.parentElement; TAG_PARENT != null; TAG_PARENT = TAG_PARENT.parentElement) {
  38.             
  39.             //<!--@ If you find <LI> container test for node type end exit loop -->
  40.             if(TAG_PARENT.tagName == "LI") { 
  41.                 setIfNode(TAG_PARENT);
  42.                 break;
  43.             }
  44.             
  45.             //<!--@ Exit if looped 4 times -->
  46.             if (i == 4) break;
  47.             i++;
  48.         }
  49.     }
  50. }
  51.  
  52. function setIfNode(src){
  53.     var i = 0;
  54.     
  55.     //<!--@ Look children elements for <DIV> and <IMG> elements
  56.     // Loop will terminate in two steps for non node elements.
  57.     // -->
  58.     while (src.children(i) != null){
  59.     
  60.         //<!--@ Look for IMG inside <A> element -->
  61.         if (src.children(i).tagName == "A") { 
  62.             if (src.children(i).children(0)) 
  63.                 if (src.children(i).children(0).className == "FLIP" )
  64.                     var IMAGE = src.children(i).children(0)
  65.         }
  66.         
  67.         //<!--@ If you find <DIV>  -->
  68.         if (src.children(i).tagName == "DIV") {
  69.             if (src.children(i).className == "Outline"){
  70.                 var NODE = src.children(i);
  71.                 break;
  72.             }else {alert("Improper DIV CLASS for this request!"); break;}
  73.         }
  74.         
  75.         //<!--@ Exit after 4 loops -->
  76.         if (i==4) break;
  77.         i++
  78.     }
  79.     if (NODE) displayMode(NODE,IMAGE);
  80. }
  81.  
  82. function displayMode(src,image){
  83.     if (src){
  84.         
  85.         if ('none' == src.style.display) {
  86.             src.style.display = '';
  87.             //<!--@ Set the expanded tree node icon  image_on = global variable  -->
  88.             if(image) image.src = image_on; 
  89.         }
  90.         else{ 
  91.             src.style.display = 'none';
  92.             //<!--@ Set the collapsed tree node icon image_off = global variable -->
  93.             if(image) image.src = image_off ;
  94.             
  95.             //<!-- Colapse all children elements -->
  96.             collapseChildren(src);
  97.         }
  98.     }
  99.     
  100. }
  101.  
  102.  
  103. function collapseChildren(src) {
  104.     var i;
  105.     var div = doc.all.tags("DIV");
  106.     for (i=0; i<div.length; i++) {
  107.         if (div(i).sourceIndex < src.sourceIndex) continue;
  108.         if (src.contains(div(i)) != true) return;
  109.         if (div(i).className == "Outline") {div(i).style.display = "none" };
  110.     }
  111. }
  112.  
  113. function setTocControl(sImgOn, sImgOff){
  114.     if((g_isIE== true) && (g_iMaj > 3)){
  115.         setVar(window,document,sImgOn,sImgOff);
  116.         setTarget("TEXTWIN");
  117.     }
  118. }
  119.  
  120.     
  121.