|
|
@ -33,12 +33,10 @@ |
|
|
|
|
|
|
|
|
|
|
|
var dynamicTable = new Class ({ |
|
|
|
var dynamicTable = new Class ({ |
|
|
|
|
|
|
|
|
|
|
|
initialize: function(table, options){ |
|
|
|
initialize: function(){ |
|
|
|
this.setOptions({ |
|
|
|
}, |
|
|
|
overCls: false, |
|
|
|
|
|
|
|
selectCls: false, |
|
|
|
setup: function(table){ |
|
|
|
altCls: false |
|
|
|
|
|
|
|
}, options); |
|
|
|
|
|
|
|
this.table = $(table); |
|
|
|
this.table = $(table); |
|
|
|
this.rows = new Object(); |
|
|
|
this.rows = new Object(); |
|
|
|
this.cur = new Array(); |
|
|
|
this.cur = new Array(); |
|
|
@ -47,16 +45,13 @@ var dynamicTable = new Class ({ |
|
|
|
altRow: function() |
|
|
|
altRow: function() |
|
|
|
{ |
|
|
|
{ |
|
|
|
var trs = this.table.getElements('tr'); |
|
|
|
var trs = this.table.getElements('tr'); |
|
|
|
if(this.options.altCls) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
trs.each(function(el,i){ |
|
|
|
trs.each(function(el,i){ |
|
|
|
if(i % 2){ |
|
|
|
if(i % 2){ |
|
|
|
el.addClass(this.options.altCls); |
|
|
|
el.addClass('alt'); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
el.removeClass(this.options.altCls); |
|
|
|
el.removeClass('alt'); |
|
|
|
} |
|
|
|
} |
|
|
|
}.bind(this)); |
|
|
|
}.bind(this)); |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
insertRow: function(id, row){ |
|
|
|
insertRow: function(id, row){ |
|
|
@ -73,14 +68,12 @@ var dynamicTable = new Class ({ |
|
|
|
td.injectInside(tr); |
|
|
|
td.injectInside(tr); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if(this.options.overCls){ |
|
|
|
|
|
|
|
tr.addEvent('mouseover', function(e){ |
|
|
|
tr.addEvent('mouseover', function(e){ |
|
|
|
tr.addClass(this.options.overCls); |
|
|
|
tr.addClass('over'); |
|
|
|
}.bind(this)); |
|
|
|
}.bind(this)); |
|
|
|
tr.addEvent('mouseout', function(e){ |
|
|
|
tr.addEvent('mouseout', function(e){ |
|
|
|
tr.removeClass(this.options.overCls); |
|
|
|
tr.removeClass('over'); |
|
|
|
}.bind(this)); |
|
|
|
}.bind(this)); |
|
|
|
} |
|
|
|
|
|
|
|
tr.addEvent('click', function(e){ |
|
|
|
tr.addEvent('click', function(e){ |
|
|
|
e.stop(); |
|
|
|
e.stop(); |
|
|
|
if(e.control) { |
|
|
|
if(e.control) { |
|
|
@ -91,14 +84,14 @@ var dynamicTable = new Class ({ |
|
|
|
// Remove selected style
|
|
|
|
// Remove selected style
|
|
|
|
temptr = this.rows[id]; |
|
|
|
temptr = this.rows[id]; |
|
|
|
if(temptr){ |
|
|
|
if(temptr){ |
|
|
|
temptr.removeClass(this.options.selectCls); |
|
|
|
temptr.removeClass('selected'); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.cur[this.cur.length] = id; |
|
|
|
this.cur[this.cur.length] = id; |
|
|
|
// Add selected style
|
|
|
|
// Add selected style
|
|
|
|
temptr = this.rows[id]; |
|
|
|
temptr = this.rows[id]; |
|
|
|
if(temptr){ |
|
|
|
if(temptr){ |
|
|
|
temptr.addClass(this.options.selectCls); |
|
|
|
temptr.addClass('selected'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -119,7 +112,7 @@ var dynamicTable = new Class ({ |
|
|
|
// Add selected style
|
|
|
|
// Add selected style
|
|
|
|
temptr = this.rows[curID]; |
|
|
|
temptr = this.rows[curID]; |
|
|
|
if(temptr){ |
|
|
|
if(temptr){ |
|
|
|
temptr.addClass(this.options.selectCls); |
|
|
|
temptr.addClass('selected'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -128,14 +121,14 @@ var dynamicTable = new Class ({ |
|
|
|
for(i=0; i<this.cur.length; i++) { |
|
|
|
for(i=0; i<this.cur.length; i++) { |
|
|
|
var temptr = this.rows[this.cur[i]]; |
|
|
|
var temptr = this.rows[this.cur[i]]; |
|
|
|
if(temptr){ |
|
|
|
if(temptr){ |
|
|
|
temptr.removeClass(this.options.selectCls); |
|
|
|
temptr.removeClass('selected'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.cur.empty(); |
|
|
|
this.cur.empty(); |
|
|
|
// Add selected style to new one
|
|
|
|
// Add selected style to new one
|
|
|
|
temptr = this.rows[id]; |
|
|
|
temptr = this.rows[id]; |
|
|
|
if(temptr){ |
|
|
|
if(temptr){ |
|
|
|
temptr.addClass(this.options.selectCls); |
|
|
|
temptr.addClass('selected'); |
|
|
|
} |
|
|
|
} |
|
|
|
this.cur[0] = id; |
|
|
|
this.cur[0] = id; |
|
|
|
} |
|
|
|
} |
|
|
@ -153,8 +146,8 @@ var dynamicTable = new Class ({ |
|
|
|
this.cur[this.cur.length] = id; |
|
|
|
this.cur[this.cur.length] = id; |
|
|
|
temptr = this.rows[id]; |
|
|
|
temptr = this.rows[id]; |
|
|
|
if(temptr){ |
|
|
|
if(temptr){ |
|
|
|
if(!temptr.hasClass(this.options.selectCls)) { |
|
|
|
if(!temptr.hasClass('selected')) { |
|
|
|
temptr.addClass(this.options.selectCls); |
|
|
|
temptr.addClass('selected'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -204,7 +197,7 @@ var dynamicTable = new Class ({ |
|
|
|
return ids; |
|
|
|
return ids; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
dynamicTable.implement(new Options); |
|
|
|
//dynamicTable.implement(new Options);
|
|
|
|
dynamicTable.implement(new Events); |
|
|
|
//dynamicTable.implement(new Events);
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************/ |
|
|
|
/*************************************************************/ |
|
|
|