menus with dropdown : also outline the whole 'More' button when a subitem is current
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Mon, 4 Nov 2013 14:38:21 +0000 (15:38 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Mon, 4 Nov 2013 14:39:31 +0000 (15:39 +0100)
ui/templates/widget-topmenu.html
ui/topmenu.py

index c465a84..dbcbe1f 100644 (file)
@@ -18,7 +18,7 @@
     <ul class="nav navbar-nav">
        {% for d in topmenu_items %} 
        {% if d.dropdown %}
-       <li class="other">
+       {% if d.is_active %} <li class='active'> {% else %} <li class='other'> {% endif %}
          <a class="dropdown-toggle" data-toggle="dropdown" href="{{ d.href }}">{{ d.label }}<b class="caret"></b></a>
          <ul class="dropdown-menu">
            {% for dd in d.contents %}
index e6250f0..1be7c28 100644 (file)
@@ -31,12 +31,15 @@ def topmenu_items (current,request=None):
     if current is not None:
         current=current.lower()
         curlen=len(current)
-        def mark_active(d):
-            if d['label'][:curlen].lower() == current: d['is_active']=True
+        def mark_active(d,up=None):
+            if d['label'][:curlen].lower() == current: 
+                d['is_active']=True
+                if up is not None: up['is_active']=True
+            print 'mark_active OUT','d=',d,'up',up
         for d in result:
             mark_active(d)
             if 'dropdown' in d:
-                for dd in d['contents']: mark_active(dd)
+                for dd in d['contents']: mark_active(dd,d)
     return result
 
 def the_user (request):