]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/on-line/javascript/helmjsmenu.js
New copyright free implementation of menus in JavaScript.
[helm.git] / helm / on-line / javascript / helmjsmenu.js
diff --git a/helm/on-line/javascript/helmjsmenu.js b/helm/on-line/javascript/helmjsmenu.js
new file mode 100644 (file)
index 0000000..0d76543
--- /dev/null
@@ -0,0 +1,58 @@
+// Global variables.
+var HJMmenu;
+
+function initializeMenu() {
+   HJMmenu =
+      document.getElementById ?
+         // A DOM browser
+         document.getElementById("HJMmenu").style
+      :  // Probably Netscape Navigator 4.0
+         document.HJMmenu;
+   HJMmenu.visibility="hidden";
+}
+
+function showMenu() {
+   HJMmenu.visibility="visible";
+}
+
+function hideMenu() {
+   HJMmenu.visibility="hidden";
+}
+
+function moveMenu(x,y) {
+ var y2 = y - 25;
+ var x2 = x - 25;
+ if (document.getElementById) {
+   // Not Netscape Navigator 4.0
+   HJMmenu.left = x2 + "px";
+   HJMmenu.top  = y2 + "px";
+ } else {
+   // Probably Netscape Navigator 4.0
+   HJMmenu.left = x2;
+   HJMmenu.top  = y2;
+ }
+}
+
+function getX(event) {
+   if(!event.pageX)
+      // Probably Internet Explorer
+      return event.clientX + document.body.scrollLeft;
+   else
+      // Probably Netscape Navigator
+      return event.pageX;
+}
+
+function getY(event) {
+   if(!event.pageY)
+      // Probably Internet Explorer
+      return event.clientY + document.body.scrollTop;
+   else
+      // Probably Netscape Navigator
+      return event.pageY;
+}
+
+if (!document.getElementById) {
+   // Probably Netscape Navigator
+   document.captureEvents(Event.MOUSEDOWN);
+   document.onmousedown = hideMenu;
+}