]> matita.cs.unibo.it Git - helm.git/commitdiff
New copyright free implementation of menus in JavaScript.
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Sun, 28 Oct 2001 22:48:19 +0000 (22:48 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Sun, 28 Oct 2001 22:48:19 +0000 (22:48 +0000)
helm/on-line/javascript/Makefile
helm/on-line/javascript/helmjsmenu.js [new file with mode: 0644]
helm/on-line/xslt/makeGraphLinks.xsl

index de7e0aa76f6c7b417b91c85c2d6fed0e34a24167..1a6baf65e056fd71e04faa7bed1a263540743968 100644 (file)
@@ -1,5 +1,5 @@
 
-TARGETS = control.js_xml defaults.js_xml utils.js_xml graphLinks.js_xml
+TARGETS = control.js_xml defaults.js_xml utils.js_xml graphLinks.js_xml helmjsmenu.js_xml
 
 .SUFFIXES:
 .SUFFIXES: .js .js_xml
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;
+}
index 3a74babdb2fc071586f4525d84830c019e38d6df..49122be2bc702382f9262999d0269d832a63d39c 100644 (file)
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:subst="http://www.cs.unibo.it/helm/subst">
 
+<xsl:import href="utils.xsl"/>
+
 <!--CSC: code cut & pasted also in metadataLib.xsl -->
-<xsl:param name="uri_set_size" select="'30'"/>
+<xsl:param name="uri_set_size" select="''"/>
 <!--CSC: end of cut & paste also in metadataLib.xsl -->
 
 <xsl:output method="html" encoding="iso-8859-1"/>
    <subst:script language="JavaScript" src="/javascript/utils.js"/>
    <subst:script language="JavaScript" src="/javascript/control.js"/>
    <subst:script language="JavaScript" src="/javascript/graphLinks.js"/>
