added dropdowns to website toolbar

This commit is contained in:
Rushabh Mehta 2012-09-05 12:32:19 +05:30
parent eb3089e6e3
commit a9302b01d1
2 changed files with 40 additions and 9 deletions

View File

@ -14,18 +14,33 @@
<ul class="nav"> <ul class="nav">
{% for page in top_bar_items %} {% for page in top_bar_items %}
{% if not page.parent_label %} {% if not page.parent_label %}
<li data-label="{{ page.label }}"> <li data-label="{{ page.label }}"
<a href="{{ page.url }}" {{ page.target }}> {% if page.child_items %}
class="dropdown"
{% endif %}>
<a href="{{ page.url or '#' }}"
{% if page.child_items %}
class="dropdown-toggle"
onclick="return false;"
{% endif %}
{{ page.target or ''}}>
{{ page.label }} {{ page.label }}
{% if page.child_items %} {% if page.child_items %}
<b class="caret"></b>
</a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
{% for child in page.child_items %} {% for child in page.child_items %}
<li data-label="{{ child.label }}"> <li data-label="{{ child.label }}">
<a href="{{ child.url }}" {{ child.target }}> <a href="{{ child.url }}" {{ child.target or '' }}>
{{ child.label }}
</a>
</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% else %}
</a>
{% endif %} {% endif %}
</a></li> </li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
@ -36,6 +51,7 @@
</div> </div>
</div> </div>
</div> </div>
<script>$('.dropdown-toggle').dropdown()</script>
</header> </header>
<div id="body_div"> <div id="body_div">
<div class="content" id="page-{{ name }}" style="display: block;"> <div class="content" id="page-{{ name }}" style="display: block;">

View File

@ -139,11 +139,26 @@ def get_outer_env():
env dict for outer template env dict for outer template
""" """
import webnotes import webnotes
all_top_items = webnotes.conn.sql("""\
select * from `tabTop Bar Item`
where parent='Website Settings' and parentfield='top_bar_items'
order by idx asc""", as_dict=1)
top_items = [d for d in all_top_items if not d['parent_label']]
# attach child items to top bar
for d in all_top_items:
if d['parent_label']:
for t in top_items:
if t['label']==d['parent_label']:
if not 'child_items' in t:
t['child_items'] = []
t['child_items'].append(d)
break
return { return {
'top_bar_items': webnotes.conn.sql("""\ 'top_bar_items': top_items,
select * from `tabTop Bar Item`
where parent='Website Settings' and parentfield='top_bar_items'
order by idx asc""", as_dict=1),
'footer_items': webnotes.conn.sql("""\ 'footer_items': webnotes.conn.sql("""\
select * from `tabTop Bar Item` select * from `tabTop Bar Item`