summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/fancytooltips/examples/tex4ht/overlib_shadow.js
blob: b6b194e337bf872358fb296805f6b1fa71bb8ba2 (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
//\/////
//\  overLIB Shadow Plugin
//\  This file requires overLIB 4.10 or later.
//\
//\  overLIB 4.05 - You may not remove or change this notice.
//\  Copyright Erik Bosrup 1998-2003. All rights reserved.
//\  Contributors are listed on the homepage.
//\  See http://www.bosrup.com/web/overlib/ for details.
//   $Revision: 1.15 $                $Date: 2004/11/25 21:27:19 $
//\/////
//\mini

////////
// PRE-INIT
// Ignore these lines, configuration is below.
////////
if (typeof olInfo == 'undefined' || typeof olInfo.meets == 'undefined' || !olInfo.meets(4.10)) alert('overLIB 4.10 or later is required for the Shadow Plugin.');
else {
registerCommands('shadow,shadowcolor,shadowimage,shadowopacity,shadowx,shadowy');


////////
// DEFAULT CONFIGURATION
// You don't have to change anything here if you don't want to. All of this can be
// changed on your html page or through an overLIB call.
////////
if (typeof ol_shadowadjust=='undefined') var ol_shadowadjust=2;  // for Ns4.x only
if (typeof ol_shadow=='undefined') var ol_shadow=0;
if (typeof ol_shadowcolor=='undefined') var ol_shadowcolor='#CCCCCC';
if (typeof ol_shadowimage=='undefined') var  ol_shadowimage='';
if (typeof ol_shadowopacity=='undefined') var  ol_shadowopacity=0;
if (typeof ol_shadowx=='undefined') var ol_shadowx=5;
if (typeof ol_shadowy=='undefined') var ol_shadowy=5;

////////
// END OF CONFIGURATION
// Don't change anything below this line, all configuration is above.
////////




////////
// INIT
////////
// Runtime variables init. Don't change for config!
var o3_shadow=0;
var o3_shadowcolor="#cccccc";
var o3_shadowimage='';
var o3_shadowopacity=0;
var o3_shadowx=5;
var o3_shadowy=5;
var bkSet=0;  // Needed for this effect in NS4



// Function which sets runtime variables to their default values
function setShadowVariables() {
	o3_shadow=ol_shadow;
	o3_shadowcolor=ol_shadowcolor;
	o3_shadowimage=ol_shadowimage;
	o3_shadowopacity=ol_shadowopacity;
	o3_shadowx=ol_shadowx;
	o3_shadowy=ol_shadowy;
}


// Parses shadow commands
function parseShadowExtras(pf,i,ar) {
	var k = i, v;
	
	if (k < ar.length) {
		if (ar[k]==SHADOW) { eval(pf +'shadow=('+pf+'shadow==0) ? 1 : 0'); return k; }
		if (ar[k]==SHADOWCOLOR) { eval(pf+'shadowcolor="'+ar[++k]+'"'); return k; }
		if (ar[k]==SHADOWOPACITY) {v=ar[++k]; eval(pf+'shadowopacity='+(olOp ? 0 : v)); return k; }
		if (ar[k]==SHADOWIMAGE) { eval(pf+'shadowimage="'+ar[++k]+'"'); return k; }
		if (ar[k]==SHADOWX) { eval(pf+'shadowx='+ar[++k]); return k; }
		if (ar[k]==SHADOWY) { eval(pf+'shadowy='+ar[++k]); return k; }
	}
	
	return -1;
}


// Function for MOUSEOUT/MOUSEOFF feature with shadow
function shadow_cursorOff() {
	var left= parseInt(over.style.left);
	var top=parseInt(over.style.top);
	var right=left+(o3_shadow ? o3_width : over.offsetWidth);
	var bottom=top+(o3_shadow ? o3_aboveheight : over.offsetHeight);
	
	if (o3_x < left || o3_x > right || o3_y < top || o3_y > bottom) return true;
	return false;
}

// Pre-hide processing to clean-up.
function checkShadowPreHide() {
	if (o3_shadow && o3_shadowopacity) cleanUpShadowEffects();
	if (o3_shadow && (olIe4 && isMac) ) over.style.pixelWidth=over.style.pixelHeight = 0;
}


// Funciton that creates the actual shadow
function generateShadow(content) {
	var wd, ht, X = 0, Y = 0, zIdx = 0, txt, dpObj, puObj, bS= '', aPos, posStr=new Array();

	if (!o3_shadow || (o3_shadowx == 0 && o3_shadowy == 0)) return;

	X = Math.abs(o3_shadowx);
	Y = Math.abs(o3_shadowy);
	wd = parseInt(o3_width);
	ht = (olNs4) ? over.clip.height : over.offsetHeight;

	if (o3_shadowx == 0) {
		if (o3_shadowy < 0) {
		  posStr[0]=' left:0; top: 0';
		  posStr[1]=' left:0; top: '+Y+'px';
		} else if (o3_shadowy > 0) {
		  posStr[0]=' left:0; top: '+Y+'px';
		  posStr[1]=' left:0; top:0';
		}
	} else if (o3_shadowy == 0) {
		if (o3_shadowx < 0) {
		  posStr[0]=' left:0; top: 0';
		  posStr[1]=' left: '+X+'px';
		} else if (o3_shadowx > 0) {
		  posStr[0]=' left: '+ X+'px; top: 0';
		  posStr[1]=' left:0; top:0';
		}
	} else if (o3_shadowx > 0) {
		if (o3_shadowy > 0) {
		  posStr[0]=' left:'+ X+'px; top:'+Y+'px';
		  posStr[1]=' left:0; top:0';
		} else if (o3_shadowy < 0) {
		  posStr[0]=' left:'+X+'px; top:0';
		  posStr[1]=' left:0; top: '+Y+'px';
		}
	} else if (o3_shadowx < 0) {
		if (o3_shadowy > 0) {
		  posStr[0]=' left:0; top:'+Y+'px';
		  posStr[1]=' left:'+X+'px; top:0';
		} else if (o3_shadowy < 0) {
		  posStr[0]=' left:0; top:0';
		  posStr[1]=' left:'+X+'px; top:'+Y+'px';
		}
	}
	
	txt = (olNs4) ? '<div id="backdrop"></div>' : ((olIe55&&olHideForm) ? backDropSource(wd+X,ht+Y,zIdx++) : '') + '<div id="backdrop" style="position: absolute;'+posStr[0]+'; width: '+wd+'px; height: '+ht+'px; z-index: ' + (zIdx++) + '; ';

	if (o3_shadowimage) {
		bS='background-image: url('+o3_shadowimage+');';
		if (olNs4) bkSet=1;
	} else { 
		bS='background-color: '+o3_shadowcolor +';';
		if (olNs4) bkSet=2;
	}

	if (olNs4) {
		txt += '<div id="PUContent">'+content+'</div>';
	} else {
		txt += bS+'"></div><div id="PUContent" style="position: absolute;'+posStr[1]+'; width: '+ wd+'px; z-index: '+(zIdx++)+';">'+content+'</div>';
	}
	
	layerWrite(txt);

	if (olNs4 && bkSet) {
		dpObj = over.document.layers['backdrop'];
		if (typeof dpObj == 'undefined') return;  // if shadow layer not found, then content layer won't be either
		
		puObj = over.document.layers['PUContent'];
		wd = puObj.clip.width;
		ht = puObj.clip.height;
		aPos = posStr[0].split(';');
		
		dpObj.clip.width = wd;
		dpObj.clip.height = ht;
		dpObj.left = parseInt(aPos[0].split(':')[1]);
		dpObj.top = parseInt(aPos[1].split(':')[1]);
    
    dpObj.bgColor = (bkSet == 1) ? null : o3_shadowcolor;
		dpObj.background.src = (bkSet==2) ? null : o3_shadowimage;
		dpObj.zIndex = 0;

		aPos = posStr[1].split(';');
		puObj.left = parseInt(aPos[0].split(':')[1]);
		puObj.top = parseInt(aPos[1].split(':')[1]);
		puObj.zIndex = 1;
		
	} else {
		puObj = (olIe4 ? o3_frame.document.all['PUContent'] : o3_frame.document.getElementById('PUContent'));
		dpObj = (olIe4 ? o3_frame.document.all['backdrop'] : o3_frame.document.getElementById('backdrop'));
		ht = puObj.offsetHeight;
		dpObj.style.height = ht + 'px';
		
		if (o3_shadowopacity) {
			var op = o3_shadowopacity;
			op = (op <= 100 ? op : 100);
			
			setBrowserOpacity(op,dpObj);
		}
	} 

	// Set popup's new width and height values here so they are available in placeLayer()
	o3_width = wd+X;
	o3_aboveheight = ht+Y;
}


////////
// SUPPORT FUNCTIONS
////////

// Cleans up opacity settings if any.
function cleanUpShadowEffects() {
	if (olNs4 || olOp) return;
	var dpObj=(olIe4 ? o3_frame.document.all['backdrop'] : o3_frame.document.getElementById('backdrop'));
	cleanUpBrowserOpacity(dpObj);
}

// multi browser opacity support
function setBrowserOpacity(op,lyr){
	if (olNs4||!op) return;  // if Ns4.x or opacity not given return;
	lyr=(lyr) ? lyr : over;
	if (olIe4&&typeof lyr.filters != 'undefined') {
		lyr.style.filter='Alpha(Opacity='+op+')';
		lyr.filters.alpha.enabled=true;
	} else {
		var sOp=(typeof(lyr.style.MozOpacity)!='undefined') ? 'MozOpacity' : (typeof(lyr.style.KhtmlOpacity)!='undefined' ? 'KhtmlOpacity' : (typeof(lyr.style.opacity)!='undefined' ? 'opacity' : '')); 
		if (sOp) eval('lyr.style.'+sOp+'=op/100');
	}
}

// multi-browser Opacity cleanup
function cleanUpBrowserOpacity(lyr) {
	if (olNs4) return;
	lyr=(lyr) ? lyr : over;
	if (olIe4&&(typeof lyr.filters != 'undefined'&&lyr.filters.alpha.enabled)) {
		lyr.style.filter='Alpha(Opacity=100)';
		lyr.filters.alpha.enabled=false;
	} else {
		var sOp=(typeof(lyr.style.MozOpacity)!='undefined') ? 'MozOpacity' : (typeof(lyr.style.KhtmlOpacity)!='undefined' ? 'KhtmlOpacity' : (typeof(lyr.style.opacity)!='undefined' ? 'opacity' : '')); 
		if (sOp) eval('lyr.style.'+sOp+'=1.0');
	}
}

// This routine is needed only for Ns4.x to allow use of popups with dropshadows and CSSCLASS at the same time on a page
function shadowAdjust() {
	if (!olNs4) return;
	var fac = ol_shadowadjust;
	if (olNs4) {
		document.write('<style type="text/css">\n<!--\n');
		document.write('#backdrop, #PUContent {position: absolute; left: '+fac*o3_shadowx+'px; top: '+fac*o3_shadowy+'px; }\n');
		document.write('-->\n<' + '\/style>');
	}
}

////////
// PLUGIN REGISTRATIONS
////////
var before = (typeof rmrkPreface!='undefined' ? rmrkPreface : null);

registerRunTimeFunction(setShadowVariables);
registerCmdLineFunction(parseShadowExtras);
registerHook("cursorOff",shadow_cursorOff,FREPLACE);
registerHook("hideObject",checkShadowPreHide,FBEFORE);
registerHook("createPopup",generateShadow,FAFTER,before);
if (olInfo.meets(4.10)) registerNoParameterCommands('shadow');

if (olNs4) shadowAdjust();  // write style rules for proper support of Ns4.x
}