-   <script language="JavaScript" type="text/javascript">
-    <!-- topurl will be used by the code in jsmenu/* -->
-    var topurl = "<subst:topurl/>";
-   </script>
-   <script language="JavaScript" type="text/javascript">
-<![CDATA[
-if(window.event + "" == "undefined") event = null;
-function HM_f_PopUp(){return false};
-function HM_f_PopDown(){return false};
-popUp = HM_f_PopUp;
-popDown = HM_f_PopDown;
-var selectedURI;
-var lastEvent;
-]]>
-   </script>
-   <script language="JavaScript1.2" type="text/javascript">
-<![CDATA[
-HM_PG_MenuWidth = 300;
-HM_PG_FontFamily = "Arial,sans-serif";
-HM_PG_FontSize = 10;
-HM_PG_FontBold = 0;
-HM_PG_FontItalic = 0;
-HM_PG_FontColor = "blue";
-HM_PG_FontColorOver = "green";
-HM_PG_BGColor = "#DDDDDD";
-HM_PG_BGColorOver = "#FFCCCC";
-HM_PG_ItemPadding = 3;
-
-HM_PG_BorderWidth = 2;
-HM_PG_BorderColor = "black";
-HM_PG_BorderStyle = "solid";
-HM_PG_SeparatorSize = 2;
-HM_PG_SeparatorColor = "#d0ff00";
-
-HM_PG_ImageSrc = ]]> topurl + <![CDATA["/javascript/jsmenu/HM_More_black_right.gif";
-HM_PG_ImageSrcLeft = ]]> topurl + <![CDATA["/javascript/jsmenu/HM_More_black_left.gif";
-HM_PG_ImageSrcOver = ]]> topurl + <![CDATA["/javascript/jsmenu/HM_More_white_right.gif";
-HM_PG_ImageSrcLeftOver = ]]> topurl + <![CDATA["/javascript/jsmenu/HM_More_white_left.gif";
-
-HM_PG_ImageSize = 5;
-HM_PG_ImageHorizSpace = 0;
-HM_PG_ImageVertSpace = 2;
-
-HM_PG_KeepHilite = true; 
-HM_PG_ClickStart = 0;
-HM_PG_ClickKill = false;
-HM_PG_ChildOverlap = 20;
-HM_PG_ChildOffset = 10;
-HM_PG_ChildPerCentOver = null;
-HM_PG_TopSecondsVisible = .5;
-HM_PG_StatusDisplayBuild =0;
-HM_PG_StatusDisplayLink = 0;
-HM_PG_UponDisplay = null;
-HM_PG_UponHide = null;
-HM_PG_RightToLeft = 0;
-
-HM_PG_CreateTopOnly = 0;
-HM_PG_ShowLinkCursor = 1;
-HM_PG_NSFontOver = true;
-
-//HM_a_TreesToBuild = [2];
-]]>
+   <subst:script language="JavaScript" src="/javascript/helmjsmenu.js"/>
+   <script>
+    var lastX, lastY;
+    var selectedURI;
    </script>
    <xsl:apply-templates/>
   </xsl:copy>
@@ -124,36 +68,37 @@ HM_PG_NSFontOver = true;
   <!--CSC: end of cut & paste also in metadataLib.xsl -->
   <xsl:copy>
    <xsl:copy-of select="@*"/>
+   <xsl:attribute name="onClick">hideMenu();</xsl:attribute>
    <xsl:apply-templates/>
-   <script>
-HM_Array1 = [
-<![CDATA[
-[,,,
-,,,,,,,,,,,,,,,,
-1,true],
-["Objects this one depends on.","javascript:window.open(mkDepURL(selectedURI),'graph')",1,0,0],
-["Render this object.","javascript:window.open(mkCICURL(selectedURI),'cic')",1,0,0],
-["Objects depending directly on this one.","javascript:window.open(mkMetaTheoryURL(selectedURI),'theory')",1,0,0],
-["Objects depending on this one.","javascript:window.open(mkMetaURL(selectedURI),'graph')",1,0,0]
-];
-]]>
-   </script>
-   <subst:script Language="JavaScript1.2" src="/javascript/jsmenu/HM_Loader_prova.js"/>
+   <div style="position: absolute" id="HJMmenu">
+    <!-- The two nested tables are for NS 4.0 where every -->
+    <!-- layer has a default transparent background color -->
+    <table bgColor="green" id="pippo">
+     <tr><td>
+      <table bgColor="cyan" border="2">
+       <tr><td><a href="" onClick="this.href=mkDepURL(selectedURI);">Objects this one depends on.</a></td></tr>
+       <tr><td><a href="" onClick="this.href=mkCICURL(selectedURI);" target="cic">Render this object.</a></td></tr>
+       <tr><td><a href="" onClick="this.href=mkMetaTheoryURL(selectedURI);" target="theory">Objects depending directly on this one.</a></td></tr>
+       <tr><td><a href="" onClick="this.href=mkMetaURL(selectedURI);">Objects depending on this one.</a></td></tr>
+      </table>
+     </td></tr>
+    </table>
+   </div>
+   <script>initializeMenu()</script>
   </xsl:copy>
 </xsl:template>
 
 <xsl:template match = "area">
- <xsl:variable name="uri" select="@href"/>
+ <xsl:variable name="quoteduri">
+  <xsl:call-template name="jsquote">
+   <xsl:with-param name="s" select="@href"/>
+  </xsl:call-template>
+ </xsl:variable>
  <xsl:copy>
   <xsl:copy-of select="@*"/> 
   <xsl:if test="starts-with(@href,&quot;cic:&quot;)">
-<!-- CSC: I don't know why the following one does not work.
-     CSC: Replaced with the following line
-   <xsl:attribute name="onMouseOver">selectedURI=this.href;HM_f_PopUp('elMenu1',event)</xsl:attribute>
--->
-   <xsl:attribute name="onMouseOver">selectedURI="<xsl:value-of select="$uri"/>";lastEvent=event;HM_f_PopUp('elMenu1',event)</xsl:attribute>
-   <xsl:attribute name="onMouseOut">HM_f_PopDown('elMenu1')</xsl:attribute>
-   <xsl:attribute name="href">javascript: HM_f_PopUp('elMenu1',lastEvent); void(0);</xsl:attribute>
+   <xsl:attribute name="onMouseOver">lastX = getX(event); lastY = getY(event);selectedURI='<xsl:value-of select="$quoteduri"/>';</xsl:attribute>
+   <xsl:attribute name="href">javascript:moveMenu(lastX,lastY); showMenu();</xsl:attribute>
   </xsl:if>
   <xsl:apply-templates/>
  </xsl:copy>