1
|
//\/////
|
2
|
|
3
|
//\ overLIB Shadow Plugin
|
4
|
|
5
|
//\ This file requires overLIB 4.10 or later.
|
6
|
|
7
|
//\
|
8
|
|
9
|
//\ overLIB 4.05 - You may not remove or change this notice.
|
10
|
|
11
|
//\ Copyright Erik Bosrup 1998-2003. All rights reserved.
|
12
|
|
13
|
//\ Contributors are listed on the homepage.
|
14
|
|
15
|
//\ See http://www.bosrup.com/web/overlib/ for details.
|
16
|
|
17
|
// $Revision$ $Date$
|
18
|
|
19
|
//\/////
|
20
|
|
21
|
//\mini
|
22
|
|
23
|
|
24
|
|
25
|
////////
|
26
|
|
27
|
// PRE-INIT
|
28
|
|
29
|
// Ignore these lines, configuration is below.
|
30
|
|
31
|
////////
|
32
|
|
33
|
if (typeof olInfo == 'undefined' || typeof olInfo.meets == 'undefined' || !olInfo.meets(4.10)) alert('overLIB 4.10 or later is required for the Shadow Plugin.');
|
34
|
|
35
|
else {
|
36
|
|
37
|
registerCommands('shadow,shadowcolor,shadowimage,shadowopacity,shadowx,shadowy');
|
38
|
|
39
|
|
40
|
|
41
|
|
42
|
|
43
|
////////
|
44
|
|
45
|
// DEFAULT CONFIGURATION
|
46
|
|
47
|
// You don't have to change anything here if you don't want to. All of this can be
|
48
|
|
49
|
// changed on your html page or through an overLIB call.
|
50
|
|
51
|
////////
|
52
|
|
53
|
if (typeof ol_shadowadjust=='undefined') var ol_shadowadjust=2; // for Ns4.x only
|
54
|
|
55
|
if (typeof ol_shadow=='undefined') var ol_shadow=0;
|
56
|
|
57
|
if (typeof ol_shadowcolor=='undefined') var ol_shadowcolor='#CCCCCC';
|
58
|
|
59
|
if (typeof ol_shadowimage=='undefined') var ol_shadowimage='';
|
60
|
|
61
|
if (typeof ol_shadowopacity=='undefined') var ol_shadowopacity=0;
|
62
|
|
63
|
if (typeof ol_shadowx=='undefined') var ol_shadowx=5;
|
64
|
|
65
|
if (typeof ol_shadowy=='undefined') var ol_shadowy=5;
|
66
|
|
67
|
|
68
|
|
69
|
////////
|
70
|
|
71
|
// END OF CONFIGURATION
|
72
|
|
73
|
// Don't change anything below this line, all configuration is above.
|
74
|
|
75
|
////////
|
76
|
|
77
|
|
78
|
|
79
|
|
80
|
|
81
|
|
82
|
|
83
|
|
84
|
|
85
|
////////
|
86
|
|
87
|
// INIT
|
88
|
|
89
|
////////
|
90
|
|
91
|
// Runtime variables init. Don't change for config!
|
92
|
|
93
|
var o3_shadow=0;
|
94
|
|
95
|
var o3_shadowcolor="#cccccc";
|
96
|
|
97
|
var o3_shadowimage='';
|
98
|
|
99
|
var o3_shadowopacity=0;
|
100
|
|
101
|
var o3_shadowx=5;
|
102
|
|
103
|
var o3_shadowy=5;
|
104
|
|
105
|
var bkSet=0; // Needed for this effect in NS4
|
106
|
|
107
|
|
108
|
|
109
|
|
110
|
|
111
|
|
112
|
|
113
|
// Function which sets runtime variables to their default values
|
114
|
|
115
|
function setShadowVariables() {
|
116
|
|
117
|
o3_shadow=ol_shadow;
|
118
|
|
119
|
o3_shadowcolor=ol_shadowcolor;
|
120
|
|
121
|
o3_shadowimage=ol_shadowimage;
|
122
|
|
123
|
o3_shadowopacity=ol_shadowopacity;
|
124
|
|
125
|
o3_shadowx=ol_shadowx;
|
126
|
|
127
|
o3_shadowy=ol_shadowy;
|
128
|
|
129
|
}
|
130
|
|
131
|
|
132
|
|
133
|
|
134
|
|
135
|
// Parses shadow commands
|
136
|
|
137
|
function parseShadowExtras(pf,i,ar) {
|
138
|
|
139
|
var k = i, v;
|
140
|
|
141
|
|
142
|
|
143
|
if (k < ar.length) {
|
144
|
|
145
|
if (ar[k]==SHADOW) { eval(pf +'shadow=('+pf+'shadow==0) ? 1 : 0'); return k; }
|
146
|
|
147
|
if (ar[k]==SHADOWCOLOR) { eval(pf+'shadowcolor="'+ar[++k]+'"'); return k; }
|
148
|
|
149
|
if (ar[k]==SHADOWOPACITY) {v=ar[++k]; eval(pf+'shadowopacity='+(olOp ? 0 : v)); return k; }
|
150
|
|
151
|
if (ar[k]==SHADOWIMAGE) { eval(pf+'shadowimage="'+ar[++k]+'"'); return k; }
|
152
|
|
153
|
if (ar[k]==SHADOWX) { eval(pf+'shadowx='+ar[++k]); return k; }
|
154
|
|
155
|
if (ar[k]==SHADOWY) { eval(pf+'shadowy='+ar[++k]); return k; }
|
156
|
|
157
|
}
|
158
|
|
159
|
|
160
|
|
161
|
return -1;
|
162
|
|
163
|
}
|
164
|
|
165
|
|
166
|
|
167
|
|
168
|
|
169
|
// Function for MOUSEOUT/MOUSEOFF feature with shadow
|
170
|
|
171
|
function shadow_cursorOff() {
|
172
|
|
173
|
var left= parseInt(over.style.left);
|
174
|
|
175
|
var top=parseInt(over.style.top);
|
176
|
|
177
|
var right=left+(o3_shadow ? o3_width : over.offsetWidth);
|
178
|
|
179
|
var bottom=top+(o3_shadow ? o3_aboveheight : over.offsetHeight);
|
180
|
|
181
|
|
182
|
|
183
|
if (o3_x < left || o3_x > right || o3_y < top || o3_y > bottom) return true;
|
184
|
|
185
|
return false;
|
186
|
|
187
|
}
|
188
|
|
189
|
|
190
|
|
191
|
// Pre-hide processing to clean-up.
|
192
|
|
193
|
function checkShadowPreHide() {
|
194
|
|
195
|
if (o3_shadow && o3_shadowopacity) cleanUpShadowEffects();
|
196
|
|
197
|
if (o3_shadow && (olIe4 && isMac) ) over.style.pixelWidth=over.style.pixelHeight = 0;
|
198
|
|
199
|
}
|
200
|
|
201
|
|
202
|
|
203
|
|
204
|
|
205
|
// Funciton that creates the actual shadow
|
206
|
|
207
|
function generateShadow(content) {
|
208
|
|
209
|
var wd, ht, X = 0, Y = 0, zIdx = 0, txt, dpObj, puObj, bS= '', aPos, posStr=new Array();
|
210
|
|
211
|
|
212
|
|
213
|
if (!o3_shadow || (o3_shadowx == 0 && o3_shadowy == 0)) return;
|
214
|
|
215
|
|
216
|
|
217
|
X = Math.abs(o3_shadowx);
|
218
|
|
219
|
Y = Math.abs(o3_shadowy);
|
220
|
|
221
|
wd = parseInt(o3_width);
|
222
|
|
223
|
ht = (olNs4) ? over.clip.height : over.offsetHeight;
|
224
|
|
225
|
|
226
|
|
227
|
if (o3_shadowx == 0) {
|
228
|
|
229
|
if (o3_shadowy < 0) {
|
230
|
|
231
|
posStr[0]=' left:0; top: 0';
|
232
|
|
233
|
posStr[1]=' left:0; top: '+Y+'px';
|
234
|
|
235
|
} else if (o3_shadowy > 0) {
|
236
|
|
237
|
posStr[0]=' left:0; top: '+Y+'px';
|
238
|
|
239
|
posStr[1]=' left:0; top:0';
|
240
|
|
241
|
}
|
242
|
|
243
|
} else if (o3_shadowy == 0) {
|
244
|
|
245
|
if (o3_shadowx < 0) {
|
246
|
|
247
|
posStr[0]=' left:0; top: 0';
|
248
|
|
249
|
posStr[1]=' left: '+X+'px';
|
250
|
|
251
|
} else if (o3_shadowx > 0) {
|
252
|
|
253
|
posStr[0]=' left: '+ X+'px; top: 0';
|
254
|
|
255
|
posStr[1]=' left:0; top:0';
|
256
|
|
257
|
}
|
258
|
|
259
|
} else if (o3_shadowx > 0) {
|
260
|
|
261
|
if (o3_shadowy > 0) {
|
262
|
|
263
|
posStr[0]=' left:'+ X+'px; top:'+Y+'px';
|
264
|
|
265
|
posStr[1]=' left:0; top:0';
|
266
|
|
267
|
} else if (o3_shadowy < 0) {
|
268
|
|
269
|
posStr[0]=' left:'+X+'px; top:0';
|
270
|
|
271
|
posStr[1]=' left:0; top: '+Y+'px';
|
272
|
|
273
|
}
|
274
|
|
275
|
} else if (o3_shadowx < 0) {
|
276
|
|
277
|
if (o3_shadowy > 0) {
|
278
|
|
279
|
posStr[0]=' left:0; top:'+Y+'px';
|
280
|
|
281
|
posStr[1]=' left:'+X+'px; top:0';
|
282
|
|
283
|
} else if (o3_shadowy < 0) {
|
284
|
|
285
|
posStr[0]=' left:0; top:0';
|
286
|
|
287
|
posStr[1]=' left:'+X+'px; top:'+Y+'px';
|
288
|
|
289
|
}
|
290
|
|
291
|
}
|
292
|
|
293
|
|
294
|
|
295
|
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++) + '; ';
|
296
|
|
297
|
|
298
|
|
299
|
if (o3_shadowimage) {
|
300
|
|
301
|
bS='background-image: url('+o3_shadowimage+');';
|
302
|
|
303
|
if (olNs4) bkSet=1;
|
304
|
|
305
|
} else {
|
306
|
|
307
|
bS='background-color: '+o3_shadowcolor +';';
|
308
|
|
309
|
if (olNs4) bkSet=2;
|
310
|
|
311
|
}
|
312
|
|
313
|
|
314
|
|
315
|
if (olNs4) {
|
316
|
|
317
|
txt += '<div id="PUContent">'+content+'</div>';
|
318
|
|
319
|
} else {
|
320
|
|
321
|
txt += bS+'"></div><div id="PUContent" style="position: absolute;'+posStr[1]+'; width: '+ wd+'px; z-index: '+(zIdx++)+';">'+content+'</div>';
|
322
|
|
323
|
}
|
324
|
|
325
|
|
326
|
|
327
|
layerWrite(txt);
|
328
|
|
329
|
|
330
|
|
331
|
if (olNs4 && bkSet) {
|
332
|
|
333
|
dpObj = over.document.layers['backdrop'];
|
334
|
|
335
|
if (typeof dpObj == 'undefined') return; // if shadow layer not found, then content layer won't be either
|
336
|
|
337
|
|
338
|
|
339
|
puObj = over.document.layers['PUContent'];
|
340
|
|
341
|
wd = puObj.clip.width;
|
342
|
|
343
|
ht = puObj.clip.height;
|
344
|
|
345
|
aPos = posStr[0].split(';');
|
346
|
|
347
|
|
348
|
|
349
|
dpObj.clip.width = wd;
|
350
|
|
351
|
dpObj.clip.height = ht;
|
352
|
|
353
|
dpObj.left = parseInt(aPos[0].split(':')[1]);
|
354
|
|
355
|
dpObj.top = parseInt(aPos[1].split(':')[1]);
|
356
|
|
357
|
|
358
|
|
359
|
dpObj.bgColor = (bkSet == 1) ? null : o3_shadowcolor;
|
360
|
|
361
|
dpObj.background.src = (bkSet==2) ? null : o3_shadowimage;
|
362
|
|
363
|
dpObj.zIndex = 0;
|
364
|
|
365
|
|
366
|
|
367
|
aPos = posStr[1].split(';');
|
368
|
|
369
|
puObj.left = parseInt(aPos[0].split(':')[1]);
|
370
|
|
371
|
puObj.top = parseInt(aPos[1].split(':')[1]);
|
372
|
|
373
|
puObj.zIndex = 1;
|
374
|
|
375
|
|
376
|
|
377
|
} else {
|
378
|
|
379
|
puObj = (olIe4 ? o3_frame.document.all['PUContent'] : o3_frame.document.getElementById('PUContent'));
|
380
|
|
381
|
dpObj = (olIe4 ? o3_frame.document.all['backdrop'] : o3_frame.document.getElementById('backdrop'));
|
382
|
|
383
|
ht = puObj.offsetHeight;
|
384
|
|
385
|
dpObj.style.height = ht + 'px';
|
386
|
|
387
|
|
388
|
|
389
|
if (o3_shadowopacity) {
|
390
|
|
391
|
var op = o3_shadowopacity;
|
392
|
|
393
|
op = (op <= 100 ? op : 100);
|
394
|
|
395
|
|
396
|
|
397
|
setBrowserOpacity(op,dpObj);
|
398
|
|
399
|
}
|
400
|
|
401
|
}
|
402
|
|
403
|
|
404
|
|
405
|
// Set popup's new width and height values here so they are available in placeLayer()
|
406
|
|
407
|
o3_width = wd+X;
|
408
|
|
409
|
o3_aboveheight = ht+Y;
|
410
|
|
411
|
}
|
412
|
|
413
|
|
414
|
|
415
|
|
416
|
|
417
|
////////
|
418
|
|
419
|
// SUPPORT FUNCTIONS
|
420
|
|
421
|
////////
|
422
|
|
423
|
|
424
|
|
425
|
// Cleans up opacity settings if any.
|
426
|
|
427
|
function cleanUpShadowEffects() {
|
428
|
|
429
|
if (olNs4 || olOp) return;
|
430
|
|
431
|
var dpObj=(olIe4 ? o3_frame.document.all['backdrop'] : o3_frame.document.getElementById('backdrop'));
|
432
|
|
433
|
cleanUpBrowserOpacity(dpObj);
|
434
|
|
435
|
}
|
436
|
|
437
|
|
438
|
|
439
|
// multi browser opacity support
|
440
|
|
441
|
function setBrowserOpacity(op,lyr){
|
442
|
|
443
|
if (olNs4||!op) return; // if Ns4.x or opacity not given return;
|
444
|
|
445
|
lyr=(lyr) ? lyr : over;
|
446
|
|
447
|
if (olIe4&&typeof lyr.filters != 'undefined') {
|
448
|
|
449
|
lyr.style.filter='Alpha(Opacity='+op+')';
|
450
|
|
451
|
lyr.filters.alpha.enabled=true;
|
452
|
|
453
|
} else {
|
454
|
|
455
|
var sOp=(typeof(lyr.style.MozOpacity)!='undefined') ? 'MozOpacity' : (typeof(lyr.style.KhtmlOpacity)!='undefined' ? 'KhtmlOpacity' : (typeof(lyr.style.opacity)!='undefined' ? 'opacity' : ''));
|
456
|
|
457
|
if (sOp) eval('lyr.style.'+sOp+'=op/100');
|
458
|
|
459
|
}
|
460
|
|
461
|
}
|
462
|
|
463
|
|
464
|
|
465
|
// multi-browser Opacity cleanup
|
466
|
|
467
|
function cleanUpBrowserOpacity(lyr) {
|
468
|
|
469
|
if (olNs4) return;
|
470
|
|
471
|
lyr=(lyr) ? lyr : over;
|
472
|
|
473
|
if (olIe4&&(typeof lyr.filters != 'undefined'&&lyr.filters.alpha.enabled)) {
|
474
|
|
475
|
lyr.style.filter='Alpha(Opacity=100)';
|
476
|
|
477
|
lyr.filters.alpha.enabled=false;
|
478
|
|
479
|
} else {
|
480
|
|
481
|
var sOp=(typeof(lyr.style.MozOpacity)!='undefined') ? 'MozOpacity' : (typeof(lyr.style.KhtmlOpacity)!='undefined' ? 'KhtmlOpacity' : (typeof(lyr.style.opacity)!='undefined' ? 'opacity' : ''));
|
482
|
|
483
|
if (sOp) eval('lyr.style.'+sOp+'=1.0');
|
484
|
|
485
|
}
|
486
|
|
487
|
}
|
488
|
|
489
|
|
490
|
|
491
|
// This routine is needed only for Ns4.x to allow use of popups with dropshadows and CSSCLASS at the same time on a page
|
492
|
|
493
|
function shadowAdjust() {
|
494
|
|
495
|
if (!olNs4) return;
|
496
|
|
497
|
var fac = ol_shadowadjust;
|
498
|
|
499
|
if (olNs4) {
|
500
|
|
501
|
document.write('<style type="text/css">\n<!--\n');
|
502
|
|
503
|
document.write('#backdrop, #PUContent {position: absolute; left: '+fac*o3_shadowx+'px; top: '+fac*o3_shadowy+'px; }\n');
|
504
|
|
505
|
document.write('-->\n<' + '\/style>');
|
506
|
|
507
|
}
|
508
|
|
509
|
}
|
510
|
|
511
|
|
512
|
|
513
|
////////
|
514
|
|
515
|
// PLUGIN REGISTRATIONS
|
516
|
|
517
|
////////
|
518
|
|
519
|
var before = (typeof rmrkPreface!='undefined' ? rmrkPreface : null);
|
520
|
|
521
|
|
522
|
|
523
|
registerRunTimeFunction(setShadowVariables);
|
524
|
|
525
|
registerCmdLineFunction(parseShadowExtras);
|
526
|
|
527
|
registerHook("cursorOff",shadow_cursorOff,FREPLACE);
|
528
|
|
529
|
registerHook("hideObject",checkShadowPreHide,FBEFORE);
|
530
|
|
531
|
registerHook("createPopup",generateShadow,FAFTER,before);
|
532
|
|
533
|
if (olInfo.meets(4.10)) registerNoParameterCommands('shadow');
|
534
|
|
535
|
|
536
|
|
537
|
if (olNs4) shadowAdjust(); // write style rules for proper support of Ns4.x
|
538
|
|
539
|
}
|