{% extends "admin/change_form.html" %}
{% load i18n admin_modify staticfiles %}

{% block extrahead %}{{ block.super }}
{% block feincms_jquery_ui %}
{% include "admin/feincms/load-jquery.include" %}
{% endblock %}

<link rel="stylesheet" type="text/css" href="{% static 'feincms/item_editor.css' %}">
<script type="text/javascript" src="{% static 'feincms/ie_compat.js' %}"></script>
<script type="text/javascript" src="{% static 'feincms/item_editor.js' %}"></script>

{% include "admin/feincms/_messages_js.html" %}
{% include "admin/feincms/_regions_js.html" %}
{% include "admin/feincms/_content_type_buttons.html" %}

{% for inc in model.feincms_item_editor_includes.head %}{% include inc %}{% endfor %}

<script type="text/javascript">
    feincms.jQuery(document).ready(function($){
        {% block extra-init-js %}{# /* do not use this block, use feincms_item_editor_includes instead */ #}{% endblock %}
    });
</script>
{% endblock %}

{% block form_top %}
{% with original.available_translations as translations %}
{% for translation in translations %}
{# look for something the translation extension's available_translations method might return #}
{% if translation.id %}
    {% if forloop.first %}
      <div style="float: right;padding: 5px 0 0 0" id="available_translations">
        {% trans "available translations" %}:
    {% endif %}
          <a href="../{{ translation.id }}/" title="{{ translation }}">{{ translation.language|upper }}</a>{% if not forloop.last %},{% endif %}
    {% if forloop.last %}
      </div>
      <script type="text/javascript">
        feincms.jQuery(function($){
            $('#id_language').parent().prepend($('#available_translations'));
        });
      </script>
    {% endif %}
{% endif %}{% endfor %}
{% endwith %}
{% endblock %}

{% block after_related_objects %} {# as good a place as any... #}
  {{ block.super }}
  <div id="content-editor-fieldset" style="display: none">
    {% include "admin/feincms/content_editor.html" %}
  </div>
  <script type="text/javascript">
    feincms.jQuery(function($){
      $("h2:contains('{{ FEINCMS_CONTENT_FIELDSET_NAME }}')").parent().replaceWith($("#main_wrapper"));
    });
  </script>
{% endblock %}
