{# -*- coding: utf-8 -*-

  This file is part of Invenio.
  Copyright (C) 2015-2018 CERN.

  Invenio is free software; you can redistribute it and/or modify it
  under the terms of the MIT License; see LICENSE file for more details.
#}
<header>
  {%- block navbar %}
  <nav class="navbar navbar-default navbar-static-top">
    <div class="container">
      {%- block navbar_header %}
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          <span class="sr-only">{{_('Toggle navigation')}}</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        {%- block brand %}
        {%- if config.THEME_LOGO %}
          <a href="/"><img class="navbar-brand" src="{{ url_for('static', filename=config.THEME_LOGO)}}" alt="{{_(config.THEME_SITENAME)}}" /></a>
        {%- else %}
          <a class="navbar-brand" href="/">{{_(config.THEME_SITENAME)}}</a>
        {%- endif %}
        {%- endblock %}
      </div>
      {%- endblock navbar_header %}
      {%- block navbar_inner %}
      <div id="navbar" class="navbar-collapse collapse">
        {%- block navbar_nav %}
        {%- if config.THEME_SEARCHBAR %}
        {%- block navbar_search %}
        <form class="navbar-form navbar-left" action="{{config.THEME_SEARCH_ENDPOINT}}" role="search">
          <div class="form-group">
            <div class="input-group">
              <input type="text" class="form-control" name="q" placeholder="{{_('Search')}}">
              <div class="input-group-btn">
                <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
              </div>
            </div>
          </div>
        </form>
        {%- endblock navbar_search %}
        {%- endif %}
        <ul class="nav navbar-nav">
          {%- for item in current_menu.submenu('main').children|sort(attribute='order') if item.visible recursive %}
          {%- if item.children %}
          <li class="dropdown{{ ' active' if item.active else ''}}">
            <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" href="{{ item.url }}">{{ item.text|safe }} <b class="caret"></b></a>
            <ul class="dropdown-menu">{{ loop(item.children|sort(attribute='order')) }}</ul>
          </li>
          {%- else %}
            <li{{ ' class="active"'|safe if item.active and loop.depth == 1 else '' }}><a href="{{ item.url }}">{{ item.text|safe }}</a></li>
          {%- endif %}
          {%- endfor %}
        </ul>
        {%- endblock navbar_nav %}
        {%- block navbar_right %}
{%- include config.THEME_HEADER_LOGIN_TEMPLATE %}
        {%- endblock navbar_right %}
      </div>
      {%- endblock navbar_inner %}
    </div>
  </nav>
  {%- endblock navbar %}
  {%- block flashmessages %}
  {%- from "invenio_theme/macros/messages.html" import flashed_messages with context -%}
  {{ flashed_messages() }}
  {%- endblock %}
  {%- block breadcrumbs %}
{%- include "invenio_theme/breadcrumbs.html" %}
  {%- endblock breadcrumbs %}
</header>
