{% extends widget.get_base_template %}

{% load feincms_page_tags %}

{% block content %}
{% feincms_nav root level=level depth=1 as toplevel %}
<div class="navbar-collapse collapse" id="top-nav">
  <ul class="nav navbar-nav{% if widget.align == 'right' %} navbar-right{% endif %}">
  {% if depth == 1 %}
  {% for page in toplevel %}
    <li class="{% if page|is_equal_or_parent_of:current %}active{% endif %}">
      <a href="{{ page.get_navigation_url }}">{{ page.title }}</a>
    </li>
  {% endfor %}
  {% else %}
  {% for page in toplevel %}
    {% feincms_nav page level=level2 depth=1 as sublevel %}
    {% if sublevel|length == 0 %}
    <li {% if page|is_equal_or_parent_of:current %}class="active"{% endif %}>
      <a href="{{ page.get_navigation_url }}">{{ page.title }}</a>
    </li>
    {% else %}
    <li class="dropdown {% if page|is_equal_or_parent_of:current %}active{% endif %}">
      <a class="dropdown-toggle" href="{{ page.get_navigation_url }}">{{ page.title }} <span class="caret"></span></a>
      <ul class="dropdown-menu">
      {% for subpage in sublevel %}
        <li class="{% if subpage|is_equal_or_parent_of:current %}active{% endif %}">
          <a href="{{ subpage.get_navigation_url }}">{{ subpage.title }}</a>
        </li>
      {% endfor %}
      </ul>
    </li>
    {% endif %}
  {% endfor %}
  {% endif %}
  </ul>
</div>
{% endblock %}
