{% extends "admin/base_site.html" %}
{% load i18n admin_modify admin_static proto_tags %}

{% block extrahead %}{{ block.super }}
{% url 'admin:jsi18n' as jsi18nurl %}
<script type="text/javascript" src="{{ jsi18nurl|default:"../../../jsi18n/" }}"></script>
<script type="text/javascript" src="{% static "js/jquery.balloon.min.js" %}"></script>
    <script>
        $(function() {
            var bal = 0;
            $.ajaxSetup({ async:false });
            $.get('{% url 'configuracao.views.has_help_text' opts.app_label opts.model_name %}', function(has) {
                bal = parseInt(has);
            });
            $.ajaxSetup({ async:true });
            if (bal) {
                $("#balloon").balloon({position:"bottom left", url:"{% url 'configuracao.views.help_text' opts.app_label opts.model_name %}", classname:"balloon",
                    css:{opacity: 1}
                });
            } else {
                $("#balloon").hide();
            }

         $(document).tooltip({
             items: "input, select, textarea",
             show: {delay:300},
             content: function(callback) {
                 var element = $(this);
                 $.get('{% url 'configuracao.views.tooltip' opts.app_label opts.model_name %}', {'field_name': element.attr('name') }, function(data) {
                     callback(data);
                 });
             },

         });
     });

	</script> {{ media }}
{% endblock %}

{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "css/forms.css" %}"/>{% endblock %}

{% block coltype %}{% if ordered_objects %}colMS{% else %}colM{% endif %}{% endblock %}

{% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %}

{% block breadcrumbs %}{% if not is_popup %}
<div class="breadcrumbs">Você está em:
     <a href="../../../">{% trans "Home" %}</a> &rsaquo;
     {% if app_label %}<a href="../../">{{ app_label|capfirst|escape }}</a> &rsaquo;{% endif %}
     {% if has_change_permission %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} &rsaquo;
     {% if add %}{% trans "Add" %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
</div>
{% endif %}{% endblock %}

{% block content %}<div id="content-main">
{% block object-tools %}
{% if not is_popup %}
    <ul class="object-tools">
        <li class="helplink"><a id="balloon" href="#" class="helplink">{% trans "Help" %}</a></li>
{% if change %}
    <li><a href="history/" class="historylink">{% trans "History" %}</a></li>
  {% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif %}
{% endif %}
    </ul>
{% endif %}
{% endblock %}
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %}
<div>
{% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
{% if save_on_top %}{% submit_row %}{% endif %}
{% if errors %}
    <p class="errornote">
    {% blocktrans count errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
    </p>
    {{ adminform.form.non_field_errors }}
{% endif %}

{% for fieldset in adminform %}
  {% include "admin/includes/fieldset.html" %}
{% endfor %}

{% block after_field_sets %}{% endblock %}

{% for inline_admin_formset in inline_admin_formsets %}
    {% include inline_admin_formset.opts.template %}
{% endfor %}

{% block after_related_objects %}{% endblock %}

{% if not user|has_group:"readonly" %}{% submit_row %}{% endif %}

{% if adminform and add %}
   <script type="text/javascript">document.getElementById("{{ adminform.first_field.auto_id }}").focus();</script>
{% endif %}

{# JavaScript for prepopulated fields #}
{% prepopulated_fields_js %}

</div>
</form></div>
{% endblock %}
