{%- extends "basic/layout.html" %}

{% block extrahead %}
{{ super() }}
{%- if theme_typography %}
{% set theme_typography = theme_typography.lower() %}
<link rel="stylesheet" id="sphinx-library-type" href="{{ pathto('_static/library/type-' ~ theme_typography ~ '.css', 1) }}" type="text/css" />
{%- endif %}
<link rel="stylesheet" href="{{ pathto('_static/custom.css', 1) }}" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9" />
<script>
  mobile_menu_content = "";
  function toggleMenu() {
    var div = document.getElementsByClassName("document").item(0);
    var btn = document.getElementById("menu-toggler");
    if(div.classList.contains("mobile-show")) {
      div.classList.remove("mobile-show");
      btn.innerHTML = mobile_menu_content;
    }
    else {
      div.classList.add("mobile-show");
      mobile_menu_content = btn.innerHTML;
      btn.innerHTML = btn.getAttribute("data-open");
    }
  }
</script>
{%- endblock %}

{%- macro breadcrumbs() %}
  {%- block rootrellink %}
  <a class="nav-item" href="{{ pathto(master_doc) }}">{{ _('Index') }}</a>
  <span class="delim">{{ reldelim1 }}</span>
  {%- endblock %}
  {%- for parent in parents %}
  <a class="nav-item" href="{{ parent.link|e }}">{{ parent.title }}</a>
  <span class="delim">{{ reldelim1 }}</span>
  {%- endfor %}
  <span class="nav-item">{{ title|striptags|e }}</span>
{%- endmacro %}

{%- macro mobile_menu() %}
  <button type="button" id="menu-toggler" onclick="toggleMenu();"
    data-open="× {{ _('Close') }}">≡ {{ _('Menu') }}</button>
  <a href="{{ pathto(master_doc) }}">{{ project }}</a>
  <noscript>
    <div>
      {{ _('JavaScript is required to open/close mobile menu') }}.
    </div>
  </noscript>
{%- endmacro %}

{%- macro relbar_links() %}
  {%- if prev %}
  <a class="prev" href="{{ prev.link|e }}" title="{{ _('Previous') }}">
    &larr; {{ prev.title }}
  </a>
  {%- endif %}
  {%- if next %}
  <a class="next" href="{{ next.link|e }}" title="{{ _('Next') }}">
    {{ next.title }} &rarr;
  </a>
  {%- endif %}
  <div class="clear"></div>
{%- endmacro %}

{%- macro library_sidebar() %}
  {%- for sidebartemplate in sidebars %}
  {%- include sidebartemplate %}
  {%- endfor %}
{%- endmacro %}

{%- block relbar1 %}{% endblock %}
{%- block relbar2 %}{% endblock %}

{# Start with default reading mode #}
{%- block body_tag %}
<body {% if theme_reading_mode %}class="{{theme_reading_mode}}"{% endif %}>
{%- endblock %}

{%- block content %}
<div class="document">

  {% block mobile_menu %}
  <nav class="mobile-menu" role="navigation">
    {{ mobile_menu() }}
  </nav>
  {% endblock %}

  {% block sidebar %}
  {%- if render_sidebar %}
  <nav class="sphinxsidebar" role="navigation" aria-label="main navigation">
    {{ library_sidebar() }}
  </nav>
  {%- endif %}
  {%- endblock %}

  {%- block document %}
  <div class="documentwrapper">

    {%- block breadcrumbs_top %}
    {%- if theme_show_breadcrumbs|tobool %}
    <nav class="related breadcrumbs" role="navigation">
      {{- breadcrumbs() }}
    </nav>
    {%- endif %}
    {%- endblock %}

    {%- block relbar_top %}
    {%- if theme_show_relbar_top|tobool %}
    <nav class="related top" role="navigation">
      {{- relbar_links () }}
    </nav>
    {%- endif %}
    {% endblock %}

    <main class="body" role="main" id="main">
      {% block body %} {% endblock %}
    </main>

    {%- block relbar_bottom %}
    {%- if theme_show_relbar_bottom|tobool %}
    <nav class="related bottom" role="navigation">
      {{- relbar_links () }}
    </nav>
    {%- endif %}
    {% endblock %}

  </div>
  {%- endblock %}

  <div class="clear"></div>
</div>
{%- endblock %}

{%- block footer %}
<footer class="footer" role="contentinfo">
  {%- if last_updated %}
  {% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}<br>
  {%- endif %}

  {%- if show_copyright %}
  {%- if hasdoc('copyright') %}
    {% trans path=pathto('copyright'), copyright=copyright|e %}&copy; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
  {%- else %}
    {% trans copyright=copyright|e %}&copy; Copyright {{ copyright }}.{% endtrans %}
  {%- endif %}
  {%- endif %}

  {%- if show_sphinx %}
  {% trans %}
  Created using <a href="http://sphinx-doc.org/">Sphinx</a> with
  <a href="https://github.com/vsalvino/sphinx-library">Library</a> theme.
  {% endtrans %}
  {%- endif -%}

  {%- if show_source and has_source and sourcename %}
  <a href="{{ pathto('_sources/' + sourcename, true)|e }}" rel="nofollow">{{ _('Page source') }}</a>
  {%- endif %}
</footer>
{%- endblock %}
