reversing previous change as it breaks page layout
[moodle-pu.git] / lib / overlib / overlib_centerpopup.js
blobb498a1e76672404f8320f4e4ddb2ecc28b1c0b8d
1 //\/////
2 //\ overLIB Center Popup Plugin
3 //\ This file requires overLIB 4.10 or later.
4 //\
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.
9 // $Revision$ $Date$
11 //\/////
12 //\mini
13 ////////
14 // PRE-INIT
15 // Ignore these lines, configuration is below.
16 ////////
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.');
18 else {
19 registerCommands('centerpopup,centeroffset');
20 ////////
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.
24 ////////
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';
28 ////////
29 // END OF CONFIGURATION
30 // Don't change anything below this line, all configuration is above.
31 ////////
32 ////////
33 // INIT
34 ////////
35 // Runtime variables init. Don't change for config!
36 var o3_centerpopup = 0;
37 var o3_centeroffset = '0';
38 ////////
39 // PLUGIN FUNCTIONS
40 ////////
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) {
47 var k = i,v;
49 if (k < ar.length) {
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; }
54 return -1;
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;
67 return 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;
79 return placeY;
81 ////////
82 // PLUGIN REGISTRATIONS
83 ////////
84 registerRunTimeFunction(setCenterPopupVariables);
85 registerCmdLineFunction(parseCenterPopupExtras);
86 registerHook('horizontalPlacement',centerPopupHorizontal,FCHAIN);
87 registerHook('verticalPlacement', centerPopupVertical, FCHAIN);
88 if(olInfo.meets(4.10)) registerNoParameterCommands('centerpopup');