[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/js/ -> stripe.js (source)

   1  /**
   2   * Javascript code for finding all tables with classname "striped" and
   3   * dynamically striping their row colors.
   4   *
   5   * $Horde: horde/js/stripe.js,v 1.3.2.2 2005/10/18 11:33:38 jan Exp $
   6   *
   7   * See the enclosed file COPYING for license information (LGPL). If you did not
   8   * receive this file, see http://www.fsf.org/copyleft/lgpl.html.
   9   */
  10  
  11  /* We do everything onload so that the entire document is present
  12   * before we start searching it for tables. */
  13  if (window.addEventListener) {
  14      window.addEventListener('load', findStripedTables, false);
  15  } else if (window.attachEvent) {
  16      window.attachEvent('onload', findStripedTables);
  17  } else if (window.onload != null) {
  18      var oldOnLoad = window.onload;
  19      window.onload = function(e)
  20      {
  21          oldOnLoad(e);
  22          findStripedTables();
  23      };
  24  } else {
  25      window.onload = findStripedTables;
  26  }
  27  
  28  function findStripedTables()
  29  {
  30      if (!document.getElementsByTagName) {
  31          return;
  32      }
  33      tables = document.getElementsByTagName('table');
  34      for (i = 0; i < tables.length; i++) {
  35          if (tables[i].className.indexOf('striped') != -1) {
  36              stripe(tables[i]);
  37          }
  38      }
  39  }
  40  
  41  function stripe(table)
  42  {
  43      // The flag we'll use to keep track of whether the current row is
  44      // odd or even.
  45      var even = false;
  46  
  47      // Tables can have more than one tbody element; get all child
  48      // tbody tags and interate through them.
  49      var tbodies = table.childNodes;
  50      for (var c = 0; c < tbodies.length; c++) {
  51          if (tbodies[c].tagName == 'TBODY') {
  52              var trs = tbodies[c].childNodes;
  53              for (var i = 0; i < trs.length; i++) {
  54                  if (trs[i].tagName == 'TR') {
  55                      trs[i].className = trs[i].className.replace(/ ?rowEven ?/, '').replace(/ ?rowOdd ?/, '');
  56                      if (trs[i].className) {
  57                          trs[i].className += ' ';
  58                      }
  59                      trs[i].className += even ? 'rowEven' : 'rowOdd';
  60  
  61                      // Flip from odd to even, or vice-versa.
  62                      even = !even;
  63                  }
  64              }
  65          }
  66      }
  67  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7