{% extends "MapbenderCoreBundle::frontend.html.twig" %}

{% block title %}{{ fom.server_name }} - {{ application.title }}{% endblock %}

{% block favicon %}{{ asset('favicon.png') }}{% endblock %}

{% block css %}
  <link rel="stylesheet" href="{{ path('mapbender_core_application_assets', {'slug': application.slug, 'type': 'css'}) }}"/>
{% endblock %}

{% block trans %}
  {{parent()}}
  <script type="text/javascript" src="{{ path('mapbender_core_application_assets', {'slug': application.slug, 'type': 'trans'}) }}"></script>
{% endblock %}

{% block js %}
  {{parent()}}
  <script type="text/javascript" src="{{ path('mapbender_core_application_assets', {'slug': application.slug, 'type': 'js'}) }}"></script>
{% endblock %}


{% block frontend_content %}
  {% set sidePaneClosed = region_props.sidepane.properties.closed|default(false) %}
  <div id="templateWrapper" class="templateWrapper {% if sidePaneClosed == false %}sidePaneOpened{% endif %}">
    {% if fom.server_logo is defined %}
      <div class="logoContainer">
        {% block logo %}
          <img class="logo" height="40" src="{{ asset(fom.server_logo) }}"/>
        {% endblock %}
      </div>
    {% endif %}

    {% if application.elements.toolbar is defined %}
    <ul id="toolbar" class="toolBar itemsRight top">
        {% for element in application.elements('toolbar') %}
          <li class="toolBarItem">{{ element.render() | raw }}</li>
        {% endfor %}
    </ul>
    {% endif %}

    {# Right sidepane definition #}
    {% set name = 'sidepane' %}
    {% if application.elements[name] is defined %}
      {% set region = application.elements[name] %}
      {% set properties = region_props[name].properties|default({}) %}
      {% set align = properties.align|default('left') %}
      {% set isRegionClosed = properties.closed|default('false') %}

      <div id="{{ name }}"
           data-closed="{{ isRegionClosed }}"
           class="clear sidePane {{ align }}"
        {% if properties.width is defined %} style="width: {{ properties.width }}"{% endif %}
      >
        <ul class="sidePaneTabs">
          <li class="sidePaneTabItem toggleSideBar"></li>
        </ul>
        <div class="sideContent">
          {% include "MapbenderCoreBundle:Template:region.html.twig"  with {'region_props': region_props, 'application': application, 'region': name } %}
        </div>
      </div>
    {% endif %}

    <div id="content" class="contentPane">
      {% include "MapbenderCoreBundle:Template:region.html.twig"  with {'region_props': region_props, 'application': application, 'region': 'content' }%}
    </div>

    {% if application.elements.footer is defined %}
    <ul id="footer" class="toolBar itemsRight bottom">
        {% for element in application.elements('footer')%}
          <li class="toolBarItem">{{ element.render() | raw }}</li>
        {% endfor %}
    </ul>
    {% endif %}
  </div>

{% endblock %}
