/// <reference path="" />
/// <reference path="" />
//Introduce
include("");
/*
<table border="1">
<thead><tr>
<th></th>
</tr></thead>
<tbody><tr>
<td></td>
</tr></tbody>
</table>
*/
function Table(){
=null; //Table tags
=null; //Template line
=null; //Display area tbody tag
=false; //Whether the mouse is moved past, will the color be changed?
="#EBF3FD"; //Mouse moves over color
=false; //Whether to change the color when the line is clicked
="#D9E8FB"; //The color when the line is clicked
=null; //The current active line
}
= {
//Set whether to change the color when the mouse is moved by
SetOverChange: function(bOverChange) {
= bOverChange;
},
//Set whether to change the color when clicking the line
SetActiveChange: function(bActiveChange) {
= bActiveChange;
},
//Bind table object
BindElement: function(elm) {
= elm;
(, "mouseover", (this));
(, "mouseout", (this));
(, "click", (this));
var tbody = [0]; //Please take its first tbody as the template
= [0]; //Please take the first behavior template in this tbody
(tbody);
= ("TBODY"); //Create display area tbody
(); //Add to the table
},
//Binding the table ID
BindID: function(id) {
var elm = (id);
(elm);
},
_getEventRow: function(evn) {
var elm = (evn);
if (elm == ) return null;
while (() != "tr") {
elm = ;
if (elm == || elm == null) return null;
}
if ( != ) return null;
return elm;
},
//The mouse is outdated and the event response
onMouseOver: function(evn) {
var row = this._getEventRow(evn);
if (!row) return;
if () {
= ; //Change the color
}
},
//Instant response when the mouse is moved out
onMouseOut: function(evn) {
var row = this._getEventRow(evn);
if (!row) return;
if () {
if (row == ) {
//If the current line is an active line, set the active line color
= ;
}
else {
//Set as template line color
= ;
}
}
},
//Line click event response
onMouseClick: function(evn) {
var row = this._getEventRow(evn);
if (!row) return;
if () {
if ( != null) {
//Restore the original active line color
= ;
}
//Set the active line color
= ;
//Set the current behavioral activity line
= row;
}
},
//Add a new line, the line structure is consistent with the template line
NewRow: function(bAdd) {
var _this = this;
var newRow = (true); //Depth the template row in depth
= ;
//Add to the table display area
if (bAdd == true || bAdd == null) {
(newRow);
}
return newRow; //Return to new line
},
//Get all rows
GetRows: function() {
return ;
},
//Clear all rows
Clear: function() {
var newTbody = ("TBODY");
(newTbody, );
= newTbody;
},
//Delete a line
DeleteRow: function(row) {
();
if (row == ) {
= null;
}
},
//The following is marked as parameters, delete a line
DeleteAt: function(index) {
(index);
var rows = ();
if (rows[index] == ) {
= null;
}
},
//Add a line
AddRow: function(row) {
(row);
},
onBinding: function(row) { },
// Data binding
BindData: function(dataSource, mapList) {
var _this = this;
();
= new Repeater();
(mapList);
= function() {
var row = _this.NewRow(false);
return row;
};
(dataSource);
();
();
}
};