{# -*- 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 class="theme header">
  <div class="outer-navbar">

  {%- block navbar %}
  <nav id="invenio-nav" class="ui inverted brand menu borderless">
    <div class="ui grid container">
      <ul class="navbar-menu">
        <li class="logo">
        {%- block navbar_header %}
          {%- block brand %}
            <div class="item left-logo">
              {%- if config.THEME_LOGO %}
                <a href="/" class="ui image small">
                  <img clas="middle aligned"
                       src="{{ url_for('static', filename=config.THEME_LOGO) }}"
                       alt="{{ _(config.THEME_SITENAME) }}"/></a>
              {%- else %}
                <a class="logo" href="/">{{ _(config.THEME_SITENAME) }}</a>
              {%- endif %}
            </div>
          {%- endblock %}
        {%- endblock navbar_header %}
        </li>
        {%- block navbar_inner %}

        {%- block navbar_nav %}
        <li class="navbar-item">
            {%- if config.THEME_SEARCHBAR %}
              {%- block navbar_search %}
                <div class="item" id="header-search-bar">
                  <form class="form"
                        action="{{ config.THEME_SEARCH_ENDPOINT }}"
                        role="search">
                    <div class="ui action icon input">
                      <input type="text" name="q"
                             placeholder="{{ _('Search') }}">
                      <button type="submit" class="ui icon search button">
                        <i class="icon search"></i>
                      </button>
                    </div>
                  </form>
                </div>

              {%- endblock navbar_search %}
            {%- endif %}
          </li>
            {%- for item in current_menu.submenu('main').children|sort(attribute='order') if item.visible recursive %}
              {%- if item.children %}
              <li class="navbar-item navbar-options">
                <div 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>
                </div>
              </li>
              {%- else %}
                <li{{ ' class="navbar-item navbar-options active"'|safe if item.active and loop.depth == 1 else 'navbar-item navbar-options' }}>
                  <a
                          href="{{ item.url }}">{{ item.text|safe }}</a></li>
              {%- endif %}
            {%- endfor %}
          {%- endblock navbar_nav %}
        <li class="navbar-item navbar-button">
          <div class="right menu">

        {%- block navbar_right %}
          {%- include config.THEME_HEADER_LOGIN_TEMPLATE %}
        {%- endblock navbar_right %}

          </div>
        </li>
        {%- endblock navbar_inner %}
      <li class="toggle">
        <input class="menu-btn" type="checkbox" id="menu-btn" />
        <label class="menu-icon" for="menu-btn"><span class="navicon"></span></label>
      </li>
    </nav>
  </div>


  {%- 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>
