{% extends "admin/original_base.html" %}
{% load i18n static jet_tags %}

{% block extrastyle %}
    {{ block.super }}
    {% get_current_jet_version as JET_VERSION %}
    <link rel="stylesheet" type="text/css" href="{% static "jet/css/vendor.css" %}?v={{ JET_VERSION }}" />
    <link rel="stylesheet" type="text/css" href="{% static "jet/css/icons/style.css" %}?v={{ JET_VERSION }}" />
    <link rel="stylesheet" type="text/css" href="{% static "jet/css/themes/default/base.css" %}?v={{ JET_VERSION }}" />
    <link rel="stylesheet" type="text/css" href="{% static "jet/css/themes/default/jquery-ui.theme.css" %}?v={{ JET_VERSION }}" />
    <link rel="stylesheet" type="text/css" href="{% static "jet/css/themes/default/select2.theme.css" %}?v={{ JET_VERSION }}" />
{% endblock %}

{% block extrahead %}
    {{ block.super }}
     <script type="text/javascript" charset="utf-8">
        var DATE_FORMAT = "{% get_date_format %}";
        var TIME_FORMAT = "{% get_time_format %}";
        var DATETIME_FORMAT = "{% get_datetime_format %}";
    </script>
    <script src="{% static "jet/js/build/bundle.min.js" %}"></script>

    {% jet_static_translation_urls as translation_urls %}
    {% for url in translation_urls %}
        <script src="{% static url %}"></script>
    {% endfor %}

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
{% endblock %}

