summaryrefslogtreecommitdiff
path: root/slides/browser/overlay.js
blob: fc010fbe968c5bbdda6bf5f256d7870e41689511 (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// -*- Java -*-
//
// Overlay.js, adapted from Floating image II on dynamicdrive.com
/* Usage:
<html>
<head>
<script LANGUAGE="JavaScript1.2" src="overlay.js"></script>
...rest of head...
</head>
<body onload="overlaySetup(corner)">
<div id="overlayDiv" STYLE="position:absolute;visibility:visible;">
...body of overlay...
</div>
...rest of page...
*/

var overlayNS4 = document.layers ? 1 : 0;
var overlayIE  = document.all ? 1 : 0;
var overlayNS6 = document.getElementById && !document.all ? 1 : 0;

var overlayPadX = 15;
var overlayPadY = 15;
var overlayDelay = 60;

var overlayCorner = 'ur'; // ul, ll, ur, lr, uc, lc, cl, cr

function overlayRefresh() {
    var overlayLx = 0;
    var overlayLy = 0;

    var overlayX = 0;
    var overlayY = 0;
    var overlayW = 0;
    var overlayH = 0;
    var contentH = 0;

    var links = document.getElementsByTagName("body")[0];

    if (overlayIE) {
	overlayLx = document.body.clientWidth;
	overlayLy = document.body.clientHeight;

	if (document.body.parentElement) {
	  // For IE6
	  overlayLx = document.body.parentElement.clientWidth;
          overlayLy = document.body.parentElement.clientHeight;
        }

	overlayH  = overlayDiv.offsetHeight;
	overlayW  = body.offsetWidth; // overlayDiv.offsetWidth;
	contentH  = body.offsetHeight;
    } else if (overlayNS4) {
	overlayLy = window.innerHeight;
	overlayLx = window.innerWidth;
	overlayH  = document.overlayDiv.clip.height;
	overlayW  = body.clip.width; // document.overlayDiv.clip.width;
	contentH  = body.clip.height;
    } else if (overlayNS6) {
	var odiv = document.getElementById('overlayDiv');

	overlayLy = window.innerHeight;
	overlayLx = window.innerWidth;
	overlayH  = odiv.offsetHeight;
	overlayW  = odiv.offsetWidth; // body.offsetWidth; 
	contentH  = odiv.offsetHeight;
    }

    if (overlayCorner == 'ul') {
	overlayX = overlayPadX;
	overlayY = overlayPadY;
    } else if (overlayCorner == 'cl') {
	overlayX = overlayPadX;
	overlayY = (overlayLy - overlayH) / 2;
    } else if (overlayCorner == 'll') {
	overlayX = overlayPadX;
	overlayY = (overlayLy - overlayH) - overlayPadY;
    } else if (overlayCorner == 'ur') {
	overlayX = (overlayLx - overlayW) - overlayPadX;
	overlayY = overlayPadY;
    } else if (overlayCorner == 'cr') {
	overlayX = (overlayLx - overlayW) - overlayPadX;
	overlayY = (overlayLy - overlayH) / 2;
    } else if (overlayCorner == 'lr') {
	overlayX = (overlayLx - overlayW) - overlayPadX;
	overlayY = (overlayLy - overlayH) - overlayPadY;
    } else if (overlayCorner == 'uc') {
	overlayX = (overlayLx - overlayW) / 2;
	overlayY = overlayPadY;
    } else { // overlayCorner == 'lc'
	overlayX = (overlayLx - overlayW) / 2;
	overlayY = (overlayLy - overlayH) - overlayPadY;
    }

    if (overlayIE) {
	overlayDiv.style.left=overlayX;
	overlayDiv.style.top=overlayY+document.body.scrollTop;

	if (contentH > overlayLy) {
	    overlayDiv.style.visibility = "hidden";
	}
    } else if (overlayNS4) {
	document.overlayDiv.pageX=overlayX;
	document.overlayDiv.pageY=overlayY+window.pageYOffset;
	document.overlayDiv.visibility="visible";

	if (contentH > overlayLy) {
	    document.overlayDiv.style.visibility = "hidden";
	}
    } else if (overlayNS6) {
	var div = document.getElementById("overlayDiv");
	var leftpx = overlayX;
	var toppx = overlayY+window.pageYOffset;
	var widthpx = overlayW;

	div.style.left = leftpx + "px";
	div.style.top = toppx + "px";
	div.style.width = widthpx + "px";

	if (contentH > overlayLy) {
	    div.style.visibility = "hidden";
	} else {
	    div.style.visibility = "visible";
	}
    }
}

function onad() {
    loopfunc();
}

function loopfunc() {
    overlayRefresh();
    setTimeout('loopfunc()',overlayDelay);
}

function overlaySetup(corner) {
    overlayCorner = corner;

    if (overlayIE || overlayNS4 || overlayNS6) {
	onad();
    }
}