{% extends "base.html" %}

{% load i18n %}
{% load tags %}
{% load staticfiles %}

{% block title %}
    {% if item %}
        {{ item }} – {% trans "Edit item" %}
    {% else %}
        {% trans "New item" %}
    {% endif %}
    – {{ block.super }}
{% endblock %}

{% block header %}
    {{ block.super }}
    <link type="text/css" rel="stylesheet" media="all" href="{% static 'styles/ckeditor.css' %}" />
{% endblock %}

{% block javascript %}
    {{ block.super }}
    <script type="text/javascript" src="{% static 'javascript/ckeditor/ckeditor.js' %}"></script>
    <script type="text/javascript" src="{% static 'javascript/ckeditor-config.js' %}"></script>
    <script>
        // Init CKeditor
        $(function() {
            CKEDITOR.replace('id_text', ck_options);
        });
    </script>
{% endblock %}

{% block content %}
    <h1>
        {% if item %}
            {% trans "Edit item" %}
        {% else %}
            {% trans "New item" %}
        {% endif %}
        <small class="pull-right">
        <a href="{% url 'item_overview' %}" class="btn btn-mini"><i class="icon-chevron-left"></i> {% trans "Back to overview" %}</a>
        </small>
    </h1>
    <p>
        {% if item.content_object %}
            <a href="{{ item.content_object|absolute_url:'update' }}" class="btn btn-small">
                {% blocktrans with type=item.content_type.name|trans name=item.content_object %}Edit {{ type }} {{ name }}{% endblocktrans %}
            </a>
        {% endif %}
    </p>
    <form action="" method="post">{% csrf_token %}
        {% include "form.html" %}
        <p>
        {% include "formbuttons_saveapply.html" %}
        <a href='{% url 'item_overview' %}' class="btn">
            {% trans 'Cancel' %}
        </a>
        </p>
        <small>* {% trans "required" %}</small>
    </form>
{% endblock %}
