]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/js/overlib_hideform.js
Update
[bacula/bacula] / gui / bacula-web / js / overlib_hideform.js
1 //\/////
2 //\  overLIB Hide Form Plugin
3 //\  This file requires overLIB 4.00 or later.
4 //\
5 //\  Uses an iframe shim to mask system controls for IE v5.5 or higher as suggested in
6 //\  http://dotnetjunkies.com/weblog/jking/posts/488.aspx
7 //\
8 //\  overLIB 4.00 - You may not remove or change this notice.
9 //\  Copyright Erik Bosrup 1998-2004. All rights reserved.
10 //\  Contributors are listed on the homepage.
11 //\  See http://www.bosrup.com/web/overlib/ for details.
12 //   $Revision$                $Date$
13 //\/////
14
15 if (typeof olInfo == 'undefined' || olInfo.simpleversion < 400) alert('overLIB 4.00 or later is required for the HideForm Plugin.');
16
17 // Function which generates the popup with an IFRAME shim
18 function generatePopUp(content) {
19         if(!olIe4||olOp||!olIe55||(typeof o3_shadow != 'undefined' && o3_shadow)||(typeof o3_bubble != 'undefined' && o3_bubble)) return;
20
21         var wd,ht,txt, zIdx =  0;
22
23         wd =  parseInt(o3_width);
24         ht =  over.offsetHeight;
25         txt =  bckDropSrc(wd,ht,zIdx++);
26         txt += '<div style="position: absolute; top: 0; left: 0; width: '+ wd+'px; z-index: ' + zIdx + ';">' + content + '</div>';
27         layerWrite(txt);
28 }
29
30 // Code for the IFRAME which is used in other places
31 function bckDropSrc(width, height, Z) {
32         return '<iframe frameborder="0" scrolling="no" src="" width="' + width + '" height="' + height + '" style="z-index: ' + Z + '; filter: Beta(Style=0,Opacity=0);"></iframe>';
33 }
34
35 // Hides SELECT boxes that will be under the popup
36 // Checking Gecko version number to try to include other browsers based on the Gecko engine
37 function hideSelectBox() {
38         if(olNs4 || olOp || olIe55) return;
39         var px, py, pw, ph, sx, sw, sy, sh, selEl, v;
40
41         if(olIe4) v = 0;
42         else {
43                 v = navigator.userAgent.match(/Gecko\/(\d{8})/i);
44                 if(!v) return;   // return if no string match
45                 v = parseInt(v[1]);
46         }
47
48         if (v < 20030624) {  // versions less than June 24, 2003 were earlier Netscape browsers
49                 px = parseInt(over.style.left);
50                 py = parseInt(over.style.top);
51                 pw = o3_width;
52                 ph = (o3_aboveheight ? parseInt(o3_aboveheight) : over.offsetHeight);
53                 selEl = (olIe4) ? o3_frame.document.all.tags("SELECT") : o3_frame.document.getElementsByTagName("SELECT");
54                 for (var i=0; i<selEl.length; i++) {
55                         if(!olIe4 && selEl[i].size < 2) continue;  // Not IE and SELECT size is 1 or not specified
56                         sx = pageLocation(selEl[i],'Left');
57                         sy = pageLocation(selEl[i],'Top');
58                         sw = selEl[i].offsetWidth;
59                         sh = selEl[i].offsetHeight;
60                         if((px+pw) < sx || px > (sx+sw) || (py+ph) < sy || py > (sy+sh)) continue;
61                         selEl[i].isHidden = 1;
62                         selEl[i].style.visibility = 'hidden';
63                 }
64         }
65 }
66
67 // Shows previously hidden SELECT Boxes
68 function showSelectBox() {
69         if(olNs4 || olOp || olIe55) return;
70         var selEl, v;
71
72         if(olIe4) v = 0;
73         else {
74                 v = navigator.userAgent.match(/Gecko\/(\d{8})/i);
75                 if(!v) return; 
76                 v = parseInt(v[1]);
77         }
78
79         if(v < 20030624) {
80                 selEl = (olIe4) ? o3_frame.document.all.tags("SELECT") : o3_frame.document.getElementsByTagName("SELECT");
81                 for (var i=0; i<selEl.length; i++) {
82                         if(typeof selEl[i].isHidden !=  'undefined' && selEl[i].isHidden) {
83                                 selEl[i].isHidden = 0;
84                                 selEl[i].style.visibility = 'visible';
85                         }
86                 }
87         }
88 }
89
90 // function gets the total offset properties of an element
91 // this same function occurs in overlib_mark.js.
92 function pageLocation(o,t){
93         var x = 0
94
95         while(o.offsetParent){
96                 x += o['offset'+t]
97                 o = o.offsetParent
98         }
99
100         x += o['offset'+t]
101
102         return x
103 }
104
105 // reset mouse move routine for NS7 but not NS7.1,Opera, or IE5.5+
106 // It also bypasses Netscape 6 since the modifications mess up the display of popups
107 // and don't work anyways.
108 // Modify mouse move routine while loading so that hideSelectBox()
109 // can be called from the correct location
110 if (!(olNs4 || olOp || olIe55 || navigator.userAgent.indexOf('Netscape6') != -1)) {
111         var MMStr = olMouseMove.toString();
112         var strRe = /(if\s*\(o3_allowmove\s*==\s*1.*\)\s*)/;
113         var f = MMStr.match(strRe);
114
115         if (f) {
116                 var ls = MMStr.search(strRe);
117                 ls += f[1].length;
118                 var le = MMStr.substring(ls).search(/[;|}]\n/);
119                 MMStr = MMStr.substring(0,ls) + ' { runHook("placeLayer",FREPLACE); if(olHideForm) hideSelectBox(); ' + MMStr.substring(ls + (le != -1 ? le+3 : 0));
120                 document.writeln('<script type="text/javascript">\n<!--\n' + MMStr + '\n//-->\n</' + 'script>');
121         }
122
123         f = capExtent.onmousemove.toString().match(/function[ ]+(\w*)\(/);
124         if (f&&f[1] != 'annoymous') capExtent.onmousemove = olMouseMove;
125 }
126
127
128 ////////
129 // PLUGIN REGISTRATIONS
130 ////////
131 registerHook("createPopup",generatePopUp,FAFTER);
132 registerHook("hideObject",showSelectBox,FAFTER);
133 olHideForm=1;