home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / phptriad / phptriad2-2-1.exe / htdocs / phpmyadmin / libraries / left.js < prev    next >
Text File  |  2001-12-27  |  10KB  |  310 lines

  1. /* $Id: left.js,v 1.6 2001/12/27 15:06:25 loic1 Exp $ */
  2.  
  3.  
  4. // These scripts were originally found on cooltype.com.
  5. // Modified 01/01/1999 by Tobias Ratschiller for linuxapps.com
  6.  
  7. // Modified 7th June 2000 by Brian Birtles for Mozilla 5.0
  8. // compatibility for phpMyAdmin
  9.  
  10. // Rewritten and put in a libray 2nd May 2001 by Lo∩c Chapeaux
  11.  
  12. // Test passed with:
  13. // - Mozilla 0.8.1-0.9.6 for Windows (js enabled & disabled)
  14. // - IE5, 5.01, 5.5, 6.0 for Windows
  15. // - Netscape 4.75 for Windows
  16.  
  17. // Test failed (crappy DOM implementations) with:
  18. // - Opera 5.02 for windows: 'getElementsByTagName' is unsupported
  19. // - Opera 5.10 to 5.12 for windows, Opera 5+ for Linux: 'style.display' can't
  20. //   be changed
  21. // - Konqueror 2+: 'style.display' can't be changed
  22.  
  23.  
  24. var isExpanded   = false;
  25.  
  26. var imgOpened    = new Image(9,9);
  27. imgOpened.src    = 'images/minus.gif';
  28. var imgClosed    = new Image(9,9);
  29. imgClosed.src    = 'images/plus.gif';
  30.  
  31.  
  32. /**
  33.  * Do reloads the frame if the window has been resized under Netscape4+
  34.  *
  35.  * @access  private
  36.  */
  37. function reDo() {
  38.   if (innerWidth != origWidth || innerHeight != origHeight)
  39.     location.reload(true);
  40. } // end of the 'reDo()' function
  41.  
  42. /**
  43.  * Positioned element resize bug under NS4+
  44.  */
  45. if (isNS4) {
  46.   var origWidth  = innerWidth;
  47.   var origHeight = innerHeight;
  48.   onresize       = reDo;
  49. }
  50.  
  51.  
  52. /**
  53.  * Gets the id of the first collapsible room
  54.  *
  55.  * @param  string  the name of the first collapsible room
  56.  *
  57.  * @return  integer  the index number corresponding to this room
  58.  *
  59.  * @access  public
  60.  */
  61. function nsGetIndex(el) {
  62.   var ind       = null;
  63.   var theLayers = document.layers;
  64.   var layersCnt = theLayers.length;
  65.   for (var i = 0; i < layersCnt; i++) {
  66.     if (theLayers[i].id == el) {
  67.       ind = i;
  68.       break;
  69.     }
  70.   }
  71.   return ind;
  72. } // end of the 'nsGetIndex()' function
  73.  
  74.  
  75. /**
  76.  * Positions layers under NS4+
  77.  *
  78.  * @access  public
  79.  */
  80. function nsArrangeList() {
  81.   if (typeof(firstInd) != 'undefined' && firstInd != null) {
  82.     var theLayers = document.layers;
  83.     var layersCnt = theLayers.length;
  84.     var nextY     = theLayers[firstInd].pageY + theLayers[firstInd].document.height;
  85.     for (var i = firstInd + 1; i < layersCnt; i++) {
  86.       if (theLayers[i].visibility != 'hide') {
  87.         theLayers[i].pageY = nextY;
  88.         nextY              += theLayers[i].document.height;
  89.       }
  90.     }
  91.   }
  92. } // end of the 'nsArrangeList()' function
  93.  
  94.  
  95. /**
  96.  * Expand databases at startup
  97.  *
  98.  * @access  public
  99.  */
  100. function nsShowAll() {
  101.   var theLayers = document.layers;
  102.   var layersCnt = theLayers.length;
  103.   for (i = firstInd; i < layersCnt; i++) {
  104.     theLayers[i].visibility = 'show';
  105.   }
  106. } // end of the 'nsShowAll()' function
  107.  
  108.  
  109. /**
  110.  * Collapses databases at startup
  111.  *
  112.  * @access  public
  113.  */
  114. function initIt()
  115. {
  116.   if (!capable || !isServer)
  117.     return;
  118.  
  119.   if (isDOM) {
  120.     var tempColl    = document.getElementsByTagName('DIV');
  121.     var tempCollCnt = tempColl.length;
  122.     for (var i = 0; i < tempCollCnt; i++) {
  123.       if (tempColl[i].id == expandedDb)
  124.         tempColl[i].style.display = 'block';
  125.       else if (tempColl[i].className == 'child')
  126.         tempColl[i].style.display = 'none';
  127.     }
  128.   } // end of the DOM case
  129.   else if (isIE4) {
  130.     tempColl        = document.all.tags('DIV');
  131.     var tempCollCnt = tempColl.length;
  132.     for (var i = 0; i < tempCollCnt; i++) {
  133.       if (tempColl(i).id == expandedDb)
  134.         tempColl(i).style.display = 'block';
  135.       else if (tempColl(i).className == 'child')
  136.         tempColl(i).style.display = 'none';
  137.     }
  138.   } // end of the IE4 case
  139.   else if (isNS4) {
  140.     var theLayers  = document.layers;
  141.     var layersCnt  = theLayers.length;
  142.     for (var i = 0; i < layersCnt; i++) {
  143.       if (theLayers[i].id == expandedDb)
  144.         theLayers[i].visibility   = 'show';
  145.       else if (theLayers[i].id.indexOf('Child') != -1)
  146.         theLayers[i].visibility   = 'hide';
  147.       else
  148.         theLayers[i].visibility   = 'show';
  149.     }
  150.     nsArrangeList();
  151.   } // end of the NS4 case
  152. } // end of the 'initIt()' function
  153.  
  154.  
  155. /**
  156.  * Collapses/expands a database when the user require this to be done
  157.  *
  158.  * @param  string  the name of the database to act on
  159.  * @param  boolean whether to expand or to collapse the database content
  160.  *
  161.  * @access  public
  162.  */
  163. function expandBase(el, unexpand)
  164. {
  165.   if (!capable)
  166.     return;
  167.  
  168.   if (isDOM) {
  169.     var whichEl = document.getElementById(el + 'Child');
  170.     var whichIm = document.getElementById(el + 'Img');
  171.     if (whichEl.style.display == 'none' && whichIm) {
  172.       whichEl.style.display  = 'block';
  173.       whichIm.src            = imgOpened.src;
  174.     }
  175.     else if (unexpand) {
  176.       whichEl.style.display  = 'none';
  177.       whichIm.src            = imgClosed.src;
  178.     }
  179.   } // end of the DOM case
  180.   else if (isIE4) {
  181.     var whichEl = document.all(el + 'Child');
  182.     var whichIm = document.images.item(el + 'Img');
  183.     if (whichEl.style.display == 'none') {
  184.       whichEl.style.display  = 'block';
  185.       whichIm.src            = imgOpened.src;
  186.     }
  187.     else if (unexpand) {
  188.       whichEl.style.display  = 'none';
  189.       whichIm.src            = imgClosed.src;
  190.     }
  191.   } // end of the IE4 case
  192.   else if (isNS4) {
  193.     var whichEl = document.layers[el + 'Child'];
  194.     var whichIm = document.layers[el + 'Parent'].document.images['imEx'];
  195.     if (whichEl.visibility == 'hide') {
  196.       whichEl.visibility  = 'show';
  197.       whichIm.src         = imgOpened.src;
  198.     }
  199.     else if (unexpand) {
  200.       whichEl.visibility  = 'hide';
  201.       whichIm.src         = imgClosed.src;
  202.     }
  203.     nsArrangeList();
  204.   } // end of the NS4 case
  205. } // end of the 'expandBase()' function
  206.  
  207.  
  208. /**
  209.  * Hilight/un-hilight a database when the mouse pass over/out it
  210.  *
  211.  * @param  string  the name of the database to act on
  212.  * @param  boolean the color to be used
  213.  *
  214.  * @access  public
  215.  */
  216. function hilightBase(el, theColor)
  217. {
  218.   if (!isDOM && !isIE4) {
  219.     return;
  220.   }
  221.  
  222.   if (isDOM) {
  223.     var whichDb     = document.getElementById(el + 'Parent');
  224.     var whichTables = document.getElementById(el + 'Child');
  225.   }
  226.   else if (isIE4) {
  227.     var whichDb     = document.all(el + 'Parent');
  228.     var whichTables = document.all(el + 'Child');
  229.   }
  230.  
  231.   if (typeof(whichDb.style) == 'undefined') {
  232.     return;
  233.   }
  234.   else if (whichTables) {
  235.     whichDb.style.backgroundColor     = theColor;
  236.     whichTables.style.backgroundColor = theColor;
  237.   }
  238.   else {
  239.     whichDb.style.backgroundColor     = theColor;
  240.   }
  241.  
  242.   return true;
  243. } // end of the 'hilightBase()' function
  244.  
  245.  
  246. /**
  247.  * Add styles for positioned layers
  248.  */
  249. if (capable) {
  250.   with (document) {
  251.     // Brian Birtles : This is not the ideal method of doing this
  252.     // but under the 7th June '00 Mozilla build (and many before
  253.     // it) Mozilla did not treat text between <style> tags as
  254.     // style information unless it was written with the one call
  255.     // to write().
  256.     if (isDOM) {
  257.       var lstyle = '<style type="text\/css">'
  258.                  + '<!--'
  259.                  + 'div {color: #000000}'
  260.                  + '.heada {font-family: ' + fontFamily + '; font-size: ' + fontSize + '; color: #000000}'
  261.                  + '.headaCnt {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '; color: #000000}'
  262.                  + '.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; display: block}'
  263.                  + '.child {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '; color: #333399; text-decoration: none; display: none}'
  264.                  + '.item, .item:active, .item:hover, .tblItem, .tblItem:active {font-size: ' + fontSmall + '; color: #333399; text-decoration: none}'
  265.                  + '.tblItem:hover {color: #FF0000; text-decoration: underline}'
  266.                  + '\/\/-->'
  267.                  + '<\/style>';
  268.       write(lstyle);
  269.     }
  270.     else {
  271.       writeln('<style type="text\/css">');
  272.       writeln('<!--');
  273.       writeln('div {color: #000000}');
  274.       writeln('.heada {font-family: ' + fontFamily + '; font-size: ' + fontSize + '; color: #000000}');
  275.       writeln('.headaCnt {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '; color: #000000}');
  276.       if (isIE4) {
  277.         writeln('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; display: block}');
  278.         writeln('.child {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '; color: #333399; text-decoration: none; display: none}');
  279.         writeln('.item, .item:active, .item:hover, .tblItem, .tblItem:active {font-size: ' + fontSmall + '; color: #333399; text-decoration: none}');
  280.         writeln('.tblItem:hover {color: #FF0000; text-decoration: underline}');
  281.       }
  282.       else {
  283.         writeln('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; position: absolute; visibility: hidden}');
  284.         writeln('.child {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '; color: #333399; position: absolute; visibility: hidden}');
  285.         writeln('.item, .tblItem {font-size: ' + fontSmall + '; color: #333399; text-decoration: none}');
  286.       }
  287.       writeln('\/\/-->');
  288.       writeln('<\/style>');
  289.     }
  290.   }
  291. }
  292. else {
  293.   with (document) {
  294.     writeln('<style type="text\/css">');
  295.     writeln('<!--');
  296.     writeln('div {color: #000000}');
  297.     writeln('.heada {font-family: ' + fontFamily + '; font-size: ' + fontSize + '; color: #000000}');
  298.     writeln('.headaCnt {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '; color: #000000}');
  299.     writeln('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none}');
  300.     writeln('.child {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '; color: #333399; text-decoration: none}');
  301.     writeln('.item, .item:active, .item:hover, .tblItem, .tblItem:active {font-size: ' + fontSmall + '; color: #333399; text-decoration: none}');
  302.     writeln('.tblItem:hover {color: #FF0000; text-decoration: underline}');
  303.     writeln('\/\/-->');
  304.     writeln('<\/style>');
  305.   }
  306. } // end of adding styles
  307.  
  308.  
  309. onload = initIt;
  310.