{% extends base %}
<!-- change coming -->
<!-- goes in body -->
{% block preamble %}
{% if app_favicon %}<link rel="icon" href="{{ app_favicon }}" type="{{favicon_type}}">{% endif %}
{% if meta_name %}<meta name="name" content="{{ meta_name }}">{% endif %}
{% if meta_description %}<meta name="description" content="{{ meta_description }}">{% endif %}
{% if meta_keywords %}<meta name="keywords" content="{{ meta_keywords }}">{% endif %}
{% if meta_author %}<meta name="author" content="{{ meta_author }}">{% endif %}
{% if meta_refresh %}<meta http-equiv="refresh" content="{{ meta_refresh }}">{% endif %}
{% if meta_viewport %}<meta name="viewport" content="{{ meta_viewport }}">{% endif %}
{% if base_url and base_target %}<base href="{{ base_url }}" target="{{ base_target }}">{% endif %}
{% endblock %}

{% block postamble %}
<link href="{{ template_resources['css']['material'] }}" rel="stylesheet">
<script src="{{ template_resources['js']['material'] }}"></script>
<link rel="stylesheet" href="{{ template_resources['css']['base'] }}">
<link rel="stylesheet" href="{{ template_resources['css']['theme'] }}">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet">
{% endblock %}

<!-- goes in body -->
{% block contents %}
<div class="mdc-typography" id="container">
<header class="mdc-top-app-bar app-bar mdc-top-app-bar--fixed" style="{% if header_background %}background-color: {{ header_background }} !important;{% endif %}{% if header_color %}color: {{ header_color }} !important;{% endif %}" id="header">
  <div class="mdc-top-app-bar__row">
    <section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start">
      {% if nav %}
      <button class="material-icons mdc-top-app-bar__navigation-icon mdc-icon-button">menu</button>
      {% endif %}
      <div class="title-bar">
        <span class="mdc-top-app-bar__title app-header">
          {% if app_logo %}<a href="/"><img src="{{ app_logo }}" class="app-logo"></a>{% endif %}
          {% if site_title %}<a class="title" href="/" >&nbsp;{{ site_title }}</a>{% endif %}
          {% if site_title and app_title%}<span class="title">&nbsp;-</span>{% endif %}
          {% if app_title %}<a class="title" href="" >&nbsp;{{ app_title }}</a>{% endif %}
        </span>
        <div id="header-items">
          {% for doc in docs %}
          {% for root in doc.roots %}
          {% if "header" in root.tags %}
          {{ embed(root) | indent(8) }}
          {% endif %}
          {% endfor %}
          {% endfor %}
        </div>
        </div>
    </section>
    {% if busy %}
	<div class="pn-busy-container">
	  {{ embed(roots.busy_indicator) | indent(6) }}
	</div>
	{% endif %}
  </div>
</header>

{% if nav %}
<aside class="mdc-drawer mdc-top-app-bar--fixed-adjust mdc-drawer--dismissible mdc-drawer--open" id="sidebar">
  <div class="mdc-drawer__content">
    <div class="mdc-list">
	  {% for doc in docs %}
	  {% for root in doc.roots %}
	  {% if "nav" in root.tags %}
      {{ embed(root) | indent(8) }}
	  {% endif %}
	  {% endfor %}
	  {% endfor %}
    </div>
  </div>
</aside>
{% endif %}

<div class="mdc-drawer-app-content mdc-top-app-bar--fixed-adjust">
<main class="main-content" id="main">
  {% if main_max_width %}
    <div style="margin-left: auto; margin-right: auto;max-width: {{main_max_width}}">
  {% endif %}
  {% for doc in docs %}
  {% for root in doc.roots %}
  {% if "main" in root.tags %}
  {{ embed(root) | indent(4) }}
  {% endif %}
  {% endfor %}
  {% endfor %}
  {% if main_max_width %}
    </div>
  {% endif %}
</main>

<div id="pn-Modal" class="pn-modal mdc-top-app-bar--fixed-adjust">
  <div class="pn-modal-content">
    <span class="pn-modalclose" id="pn-closeModal">&times;</span>
    {% for doc in docs %}
	{% for root in doc.roots %}
	{% if "modal" in root.tags %}
	{{ embed(root) | indent(4) }}
	{% endif %}
	{% endfor %}
	{% endfor %}
  </div>
</div>
</div>
</div>

<script>
  {% if nav %}
  var drawer = mdc.drawer.MDCDrawer.attachTo(document.querySelector('.mdc-drawer'));
  var topAppBar = mdc.topAppBar.MDCTopAppBar.attachTo(document.getElementById('header'));
  topAppBar.setScrollTarget(document.getElementById('main'));
  topAppBar.listen('MDCTopAppBar:nav', function() {
    drawer.open = !drawer.open;
    // Ensure bokeh layout recomputes layout
    window.dispatchEvent(new Event('resize'));
  });

  drawer.open = true;
  {% endif %}

  var modal = document.getElementById("pn-Modal");
  var span = document.getElementById("pn-closeModal");

  span.onclick = function() {
    modal.style.display = "none";
  }

  window.onclick = function(event) {
    if (event.target == modal) {
      modal.style.display = "none";
    }
  }
</script>

{{ embed(roots.js_area) }}
{{ embed(roots.location) }}

{% endblock %}
