{% load static %}{% load i18n grp_tags %}{% load compress %}<!DOCTYPE html>
<html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
<head>
    <title>{% if "test" in request.get_host %}** SERWER TESTOWY ** {% endif %}{% block title %}{% endblock %}</title>
    <meta charset="utf-8"/>
    {% block blockbots %}
        <meta name="robots" content="NONE,NOARCHIVE"/>{% endblock %}
    <!-- STYLESHEETS -->
    {% compress css %}
        {% block stylesheets %}
            <link href="{% static "grappelli/jquery/ui/jquery-ui.min.css" %}" rel="stylesheet" type="text/css"
                  media="screen"/>
            <link href="{% static "grappelli/stylesheets/mueller/grid/output.css" %}" rel="stylesheet" type="text/css"
                  media="screen"/>
            <link href="{% static "grappelli/stylesheets/screen.css" %}" rel="stylesheet" type="text/css" media="all"/>
            <link rel="stylesheet" type="text/css" href="{% static 'kbw-keypad/dist/css/jquery.keypad.css' %}"
                  media="all"/>
        {% endblock %}
    {% endcompress %}
    <!-- EXTRASTYLES -->
    <!-- EXTRASTYLES -->
    {% block extrastyle %}{% endblock %}


    <!-- JAVASCRIPTS -->
    {% block javascripts %}
        <script type="text/javascript">window.__admin_media_prefix__ = "{% filter escapejs %}{% static "grappelli/" %}{% endfilter %}";</script>
        <script type="text/javascript">window.__admin_utc_offset__ = "{% filter escapejs %}{% now "Z" %}{% endfilter %}";</script>
        <script type="text/javascript" charset="utf-8">
            // GLOBALS
            var grappelli = {},
                ADMIN_URL = "{% url 'admin:index' %}",
                MODEL_URL_ARRAY = {% if user.is_staff %}{% get_content_types %}{% else %}[]{% endif %},
                DATE_FORMAT = "{% get_date_format %}",
                TIME_FORMAT = "{% get_time_format %}",
                DATETIME_FORMAT = "{% get_datetime_format %}";
        </script>
        <!-- jQuery, jQuery-UI -->
        {% compress js %}
            <script src="{% static "grappelli/jquery/jquery.min.js" %}" type="text/javascript"></script>
            <script src="{% static "grappelli/jquery/ui/jquery-ui.min.js" %}" type="text/javascript"></script>
            <script src="{% static "grappelli/js/grappelli.min.js" %}" type="text/javascript"></script>

            {#        <script src="{% static "admin/js/jquery.init.js" %}" type="text/javascript"></script>#}

            <script type="text/javascript" src="{% static 'kbw-keypad/dist/js/jquery.plugin.min.js' %}"></script>
            <script type="text/javascript" src="{% static 'kbw-keypad/dist/js/jquery.keypad.js' %}"></script>
            <script type="text/javascript" src="{% static 'kbw-keypad/dist/js/jquery.keypad-pl.js' %}"></script>

            <script src="/static/bpp/js/bpp.js" type="text/javascript"></script>

            <script src="{% static "grappelli/jquery/i18n/ui.datepicker-pl.js" %}" type="text/javascript"></script>

        {% endcompress %}

        <script type="text/javascript" charset="utf-8">
            (function ($) {
                $(document).ready(function () {
                    $("#grp-navigation .grp-collapse").grp_collapsible();

                    function csrfSafeMethod(method) {
                        // these HTTP methods do not require CSRF protection
                        return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
                    }

                    $.ajaxSetup({
                        beforeSend: function (xhr, settings) {
                            if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                                xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
                            }
                        }
                    });

                    $("a.close[close-href]").click(function (e) {
                        e.preventDefault();
                        var orig_elem = $(this);

                        $.post(
                            orig_elem.attr("close-href"),
                            "",
                            function () {
                                orig_elem.parent().hide();
                            }
                        );
                    });
                });
            })(django.jQuery);

        </script>
    {% endblock %}
    <!-- EXTRAHEAD -->
    {% block extrahead %}{% endblock %}


