1
|
//\/////
|
2
|
|
3
|
//\ overLIB Center Popup Plugin
|
4
|
|
5
|
//\ This file requires overLIB 4.10 or later.
|
6
|
|
7
|
//\
|
8
|
|
9
|
//\ overLIB 4.10 - 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
|
//\/////
|
22
|
|
23
|
//\mini
|
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 Center Popup Plugin.');
|
34
|
|
35
|
else {
|
36
|
|
37
|
registerCommands('centerpopup,centeroffset');
|
38
|
|
39
|
////////
|
40
|
|
41
|
// DEFAULT CONFIGURATION
|
42
|
|
43
|
// You don't have to change anything here if you don't want to. All of this can be
|
44
|
|
45
|
// changed on your html page or through an overLIB call.
|
46
|
|
47
|
////////
|
48
|
|
49
|
// Default value for centerpopup is to not center the popup
|
50
|
|
51
|
if (typeof ol_centerpopup == 'undefined') var ol_centerpopup = 0;
|
52
|
|
53
|
if (typeof ol_centeroffset == 'undefined') var ol_centeroffset = '0';
|
54
|
|
55
|
////////
|
56
|
|
57
|
// END OF CONFIGURATION
|
58
|
|
59
|
// Don't change anything below this line, all configuration is above.
|
60
|
|
61
|
////////
|
62
|
|
63
|
////////
|
64
|
|
65
|
// INIT
|
66
|
|
67
|
////////
|
68
|
|
69
|
// Runtime variables init. Don't change for config!
|
70
|
|
71
|
var o3_centerpopup = 0;
|
72
|
|
73
|
var o3_centeroffset = '0';
|
74
|
|
75
|
////////
|
76
|
|
77
|
// PLUGIN FUNCTIONS
|
78
|
|
79
|
////////
|
80
|
|
81
|
function setCenterPopupVariables() {
|
82
|
|
83
|
o3_centerpopup = ol_centerpopup;
|
84
|
|
85
|
o3_centeroffset = ol_centeroffset;
|
86
|
|
87
|
}
|
88
|
|
89
|
// Parses Shadow and Scroll commands
|
90
|
|
91
|
function parseCenterPopupExtras(pf,i,ar) {
|
92
|
|
93
|
var k = i,v;
|
94
|
|
95
|
|
96
|
|
97
|
if (k < ar.length) {
|
98
|
|
99
|
if (ar[k] == CENTERPOPUP) { eval(pf + 'centerpopup = (' + pf + 'centerpopup == 0) ? 1 : 0'); return k; }
|
100
|
|
101
|
if (ar[k] == CENTEROFFSET) { k = opt_MULTIPLEARGS(++k,ar,(pf + 'centeroffset')); return k; }
|
102
|
|
103
|
}
|
104
|
|
105
|
|
106
|
|
107
|
return -1;
|
108
|
|
109
|
}
|
110
|
|
111
|
// Function which positions popup in Center of screen
|
112
|
|
113
|
function centerPopupHorizontal(browserWidth, horizontalScrollAmount, widthFix) {
|
114
|
|
115
|
if (!o3_centerpopup) return void(0);
|
116
|
|
117
|
|
118
|
|
119
|
var vdisp = o3_centeroffset.split(',');
|
120
|
|
121
|
var placeX, iwidth = browserWidth, winoffset = horizontalScrollAmount;
|
122
|
|
123
|
var pWd = parseInt(o3_width);
|
124
|
|
125
|
|
126
|
|
127
|
placeX = winoffset + Math.round((iwidth - widthFix - pWd)/2) + parseInt(vdisp[0]);
|
128
|
|
129
|
if(typeof o3_followscroll != 'undefined' && o3_followscroll && o3_sticky) o3_relx = placeX;
|
130
|
|
131
|
|
132
|
|
133
|
return placeX;
|
134
|
|
135
|
}
|
136
|
|
137
|
function centerPopupVertical(browserHeight,verticalScrollAmount) {
|
138
|
|
139
|
if (!o3_centerpopup) return void(0);
|
140
|
|
141
|
|
142
|
|
143
|
var placeY, iheight = browserHeight, scrolloffset = verticalScrollAmount;
|
144
|
|
145
|
var vdisp = o3_centeroffset.split(',');
|
146
|
|
147
|
var pHeight = (o3_aboveheight ? parseInt(o3_aboveheight) : (olNs4 ? over.clip.height : over.offsetHeight));
|
148
|
|
149
|
|
150
|
|
151
|
placeY = scrolloffset + Math.round((iheight - pHeight)/2) + (vdisp.length > 1 ? parseInt(vdisp[1]) : 0);
|
152
|
|
153
|
if(typeof o3_followscroll != 'undefined' && o3_followscroll && o3_sticky) o3_rely = placeY;
|
154
|
|
155
|
|
156
|
|
157
|
return placeY;
|
158
|
|
159
|
}
|
160
|
|
161
|
////////
|
162
|
|
163
|
// PLUGIN REGISTRATIONS
|
164
|
|
165
|
////////
|
166
|
|
167
|
registerRunTimeFunction(setCenterPopupVariables);
|
168
|
|
169
|
registerCmdLineFunction(parseCenterPopupExtras);
|
170
|
|
171
|
registerHook('horizontalPlacement',centerPopupHorizontal,FCHAIN);
|
172
|
|
173
|
registerHook('verticalPlacement', centerPopupVertical, FCHAIN);
|
174
|
|
175
|
if(olInfo.meets(4.10)) registerNoParameterCommands('centerpopup');
|
176
|
|
177
|
}
|