Fix menu exploding (so that we don't need the id's anymore)
authorFelix Dörre <felix@dogcraft.de>
Sun, 24 Aug 2014 00:11:43 +0000 (02:11 +0200)
committerFelix Dörre <felix@dogcraft.de>
Sun, 24 Aug 2014 00:22:11 +0000 (02:22 +0200)
src/org/cacert/gigi/Gigi.java
src/org/cacert/gigi/output/Menu.java
static/static/menu.js

index 245dff9d217cca51fd20a94f16a515baa3347702..74bfd623218a8bb9ea0bd0e684bbf25d70674d7a 100644 (file)
@@ -84,7 +84,7 @@ public class Gigi extends HttpServlet {
             putPage(MailOverview.DEFAULT_PATH, new MailOverview("My email addresses"), "Certificates");
             putPage(DomainOverview.PATH, new DomainOverview("Domains"), "Certificates");
             baseTemplate = new Template(Gigi.class.getResource("Gigi.templ"));
-            rootMenu = new Menu("Main", "");
+            rootMenu = new Menu("Main");
             for (Menu menu : categories) {
                 menu.prepare();
                 rootMenu.addItem(menu);
@@ -109,7 +109,7 @@ public class Gigi extends HttpServlet {
             }
         }
         if (m == null) {
-            m = new Menu(category, "");
+            m = new Menu(category);
             categories.add(m);
         }
         m.addItem(new PageMenuItem(p));
index b1fc745ad1ed7858bc7852ac035e1e375645ed7c..a57f531764467f413082f85fb07d9c87dfe2afd6 100644 (file)
@@ -13,15 +13,12 @@ public class Menu implements IMenuItem {
 
     private String menuName;
 
-    private String id;
-
     private IMenuItem[] content;
 
     private LinkedList<IMenuItem> prepare = new LinkedList<IMenuItem>();
 
-    public Menu(String menuName, String id) {
+    public Menu(String menuName) {
         this.menuName = menuName;
-        this.id = id;
     }
 
     @Override
@@ -33,12 +30,10 @@ public class Menu implements IMenuItem {
                 if ( !visible) {
                     visible = true;
                     out.println("<div>");
-                    out.print("<h3>+ ");
+                    out.print("<h3 class='pointer'>+ ");
                     out.print(l.getTranslation(menuName));
-                    out.print("</h3>");
-                    out.print("<ul class=\"menu\" id=\"");
-                    out.print(id);
-                    out.print("\">");
+                    out.println("</h3>");
+                    out.print("<ul class=\"menu\">");
                 }
                 mi.output(out, l, vars);
             }
index aff0c36bfc1c3900a4db91502d7ebdff0f8ce600..023e62440757526865c0a33e05b8fdcf948d0526 100644 (file)
@@ -1,9 +1,9 @@
 (function() {
        function explodeMenu(e) {
-               if (document.getElementById(e).className == 'menu hidden') {
-                       document.getElementById(e).className = 'menu';
+               if (e.className == 'menu hidden') {
+                       e.className = 'menu';
                } else {
-                       document.getElementById(e).className = 'menu hidden';
+                       e.className = 'menu hidden';
                }
        }
 
                for (var i = 0; i < max; i++) {
                        var nodeObj = Nodes.item(i);
                        if (nodeObj.className.indexOf("menu") > -1 && nodeObj.id != "recom") {
-                               nodeObj.previousSibling.previousSibling.onclick = (function(nid) {
+                               nodeObj.previousSibling.previousSibling.onclick = (function(node) {
                                        return function() {
-                                               explodeMenu(nid);
+                                               explodeMenu(node);
                                        };
-                               })(nodeObj.id);
+                               })(nodeObj);
                        }
                }
        }