{#    <script>#}
{#        console.log('GRP ver', grp.jQuery.fn.jquery);#}
{#        console.log('GRP sel', grp.jQuery.fn.select2);#}
{#        console.log('DJG ver', django.jQuery.fn.jquery);#}
{#        console.log('DJG sel', django.jQuery.fn.select2);#}
{#        console.log('  $ fun', window.$);#}
{#        if (window.$) {#}
{#            if (window.$.jQuery)#}
{#                if (window.$.jQuery.fn) {#}
{#                    console.log('  $ ver', $.jQuery.fn.jquery);#}
{#                    console.log('  $ sel', $.jQuery.fn.select2);#}
{#                }#}
{#        }#}
{#        var $ = grp.jQuery;#}
{#    </script>#}
    {% include 'session_security/all.html' %}

</head>
<body class="{% if is_popup %}grp-popup {% endif %}{% block bodyclass %}{% endblock %}{% if LANGUAGE_BIDI %} rtl{% endif %}">
<div id="grp-container">

    <!-- HEADER -->
    <header id="grp-header" class="{% block header-class %}{% endblock %}">
        {% if not is_popup %}

            <!-- NAVIGATION -->
            <div id="grp-navigation">
                <h1 id="grp-admin-title">{% if grappelli_admin_title %}{{ grappelli_admin_title }}{% else %}
                    {% get_admin_title %}{% endif %}</h1>
                {% if user.is_authenticated and user.is_staff %}
                    <ul id="grp-user-tools">
                        <!-- Userlinks -->
                        {% block userlinks %}
                            <!-- Username -->
                            <li class="grp-user-options-container grp-collapse grp-closed">
                                <a href="javascript://" class="user-options-handler grp-collapse-handler">
                                    {% filter force_escape %}
                                        {% firstof user.first_name user.username user.get_short_name user.get_username %}{% endfilter %}</a>
                                <ul class="grp-user-options">
                                    <!-- Change Password -->
                                    {% if user.has_usable_password %}
                                        {% url 'admin:password_change' as password_change_url %}
                                        {% if password_change_url %}
                                            <li><a href="{{ password_change_url }}">
                                                {% else %}
                                            <li><a href="{{ root_path }}password_change/">
                                        {% endif %}
                                    {% trans 'Change password' %}</a></li>
                                    {% endif %}
                                    <!-- Logout -->
                                    {% url 'admin:logout' as logout_url %}
                                    {% if logout_url %}
                                        <li><a href="{{ logout_url }}">
                                            {% else %}
                                        <li><a href="{{ root_path }}logout/">
                                    {% endif %}
                                    {% trans 'Log out' %}</a></li>
                                </ul>
                            </li>
                            <!-- JS tests -->
                            {% url 'test-index' as testindexurl %}
                            {% if testindexurl %}
                                <li><a href="{{ testindexurl }}">{% trans 'Tests' %}</a></li>
                            {% endif %}
                            <!-- Documentation -->
                            {% url 'django-admindocs-docroot' as docsroot %}
                            {% if docsroot %}
                                <li><a href="{{ docsroot }}">{% trans 'Documentation' %}</a></li>
                            {% endif %}
                        {% endblock %}
                    </ul>
                {% endif %}
                <!-- Nav-Global -->
                {% block nav-global %}{% endblock %}
            </div>

            <!-- CONTEXT NAVIGATION -->
            <div id="grp-context-navigation">
                <nav id="grp-breadcrumbs" class="{% block breadcrumbs-class %}{% endblock %}">
                    <header style="display:none"><h1>Breadcrumbs</h1></header>
                    {% block breadcrumbs %}
                        <ul>
                            <li><a href="/">{% trans 'Home' %}</a></li>
                            {% if title %}
                                <li> &rsaquo; {{ title }}</li>
                            {% endif %}
                        </ul>
                    {% endblock %}
                </nav>
                <nav id="grp-page-tools">
                    <header style="display:none"><h1>Page Tools</h1></header>
                    {% block page-tools %}{% endblock %}
                </nav>
            </div>
        {% endif %}
    </header>

    <!-- CONTENT -->
    <article id="grp-content" class="{% block content-class %}{% endblock %}">
        <!-- MESSAGES -->
        {% block messages %}
            {% if messages %}
                <ul class="grp-messagelist">
                    {% for message in messages %}
                        <li{% if message.tags %} class="grp-{{ message.tags }}"{% endif %}>
                            <a style="cursor: pointer; cursor: hand; }" class="close" data-dismiss="alert"
                                    {% if message.pk %}
                               close-href="{% url "messages_extends:message_mark_read" message.pk %}"{% endif %}> × </a>
                            {{ message|safe }}
                        </li>
                    {% endfor %}
                </ul>
            {% endif %}
        {% endblock %}
        <!-- CONTENT TITLE -->
        <header id="grp-content-title">
            {% block pretitle %}{% endblock %}
            {% block content_title %}{% if title %}<h1>
                {% if "test" in request.get_host %}Serwer testowy - {% endif %}
                {{ title }}</h1>{% endif %}{% endblock %}
            {% block object-tools %}{% endblock %}
        </header>

        <!-- CONTENT-CONTAINER -->
        <div id="grp-content-container">
            {% block content %}
                {{ content }}
                {% block filters %}{% endblock %}
            {% endblock %}
        </div>

    </article>

    <!-- FOOTER -->
    {% block footer %}{% endblock %}

    {% if "test" in request.get_host %}
        {# Najprostsza, naiwna identyfikacja serwera testowego - słowo 'test' w nazwie domeny. #}
        <style>
            body {
                background-image: url("{% static "bpp/images/test_server_background.jpg" %}") !important;
                background-size: 100%;
                background-repeat: repeat-y;
            }
        </style>
    {% endif %}

</div>

</body>
</html>