{% block footer %}
    {{ block.super }}

    {% jet_delete_confirmation_context %}

    {% jet_change_form_sibling_links_enabled as show_siblings %}
    {% if change and show_siblings %}
        <div class="changeform-navigation">
            {% spaceless %}
                {% jet_previous_object_url as url %}
                <a{% if url %} href="{{ url }}"{% endif %} class="segmented-button left{% if not url %} disabled{% endif %}">
                    <span class="changeform-navigation-button icon-arrow-left"></span>
                </a>

                {% jet_next_object_url as url %}
                <a{% if url %} href="{{ url }}"{% endif %} class="segmented-button right{% if not url %} disabled{% endif %}">
                    <span class="changeform-navigation-button icon-arrow-right"></span>
                </a>
            {% endspaceless %}
        </div>
    {% endif %}

    {% get_side_menu_compact as SIDE_MENU_COMPACT %}
    {% if not is_popup %}
        <div class="related-popup-container scrollable">
            <a href="#" class="related-popup-back"><span class="related-popup-back-icon icon-arrow-left"></span> <span class="related-popup-back-label">{% trans "back" %}</span></a>
            <span class="icon-refresh loading-indicator"></span>
        </div>

        <div class="sidebar-header sidebar-dependent">
            <a href="#" class="sidebar-header-menu sidebar-toggle">
                <span class="sidebar-header-menu-icon icon-menu"></span>
            </a>
        </div>
        <div class="sidebar sidebar-dependent">
            <div class="sidebar-wrapper scrollable">
                <a href="#" class="sidebar-close sidebar-toggle">
                    <span class="sidebar-close-icon icon-arrow-left"></span>
                </a>
                <div class="sidebar-section">
                    {% if user.is_active and user.is_staff %}
                        <div>
                            <a href="{% url 'admin:index' %}" class="sidebar-link icon">
                                <span class="sidebar-link-icon icon-data"></span>
                                <span class="sidebar-link-label">{% trans 'Home' %}</span>
                            </a>
                        </div>
                    {% endif %}
                    {% if site_url %}
                        <div>
                            <a href="{{ site_url }}" class="sidebar-link icon">
                                <span class="sidebar-link-icon icon-open-external"></span>
                                <span class="sidebar-link-label">{% trans 'View site' %}</span>
                            </a>
                        </div>
                    {% endif %}
                    {% url 'django-admindocs-docroot' as docsroot %}
                    {% if docsroot %}
                        <div>
                            <a href="{{ docsroot }}" class="sidebar-link icon">
                                <span class="sidebar-link-icon icon-book"></span>
                                <span class="sidebar-link-label">{% trans 'Documentation' %}</span>
                            </a>
                        </div>
                    {% endif %}
                    {% block nav-global %}{% endblock %}
                </div>

                {% if user.is_active and user.is_staff %}
                    {% get_menu as app_list %}
                    {% if app_list.apps or app_list.pinned_apps %}
                        {% if SIDE_MENU_COMPACT %}
                            {% for app in app_list.all_apps %}
                                <div class="sidebar-section">
                                    <div class="sidebar-title">
                                        <a href="{{ app.app_url }}" class="sidebar-title-link">
                                            {% if app.name != app.app_label|capfirst|escape %}
                                                {{ app.name }}
                                            {% else %}
                                                {% trans app.app_label as app_label %}{{ app_label|capfirst|escape }}
                                            {% endif %}
                                        </a>
                                    </div>
                                    {% for model in app.models %}
                                        {% if model.admin_url %}
                                            <div>
                                                <a href="{{ model.admin_url }}" class="sidebar-link">
                                                    <span class="sidebar-right">
                                                        <span class="sidebar-right-arrow icon-arrow-right"></span>
                                                    </span>
                                                    {{ model.name }}
                                                </a>
                                            </div>
                                        {% endif %}
                                    {% endfor %}
                                </div>
                            {% endfor %}
                        {% else %}
                            <form action="{% url "jet:toggle_application_pin" %}" method="POST" id="toggle-application-pin-form">
                                {% csrf_token %}
                                <input type="hidden" name="app_label">
                            </form>

                            <div class="sidebar-section">
                                <div class="sidebar-title">
                                    <span class="sidebar-right">
                                        <a href="#" class="sidebar-right-edit edit-apps-list"><span class="icon-settings"></span></a>
                                    </span>
                                    {% trans 'Applications' %}
                                </div>

                                <div class="apps-list-pinned">
                                    {% for app in app_list.pinned_apps %}
                                        <a href="{{ app.app_url }}" class="sidebar-link popup-section-link app-item" data-app-label="{{ app.app_label }}" data-popup-section-class="sidebar-popup-section-{{ app.app_label }}">
                                            <span class="sidebar-left collapsible">
                                                <span class="sidebar-left-pin icon-star pin-toggle"></span>
                                                <span class="sidebar-left-unpin icon-cross pin-toggle"></span>
                                            </span>

                                            <span class="sidebar-right">
                                                <span class="sidebar-right-arrow icon-arrow-right"></span>
                                            </span>

                                            <span class="sidebar-link-label">
                                                {% if app.name != app.app_label|capfirst|escape %}
                                                    {{ app.name }}
                                                {% else %}
                                                    {% trans app.app_label as app_label %}{{ app_label|capfirst|escape }}
                                                {% endif %}
                                            </span>
                                        </a>
                                    {% endfor %}
                                </div>
                                <a href="#" class="sidebar-center-link apps-hide">
                                    <span class="apps-hide-label apps-visible">{% trans "Hide applications" %}</span>
                                    <span class="apps-hide-label apps-hidden">{% trans "Show hidden" %}</span>
                                </a>
                                <div class="apps-list">
                                    {% for app in app_list.apps %}
                                        <a href="{{ app.app_url }}" class="sidebar-link popup-section-link app-item" data-app-label="{{ app.app_label }}" data-popup-section-class="sidebar-popup-section-{{ app.app_label }}">
                                            <span class="sidebar-left collapsible">
                                                <span class="sidebar-left-pin icon-star pin-toggle"></span>
                                                <span class="sidebar-left-unpin icon-cross pin-toggle"></span>
                                            </span>

                                            <span class="sidebar-right">
                                                <span class="sidebar-right-arrow icon-arrow-right"></span>
                                            </span>

                                            <span class="sidebar-link-label">
                                                {% if app.name != app.app_label|capfirst|escape %}
                                                    {{ app.name }}
                                                {% else %}
                                                    {% trans app.app_label as app_label %}{{ app_label|capfirst|escape }}
                                                {% endif %}
                                            </span>
                                        </a>
                                    {% endfor %}
                                </div>
                            </div>
                        {% endif %}
                    {% endif %}

                    <div class="sidebar-section">
                        <div class="dialog-confirm" id="bookmarks-add-dialog" title="{% trans "Add bookmark" %}">
                            <form action="{% url "jet:add_bookmark" %}" method="POST" id="bookmarks-add-form">
                                {% csrf_token %}
                                <p>{% trans "Title" %}:</p>
                                <input type="text" name="title" class="fill_width">
                                <p>{% trans "URL" %}:</p>
                                <input type="text" name="url" class="fill_width">
                            </form>
                        </div>
                        <form action="{% url "jet:remove_bookmark" %}" method="POST" id="bookmarks-remove-form">
                            {% csrf_token %}
                            <input type="hidden" name="id">
                        </form>
                        <div class="dialog-confirm" id="bookmarks-remove-dialog" title="{% trans "Delete bookmark" %}">
                            <p>{% trans "Are you sure want to delete this bookmark?" %}</p>
                        </div>

                        <div class="sidebar-title">
                            <span class="sidebar-right">
                                <a href="#" class="sidebar-right-plus bookmarks-add" title="{% trans "Add bookmark" %}"{% if title %} data-title="{{ title }}"{% endif %}><span class="icon-add"></span></a>
                            </span>
                            {% trans 'bookmarks' %}
                        </div>

                        <div class="bookmarks-list">
                            {% get_bookmarks user as bookmarks %}
                            {% for bookmark in bookmarks %}
                                <a href="{{ bookmark.url }}" class="sidebar-link bookmark-item">
                                    <span class="sidebar-right collapsible">
                                        <span class="sidebar-right-remove bookmarks-remove" data-bookmark-id="{{ bookmark.pk }}">{% trans "Remove" %}</span>
                                    </span>
                                    {{ bookmark.title }}
                                </a>
                            {% endfor %}
                            <a class="sidebar-link bookmark-item clone">
                                <span class="sidebar-right collapsible">
                                    <span class="sidebar-right-remove bookmarks-remove">{% trans "Remove" %}</span>
                                </span>
                            </a>
                        </div>
                    </div>
                {% endif %}
            </div>
            <div class="sidebar-copyright">powered by DJANGO JET</div>

            {% if app_list and not SIDE_MENU_COMPACT %}
                <div class="sidebar-popup-container">
                    <div class="sidebar-popup">
                        <a href="#" class="sidebar-close popup sidebar-back">
                            <span class="sidebar-close-icon icon-arrow-left"></span>
                        </a>
                        {% for app in app_list.apps|add:app_list.pinned_apps %}
                            <div class="sidebar-popup-section sidebar-popup-section-{{ app.app_label }}">
                                <div class="sidebar-popup-title">
                                    {% if app.name != app.app_label|capfirst|escape %}
                                        {{ app.name }}
                                    {% else %}
                                        {% trans app.app_label as app_label %}{{ app_label|capfirst|escape }}
                                    {% endif %}
                                </div>

                                <input class="sidebar-popup-search" placeholder="Search...">

                                <ul class="sidebar-popup-list">
                                    <li class="sidebar-popup-list-item app-{{ app.app_label }}{{ app.current|yesno:" current," }}">
                                        <a href="{{ app.app_url }}" class="sidebar-popup-list-item-link">{% trans 'Application page' %}</a>
                                    </li>

                                    {% for model in app.models %}
                                        <li class="sidebar-popup-list-item model-{{ model.object_name|lower }}{{ model.current|yesno:" current," }}">
                                            {% if model.admin_url %}
                                                <a href="{{ model.admin_url }}" class="sidebar-popup-list-item-link">{{ model.name }}</a>
                                            {% else %}
                                                {{ model.name }}
                                            {% endif %}
                                        </li>
                                    {% endfor %}
                                </ul>
                            </div>
                        {% endfor %}
                    </div>
                </div>
            {% endif %}
        </div>
    {% endif %}
{% endblock %}