source: temp/test-xoops.ec-cube.net/html/include/layersmenu.js @ 405

Revision 405, 3.8 KB checked in by root, 20 years ago (diff)
Line 
1// PHP Layers Menu 1.0.7 (c) 2001, 2002 Marco Pratesi <[email protected]>
2
3DOM = (document.getElementById) ? 1 : 0;
4NS4 = (document.layers) ? 1 : 0;
5IE4 = (document.all) ? 1 : 0;
6var loaded = 0; // to avoid stupid errors of Microsoft browsers
7Konqueror = (navigator.userAgent.indexOf("Konqueror") > -1) ? 1 : 0;
8// We need to explicitly detect Konqueror
9// because Konqueror 3 sets IE4 = 1 ... AAAAAAAAAARGHHH!!!
10Opera5 = (navigator.userAgent.indexOf("Opera 5") > -1 || navigator.userAgent.indexOf("Opera/5") > -1 || navigator.userAgent.indexOf("Opera 6") > -1 || navigator.userAgent.indexOf("Opera/6") > -1) ? 1 : 0;
11
12// it works with NS4, Mozilla, NS6, Opera 5 and 6, IE
13currentY = -1;
14function grabMouse(e) {
15    if ((DOM && !IE4) || Opera5) {
16        currentY = e.clientY;
17    } else if (NS4) {
18        currentY = e.pageY;
19    } else {
20        currentY = event.y;
21    }
22    if (DOM && !IE4 && !Opera5 && !Konqueror) {
23        currentY += window.pageYOffset;
24    } else if (IE4 && DOM && !Opera5 && !Konqueror) {
25        currentY += document.body.scrollTop;
26    }
27}
28if ((DOM || NS4) && !IE4) {
29    document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
30}
31document.onmousemove = grabMouse;
32
33function popUp(menuName,on) {
34    if (loaded) {   // to avoid stupid errors of Microsoft browsers
35        if (on) {
36//          moveLayers();
37            if (DOM) {
38                document.getElementById(menuName).style.visibility = "visible";
39                document.getElementById(menuName).style.zIndex = 1000;
40            } else if (NS4) {
41                document.layers[menuName].visibility = "show";
42                document.layers[menuName].zIndex = 1000;
43            } else {
44                document.all[menuName].style.visibility = "visible";
45                document.all[menuName].style.zIndex = 1000;
46            }
47        } else {
48            if (DOM) {
49                document.getElementById(menuName).style.visibility = "hidden";
50            } else if (NS4) {
51                document.layers[menuName].visibility = "hide";
52            } else {
53                document.all[menuName].style.visibility = "hidden";
54            }
55        }
56    }
57}
58
59function setleft(layer,x) {
60    if (DOM) {
61        document.getElementById(layer).style.left = x;
62        document.getElementById(layer).style.left = x + 'px';
63    } else if (NS4) {
64        document.layers[layer].left = x;
65    } else {
66        document.all[layer].style.pixelLeft = x;
67    }
68}
69
70function settop(layer,y) {
71    if (DOM) {
72        document.getElementById(layer).style.top = y;
73        document.getElementById(layer).style.top = y + 'px';
74    } else if (NS4) {
75        document.layers[layer].top = y;
76    } else {
77        document.all[layer].style.pixelTop = y;
78    }
79}
80
81function setwidth(layer,w) {
82    if (DOM) {
83        document.getElementById(layer).style.width = w;
84        document.getElementById(layer).style.width = w + 'px';
85    } else if (NS4) {
86//      document.layers[layer].width = w;
87    } else {
88        document.all[layer].style.pixelWidth = w;
89    }
90}
91
92function moveLayerY(menuName, ordinata, e) {
93    if (loaded) {   
94    // to avoid stupid errors of Microsoft browsers
95    //alert (ordinata);
96    // Konqueror: ordinata = -1 according to the initialization currentY = -1
97    // Opera: isNaN(ordinata), currentY is NaN, it seems that Opera ignores the initialization currentY = -1
98        if (ordinata != -1 && !isNaN(ordinata)) {   // The browser has detected the mouse position
99            if (DOM) {
100                // attenzione a "px" !!!
101                if (e && e.clientY) { // just use the pos of the mouseOver event if we have it
102                    document.getElementById(menuName).style.top = e.clientY + 'px';
103                } else {
104                    appoggio = parseInt(document.getElementById(menuName).style.top);
105                    if (isNaN(appoggio)) appoggio = 0;
106                    if (Math.abs(appoggio + ordinata_margin - ordinata) > thresholdY)
107                        document.getElementById(menuName).style.top = (ordinata - ordinata_margin) + 'px';
108                }
109
110            } else if (NS4) {
111                    if (Math.abs(document.layers[menuName].top + ordinata_margin - ordinata) > thresholdY)
112                        document.layers[menuName].top = ordinata - ordinata_margin;
113            } else {
114                if (Math.abs(document.all[menuName].style.pixelTop + ordinata_margin - ordinata) > thresholdY)
115                    document.all[menuName].style.pixelTop = ordinata - ordinata_margin;
116            }
117        }
118    }
119}
120
Note: See TracBrowser for help on using the repository browser.