[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/js/ui/ -> tableeffects.js (source)

   1  /**
   2   * TableEffects class
   3   *
   4   * @param id The id of the table to which we'd like to apply the effects. If no id is provided (i.e. the constructor
   5   * is called without parameters), then all tables in the page will be processed
   6   */
   7  Lifetype.UI.TableEffects = function( id )
   8  {
   9      this.id = id;
  10      this.table = document.getElementById( id );    
  11  }
  12  
  13  /**
  14   * Given a table id, use stripes for its rows
  15   *
  16   * @param cssClass CSS class to be applied to odd rows. If none is provided, a class called
  17   * "odd" will be used.
  18   */
  19  Lifetype.UI.TableEffects.prototype.stripe = function( cssClass )
  20  {
  21      if( this.table ) 
  22          var tbodies = this.table.getElementsByTagName("tbody");
  23      else
  24          var tbodies = document.getElementsByTagName("tbody");
  25          
  26      if( !cssClass ) 
  27          cssClass = "odd";
  28          
  29      for (var i=0; i<tbodies.length; i++) {
  30          var odd = true;
  31          var rows = tbodies[i].getElementsByTagName("tr");
  32          for (var j=0; j<rows.length; j++) {
  33              if (odd == false) {
  34                  odd = true;
  35              } 
  36              else {
  37                  YAHOO.util.Dom.addClass( rows[j], cssClass );
  38                  odd = false;
  39              }
  40          }
  41      }
  42  }
  43  
  44  /**
  45   * Highlights the row where the mouse is
  46   *
  47   * @param cssClass The name of the CSS cssClass to be applied to highlighted rows. If none is provided,
  48   * a class called "highlightClass" will be used
  49   */
  50  Lifetype.UI.TableEffects.prototype.highlightRows = function( cssClass )
  51  {
  52      if(!document.getElementsByTagName) 
  53          return false;
  54      
  55      if( !cssClass )
  56          cssClass = "highlightClass";
  57      
  58      if( this.table )
  59          var tbodies = this.table.getElementsByTagName("tbody");
  60      else
  61          var tbodies = document.getElementsByTagName("tbody");
  62      
  63      for (var j=0; j<tbodies.length; j++) {
  64          var rows = tbodies[j].getElementsByTagName("tr");
  65            for (var i=0; i<rows.length; i++) {
  66              rows[i].onmouseover = function() {                
  67                  YAHOO.util.Dom.addClass( this, cssClass );
  68              }
  69              rows[i].onmouseout = function() {
  70                  YAHOO.util.Dom.removeClass( this, cssClass );
  71              }
  72          }
  73      }
  74  }


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics