-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallback.js
30 lines (27 loc) · 954 Bytes
/
callback.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var lineMarker = function(tableContent, opt){
var rowMarkerClass = 'cellRow';
var colMarkerClass = 'cellCol';
// mark row
tableContent.find("."+opt.tdHeaderClassName).each(function(){
$(this).on("click", function(){
$(this).toggleClass(rowMarkerClass);
$(this).parent("tr").find("td").toggleClass(rowMarkerClass);
});
});
// mark col
var tdOrTh = opt.firstRowTd2Th ? 'th' : 'td';
tableContent.find("."+opt.trHeaderClassName).find(tdOrTh).each(function(){
$(this).on("click", function(){
var index = $(this).parent("tr").find(tdOrTh).index(this);
var trElements;
if(opt.addThead){
trElements = $(this).parent("tr").parent("thead").parent('table').find('tr');
}else{
trElements = $(this).parent("tr").parent('table').find('tr');
}
trElements.each(function(){
$(this).children().eq(index).toggleClass(colMarkerClass);
});
});
});
};