blob: d8125c5302a93e0460847ec8561a3c9420e9af92 (
plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
//misc objects
//a simple encapsulation object
//used to query widths and heights
function cDomObject( sId )
{
if( bw.dom || bw.ie )
{
this.hElement = document.getElementById( sId )
this.hStyle = this.hElement.style
}
}
cDomObject.prototype.getWidth = function( )
{
return cDomObject.getWidth( this.hElement )
}
cDomObject.getWidth = function( hElement )
{
if( hElement.currentStyle )
{
var nWidth = parseInt( hElement.currentStyle.width )
if( isNaN( nWidth ) )
{
return parseInt( hElement.offsetWidth )
}
else
{
return nWidth
}
}
else
{
return parseInt( hElement.offsetWidth )
}
}
cDomObject.prototype.getHeight = function( )
{
return cDomObject.getHeight( this.hElement )
}
cDomObject.getHeight = function( hElement )
{
if( hElement.currentStyle )
{
var nHeight = parseInt( hElement.currentStyle.height )
if( isNaN( nHeight ) )
{
return parseInt( hElement.offsetHeight )
}
else
{
return nHeight
}
}
else
{
return parseInt( hElement.offsetHeight )
}
}
cDomObject.prototype.getLeft = function()
{
return cDomObject.getLeft( this.hElement )
}
cDomObject.getLeft = function( hElement )
{
return parseInt( hElement.offsetLeft )
}
cDomObject.prototype.getTop = function( )
{
return cDomObject.getTop( this.hElement )
}
cDomObject.getTop = function( hElement )
{
return parseInt( hElement.offsetTop )
}
// used to get the absolute position of an relativeli position element
// by accumulating the offset parameters
// example
// cDomObject.getOffsetParam( hElement,'offsetLeft' )
cDomObject.getOffsetParam = function( hElement, sParam, hLimitParent )
{
var nRes = 0
if( hLimitParent == null )
{
hLimitParent = document.body.parentElement
}
while( hElement != hLimitParent )
{
nRes += eval( 'hElement.' + sParam )
if( !hElement.offsetParent ) { break }
hElement = hElement.offsetParent
}
return nRes
}
// used to get the absolute position of an relativeli position element
// by accumulating the scroll offset parameters
// example
// cDomObject.getScrollOffset( hElement,'Left' )
cDomObject.getScrollOffset = function( hElement, sParam, hLimitParent )
{
nRes = 0
if( hLimitParent == null )
{
hLimitParent = document.body.parentElement
}
while( hElement != hLimitParent )
{
nRes += eval( 'hElement.scroll' + sParam )
if( !hElement.offsetParent ) { break }
hElement = hElement.parentNode
}
return nRes
}
|