PageSourceSearch

https://aurelienbaro.fr/overlib400/overlib_shadow.js

js aurelienbaro.fr collected 2026-10-04 03:47:55 UTC 8,573 bytes, 269 lines download raw bytes

1//\/////
2//\  overLIB Shadow Plugin
3//\  This file requires overLIB 4.21 or later.
4//\
5//\  overLIB 4.21 - You may not remove or change this notice.
6//\  Copyright Erik Bosrup 1998-2003. All rights reserved.
7//\  Contributors are listed on the homepage.
8//\  See http://www.bosrup.com/web/overlib/ for details.
9//   $Revision: 1.15 $                $Date: 2004/11/25 21:27:19 $
10//\/////
11//\mini
12
13////////
14// PRE-INIT
15// Ignore these lines, configuration is below.
16////////
17{
18registerCommands('shadow,shadowcolor,shadowimage,shadowopacity,shadowx,shadowy');
19
20
21////////
22// DEFAULT CONFIGURATION
23// You don't have to change anything here if you don't want to. All of this can be
24// changed on your html page or through an overLIB call.
25////////
26if (typeof ol_shadowadjust=='undefined') var ol_shadowadjust=2;  // for Ns4.x only
27if (typeof ol_shadow=='undefined') var ol_shadow=0;
28if (typeof ol_shadowcolor=='undefined') var ol_shadowcolor='#CCCCCC';
29if (typeof ol_shadowimage=='undefined') var  ol_shadowimage='';
30if (typeof ol_shadowopacity=='undefined') var  ol_shadowopacity=0;
31if (typeof ol_shadowx=='undefined') var ol_shadowx=5;
32if (typeof ol_shadowy=='undefined') var ol_shadowy=5;
33
34////////
35// END OF CONFIGURATION
36// Don't change anything below this line, all configuration is above.
37////////
38
39
40
41
42////////
43// INIT
44////////
45// Runtime variables init. Don't change for config!
46var o3_shadow=0;
47var o3_shadowcolor="#cccccc";
48var o3_shadowimage='';
49var o3_shadowopacity=0;
50var o3_shadowx=5;
51var o3_shadowy=5;
52var bkSet=0;  // Needed for this effect in NS4
53
54
55
56// Function which sets runtime variables to their default values
57function setShadowVariables() {
58	o3_shadow=ol_shadow;
59	o3_shadowcolor=ol_shadowcolor;
60	o3_shadowimage=ol_shadowimage;
61	o3_shadowopacity=ol_shadowopacity;
62	o3_shadowx=ol_shadowx;
63	o3_shadowy=ol_shadowy;
64}
65
66
67// Parses shadow commands
68function parseShadowExtras(pf,i,ar) {
69	var k = i, v;
70	
71	if (k < ar.length) {
72		if (ar[k]==SHADOW) { eval(pf +'shadow=('+pf+'shadow==0) ? 1 : 0'); return k; }
73		if (ar[k]==SHADOWCOLOR) { eval(pf+'shadowcolor="'+ar[++k]+'"'); return k; }
74		if (ar[k]==SHADOWOPACITY) {v=ar[++k]; eval(pf+'shadowopacity='+(olOp ? 0 : v)); return k; }
75		if (ar[k]==SHADOWIMAGE) { eval(pf+'shadowimage="'+ar[++k]+'"'); return k; }
76		if (ar[k]==SHADOWX) { eval(pf+'shadowx='+ar[++k]); return k; }
77		if (ar[k]==SHADOWY) { eval(pf+'shadowy='+ar[++k]); return k; }
78	}
79	
80	return -1;
81}
82
83
84// Function for MOUSEOUT/MOUSEOFF feature with shadow
85function shadow_cursorOff() {
86	var left= parseInt(over.style.left);
87	var top=parseInt(over.style.top);
88	var right=left+(o3_shadow ? o3_width : over.offsetWidth);
89	var bottom=top+(o3_shadow ? o3_aboveheight : over.offsetHeight);
90	
91	if (o3_x < left || o3_x > right || o3_y < top || o3_y > bottom) return true;
92	return false;
93}
94
95// Pre-hide processing to clean-up.
96function checkShadowPreHide() {
97	if (o3_shadow && o3_shadowopacity) cleanUpShadowEffects();
98	if (o3_shadow && (olIe4 && isMac) ) over.style.pixelWidth=over.style.pixelHeight = 0;
99}
100
101
102// Funciton that creates the actual shadow
103function generateShadow(content) {
104	var wd, ht, X = 0, Y = 0, zIdx = 0, txt, dpObj, puObj, bS= '', aPos, posStr=new Array();
105
106	if (!o3_shadow || (o3_shadowx == 0 && o3_shadowy == 0)) return;
107
108	X = Math.abs(o3_shadowx);
109	Y = Math.abs(o3_shadowy);
110	wd = parseInt(o3_width);
111	ht = (olNs4) ? over.clip.height : over.offsetHeight;
112
113	if (o3_shadowx == 0) {
114		if (o3_shadowy < 0) {
115		  posStr[0]=' left:0; top: 0';
116		  posStr[1]=' left:0; top: '+Y+'px';
117		} else if (o3_shadowy > 0) {
118		  posStr[0]=' left:0; top: '+Y+'px';
119		  posStr[1]=' left:0; top:0';
120		}
121	} else if (o3_shadowy == 0) {
122		if (o3_shadowx < 0) {
123		  posStr[0]=' left:0; top: 0';
124		  posStr[1]=' left: '+X+'px';
125		} else if (o3_shadowx > 0) {
126		  posStr[0]=' left: '+ X+'px; top: 0';
127		  posStr[1]=' left:0; top:0';
128		}
129	} else if (o3_shadowx > 0) {
130		if (o3_shadowy > 0) {
131		  posStr[0]=' left:'+ X+'px; top:'+Y+'px';
132		  posStr[1]=' left:0; top:0';
133		} else if (o3_shadowy < 0) {
134		  posStr[0]=' left:'+X+'px; top:0';
135		  posStr[1]=' left:0; top: '+Y+'px';
136		}
137	} else if (o3_shadowx < 0) {
138		if (o3_shadowy > 0) {
139		  posStr[0]=' left:0; top:'+Y+'px';
140		  posStr[1]=' left:'+X+'px; top:0';
141		} else if (o3_shadowy < 0) {
142		  posStr[0]=' left:0; top:0';
143		  posStr[1]=' left:'+X+'px; top:'+Y+'px';
144		}
145	}
146	
147	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++) + '; ';
148
149	if (o3_shadowimage) {
150		bS='background-image: url('+o3_shadowimage+');';
151		if (olNs4) bkSet=1;
152	} else { 
153		bS='background-color: '+o3_shadowcolor +';';
154		if (olNs4) bkSet=2;
155	}
156
157	if (olNs4) {
158		txt += '<div id="PUContent">'+content+'</div>';
159	} else {
160		txt += bS+'"></div><div id="PUContent" style="position: absolute;'+posStr[1]+'; width: '+ wd+'px; z-index: '+(zIdx++)+';">'+content+'</div>';
161	}
162	
163	layerWrite(txt);
164
165	if (olNs4 && bkSet) {
166		dpObj = over.document.layers['backdrop'];
167		if (typeof dpObj == 'undefined') return;  // if shadow layer not found, then content layer won't be either
168		
169		puObj = over.document.layers['PUContent'];
170		wd = puObj.clip.width;
171		ht = puObj.clip.height;
172		aPos = posStr[0].split(';');
173		
174		dpObj.clip.width = wd;
175		dpObj.clip.height = ht;
176		dpObj.left = parseInt(aPos[0].split(':')[1]);
177		dpObj.top = parseInt(aPos[1].split(':')[1]);
178    
179    dpObj.bgColor = (bkSet == 1) ? null : o3_shadowcolor;
180		dpObj.background.src = (bkSet==2) ? null : o3_shadowimage;
181		dpObj.zIndex = 0;
182
183		aPos = posStr[1].split(';');
184		puObj.left = parseInt(aPos[0].split(':')[1]);
185		puObj.top = parseInt(aPos[1].split(':')[1]);
186		puObj.zIndex = 1;
187		
188	} else {
189		puObj = (olIe4 ? o3_frame.document.all['PUContent'] : o3_frame.document.getElementById('PUContent'));
190		dpObj = (olIe4 ? o3_frame.document.all['backdrop'] : o3_frame.document.getElementById('backdrop'));
191		ht = puObj.offsetHeight;
192		dpObj.style.height = ht + 'px';
193		
194		if (o3_shadowopacity) {
195			var op = o3_shadowopacity;
196			op = (op <= 100 ? op : 100);
197			
198			setBrowserOpacity(op,dpObj);
199		}
200	} 
201
202	// Set popup's new width and height values here so they are available in placeLayer()
203	o3_width = wd+X;
204	o3_aboveheight = ht+Y;
205}
206
207
208////////
209// SUPPORT FUNCTIONS
210////////
211
212// Cleans up opacity settings if any.
213function cleanUpShadowEffects() {
214	if (olNs4 || olOp) return;
215	var dpObj=(olIe4 ? o3_frame.document.all['backdrop'] : o3_frame.document.getElementById('backdrop'));
216	cleanUpBrowserOpacity(dpObj);
217}
218
219// multi browser opacity support
220function setBrowserOpacity(op,lyr){
221	if (olNs4||!op) return;  // if Ns4.x or opacity not given return;
222	lyr=(lyr) ? lyr : over;
223	if (olIe4&&typeof lyr.filters != 'undefined') {
224		lyr.style.filter='Alpha(Opacity='+op+')';
225		lyr.filters.alpha.enabled=true;
226	} else {
227		var sOp=(typeof(lyr.style.MozOpacity)!='undefined') ? 'MozOpacity' : (typeof(lyr.style.KhtmlOpacity)!='undefined' ? 'KhtmlOpacity' : (typeof(lyr.style.opacity)!='undefined' ? 'opacity' : '')); 
228		if (sOp) eval('lyr.style.'+sOp+'=op/100');
229	}
230}
231
232// multi-browser Opacity cleanup
233function cleanUpBrowserOpacity(lyr) {
234	if (olNs4) return;
235	lyr=(lyr) ? lyr : over;
236	if (olIe4&&(typeof lyr.filters != 'undefined'&&lyr.filters.alpha.enabled)) {
237		lyr.style.filter='Alpha(Opacity=100)';
238		lyr.filters.alpha.enabled=false;
239	} else {
240		var sOp=(typeof(lyr.style.MozOpacity)!='undefined') ? 'MozOpacity' : (typeof(lyr.style.KhtmlOpacity)!='undefined' ? 'KhtmlOpacity' : (typeof(lyr.style.opacity)!='undefined' ? 'opacity' : '')); 
241		if (sOp) eval('lyr.style.'+sOp+'=1.0');
242	}
243}
244
245// This routine is needed only for Ns4.x to allow use of popups with dropshadows and CSSCLASS at the same time on a page
246function shadowAdjust() {
247	if (!olNs4) return;
248	var fac = ol_shadowadjust;
249	if (olNs4) {
250		document.write('<style type="text/css">\n<!--\n');
251		document.write('#backdrop, #PUContent {position: absolute; left: '+fac*o3_shadowx+'px; top: '+fac*o3_shadowy+'px; }\n');
252		document.write('-->\n<' + '\/style>');
253	}
254}
255
256////////
257// PLUGIN REGISTRATIONS
258////////
259var before = (typeof rmrkPreface!='undefined' ? rmrkPreface : null);
260
261registerRunTimeFunction(setShadowVariables);
262registerCmdLineFunction(parseShadowExtras);
263registerHook("cursorOff",shadow_cursorOff,FREPLACE);
264registerHook("hideObject",checkShadowPreHide,FBEFORE);
265registerHook("createPopup",generateShadow,FAFTER,before);
266if (olInfo.meets(4.21)) registerNoParameterCommands('shadow');
267
268if (olNs4) shadowAdjust();  // write style rules for proper support of Ns4.x
269}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.