2 //\ overLIB Center Popup Plugin
3 //\ This file requires overLIB 4.10 or later.
5 //\ overLIB 4.10 - 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.
15 // Ignore these lines, configuration is below.
17 if (typeof olInfo
== 'undefined' || typeof olInfo
.meets
== 'undefined' || !olInfo
.meets(4.10)) alert('overLIB 4.10 or later is required for the Center Popup Plugin.');
19 registerCommands('centerpopup,centeroffset');
21 // DEFAULT CONFIGURATION
22 // You don't have to change anything here if you don't want to. All of this can be
23 // changed on your html page or through an overLIB call.
25 // Default value for centerpopup is to not center the popup
26 if (typeof ol_centerpopup
== 'undefined') var ol_centerpopup
= 0;
27 if (typeof ol_centeroffset
== 'undefined') var ol_centeroffset
= '0';
29 // END OF CONFIGURATION
30 // Don't change anything below this line, all configuration is above.
35 // Runtime variables init. Don't change for config!
36 var o3_centerpopup
= 0;
37 var o3_centeroffset
= '0';
41 function setCenterPopupVariables() {
42 o3_centerpopup
= ol_centerpopup
;
43 o3_centeroffset
= ol_centeroffset
;
45 // Parses Shadow and Scroll commands
46 function parseCenterPopupExtras(pf
,i
,ar
) {
50 if (ar
[k
] == CENTERPOPUP
) { eval(pf
+ 'centerpopup = (' + pf
+ 'centerpopup == 0) ? 1 : 0'); return k
; }
51 if (ar
[k
] == CENTEROFFSET
) { k
= opt_MULTIPLEARGS(++k
,ar
,(pf
+ 'centeroffset')); return k
; }
56 // Function which positions popup in Center of screen
57 function centerPopupHorizontal(browserWidth
, horizontalScrollAmount
, widthFix
) {
58 if (!o3_centerpopup
) return void(0);
60 var vdisp
= o3_centeroffset
.split(',');
61 var placeX
, iwidth
= browserWidth
, winoffset
= horizontalScrollAmount
;
62 var pWd
= parseInt(o3_width
);
64 placeX
= winoffset
+ Math
.round((iwidth
- widthFix
- pWd
)/2) + parseInt(vdisp
[0]);
65 if(typeof o3_followscroll
!= 'undefined' && o3_followscroll
&& o3_sticky
) o3_relx
= placeX
;
69 function centerPopupVertical(browserHeight
,verticalScrollAmount
) {
70 if (!o3_centerpopup
) return void(0);
72 var placeY
, iheight
= browserHeight
, scrolloffset
= verticalScrollAmount
;
73 var vdisp
= o3_centeroffset
.split(',');
74 var pHeight
= (o3_aboveheight
? parseInt(o3_aboveheight
) : (olNs4
? over
.clip
.height
: over
.offsetHeight
));
76 placeY
= scrolloffset
+ Math
.round((iheight
- pHeight
)/2) + (vdisp
.length
> 1 ? parseInt(vdisp
[1]) : 0);
77 if(typeof o3_followscroll
!= 'undefined' && o3_followscroll
&& o3_sticky
) o3_rely
= placeY
;
82 // PLUGIN REGISTRATIONS
84 registerRunTimeFunction(setCenterPopupVariables
);
85 registerCmdLineFunction(parseCenterPopupExtras
);
86 registerHook('horizontalPlacement',centerPopupHorizontal
,FCHAIN
);
87 registerHook('verticalPlacement', centerPopupVertical
, FCHAIN
);
88 if(olInfo
.meets(4.10)) registerNoParameterCommands('centerpopup');