-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtablehl.htc
93 lines (72 loc) · 1.78 KB
/
tablehl.htc
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<public:event name="onrowselect" ID=rowSelect />
<public:property name="hlColor" />
<public:property name="slColor" />
<PUBLIC:ATTACH EVENT="ondetach" ONEVENT="cleanup()" />
<script language=jscript>
var currRow = -1;
var selRow = -1;
if (element.tagName == 'TABLE')
{
element.attachEvent('onmouseover', onMouseOver);
element.attachEvent('onmouseout', onMouseOut);
element.attachEvent('onclick', onClick);
}
else
{
alert("Error: tablehl not attached to a table element");
}
function cleanup()
{
hilite(-1);
element.detachEvent('onmouseover', onMouseOver);
element.detachEvent('onmouseout', onMouseOut);
element.detachEvent('onclick', onClick);
}
function onClick()
{
srcElem = window.event.srcElement;
//crawl up the tree to find the table row
while (srcElem.tagName != "TR" && srcElem.tagName != "TABLE")
srcElem = srcElem.parentElement;
if(srcElem.tagName != "TR") return;
if(srcElem.rowIndex == 0 ) return;
if (selRow != -1) selRow.runtimeStyle.backgroundColor = '';
srcElem.runtimeStyle.backgroundColor = slColor;
selRow = srcElem;
var oEvent = createEventObject();
oEvent.selected = selRow;
rowSelect.fire(oEvent);
}
function onMouseOver()
{
srcElem = window.event.srcElement;
//crawl up to find the row
while (srcElem.tagName != "TR" && srcElem.tagName != "TABLE")
srcElem = srcElem.parentElement;
if(srcElem.tagName != "TR") return;
if (srcElem.rowIndex > 0)
hilite(srcElem);
else
hilite(-1);
}
function onMouseOut()
{
// Make sure we catch exit from the table
hilite(-1, -1);
}
function hilite(newRow)
{
if (hlColor != null )
{
if (currRow != -1 && currRow!=selRow)
{
currRow.runtimeStyle.backgroundColor = '';
}
if (newRow != -1 && newRow!=selRow)
{
newRow.runtimeStyle.backgroundColor = hlColor;
}
}
currRow = newRow;
}
</script>