/*********** Name: Kin_Table Website: http://jorkin.reallydo.com/article.asp?id=538 Version: 1.0 Update: 2007/08/05 Introduction: toggle table row color by mouseover and check checkbox by click table row and toggle table row background-color by check checkbox but can not exclude checkboxes (I dont need this. ^_^ ) Reference: Dodo (tableRowCheckboxToggle) Softcomplex (tigra_tables) Others:Need jQuery ************/
function Kin_Tables(Kin_Table_GetTableMethod, //get your table Kin_Table_Header_Offset, //set the table header offset Kin_Table_Footer_Offset, //set the table footer offset Kin_Table_Odd_Style, // set the table odd row style name (Default:odd) Kin_Table_Even_Style, // set the table even row style name (Default:even) Kin_Table_Hover_Style, // set the table mouseover row style name (Default:over) Kin_Table_Click_Style // set the table odd row style name (Default:clicked) ){
//var Kin_Table = $(Kin_Table_Config.GetTableMethod+” tr:nth- child(n+”+eval(Kin_Table_Config.Header_Offset+1)+”)”); //Old Method var Kin_Table = $(Kin_Table_Config.GetTableMethod + “ tr”).slice(Kin_Table_Config.Header_Offset,-Kin_Table_Config.Footer_Offset); //New Method
Kin_Table.each(function(i, row){ var Kin_Table_Row_Checkbox = $(row).find(“:checkbox”); bChecked = false; $(row).addClass(i % 2 == 0 ? Kin_Table_Config.Odd_Style : Kin_Table_Config.Even_Style) $(row).hover(function(){ $(this).addClass(Kin_Table_Config.Hover_Style); }, function(){ $(this).removeClass(Kin_Table_Config.Hover_Style); }); $(row).click(function(){ $(this).toggleClass(Kin_Table_Config.Click_Style); Kin_Table_Row_Checkbox.each(function(){ this.checked = $(row).hasClass(Kin_Table_Config.Click_Style); }); }); Kin_Table_Row_Checkbox.each(function(){ if (this.checked) { bChecked = true; return false; } }); if (bChecked) { $(row).addClass(Kin_Table_Config.Click_Style); Kin_Table_Row_Checkbox.each(function(){ this.checked = true; }); } else { $(row).removeClass(Kin_Table_Config.Click_Style); } }); }); }