<commit_before>{% load i18n admin_urls admin_static advanced_admin_tags %}
<div class="_inline-group panel" id="{{ inline_admin_formset.formset.prefix }}-group">
    <div class="panel-heading"><a>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</a></div>
    {{ inline_admin_formset.formset.management_form }}

    {% if inline_admin_formset.formset.non_form_errors %}
    <div class="alert alert-danger">
        {{ inline_admin_formset.formset.non_form_errors }}
    </div>
    {% endif %}
    <div class="items inline-stacked panel-body">
        {% for inline_admin_form in inline_admin_formset %}
        <fieldset class="inline-related{% if inline_admin_form.original or inline_admin_form.show_url %} has_original{% endif %}{% if forloop.last %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
            <legend>
                <a data-toggle="collapse"
                   data-target="#{{ inline_admin_formset.formset.prefix }}-{{ forloop.counter0 }} > .collapse">

                    {# Label #}
                    {% if inline_admin_form.original %}
                        {{ inline_admin_form.original }}
                        {% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %}
                            <a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" class="inlinechangelink">
                                {% trans "Change" %}
                            </a>
                        {% endif %}
                    {% else %}
                        <span class="inline-label">{{ inline_admin_formset.opts.verbose_name|capfirst }} #{{ forloop.counter }}</span>
                    {% endif %}

                    {# Collapse icon #}
                    <span class="mdi-action-open-in-new"></span>

                    {# Order icon #}
                    {% if inline_admin_formset.opts.sortable_field_name %}
                    <span class="drag-handler mdi-action-swap-vert"></span>
                    {% endif %}

                </a>
                {% if inline_admin_form.show_url %}
                    <a href="{{ inline_admin_form.absolute_url }}">{% trans "View on site" %}</a>
                {% endif %}
                {% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}
                <div class="pull-right">
                        <div class="delete">
                            {{ inline_admin_form.deletion_field.field }}
                            <div><a class="mdi-content-clear" title="{% trans "Delete" %}"></a></div>
                        </div>
                </div>
                {% endif %}
          </legend>
          {% for fieldset in inline_admin_form %}
              {% for line in fieldset %}
                  {% if line.errors %}
                      {% for field in line %}
                        <div class="alert alert-danger"><strong>{{ field.field.label }}:</strong> {{ field.errors|striptags }}</div>
                      {% endfor %}
                  {% endif %}
              {% endfor %}
          {% endfor %}

          <div class="panel-body collapse{% if not inline_admin_formset.opts.start_collapsed %} in{% endif %}">
          {% if inline_admin_form.form.non_field_errors %}
              <div class="alert alert-danger">
                  {{ inline_admin_form.form.non_field_errors }}
              </div>
          {% endif %}
          {% with stacked_prefix=forloop.counter %}
              {% for fieldset in inline_admin_form %}
                    {% include "admin/includes/fieldset.html" with group_column_width=fieldset|fieldset_column_width %}
              {% endfor %}
          {% endwith %}
          {% if inline_admin_form.needs_explicit_pk_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
          {{ inline_admin_form.fk_field.field }}
          </div>
        </fieldset>
        {% endfor %}
    </div>
</div>

<script type="text/javascript">
(function($) {
    $(document).ready(function() {
        var rows = "#{{ inline_admin_formset.formset.prefix }}-group .inline-related";
        var updateInlineLabel = function(row) {
            $(rows).find(".inline-label").each(function(i) {
                var count = i + 1;
                $(this).html($(this).html().replace(/(#\d+)/g, "#" + count));
            });
        };
        var reinitDateTimeShortCuts = function() {
            // Reinitialize the calendar and clock widgets by force, yuck.
            if (typeof DateTimeShortcuts != "undefined") {
                $(".datetimeshortcuts").remove();
                DateTimeShortcuts.init();
            }
        };
        var updateSelectFilter = function() {
            // If any SelectFilter widgets were added, instantiate a new instance.
            if (typeof SelectFilter != "undefined"){
                $(".selectfilter").each(function(index, value){
                  var namearr = value.name.split('-');
                  SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% static "admin/" %}");
                });
                $(".selectfilterstacked").each(function(index, value){
                  var namearr = value.name.split('-');
                  SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% static "admin/" %}");
                });
            }
        };
        var initPrepopulatedFields = function(row) {
            row.find('.prepopulated_field').each(function() {
                var field = $(this);
                var input = field.find('input, select, textarea');
                var dependency_list = input.data('dependency_list') || [];
                var dependencies = [];
                $.each(dependency_list, function(i, field_name) {
                  dependencies.push('#' + row.find('.form-row .field-' + field_name).find('input, select, textarea').attr('id'));
                });
                if (dependencies.length) {
                    input.prepopulate(dependencies, input.attr('maxlength'));
                }
            });
        };
        $(rows).formset({
            prefix: "{{ inline_admin_formset.formset.prefix }}",
            addText: "<span class=\"mdi-content-add\"></span>{% trans "Add another" %}",
            formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}",
            deleteCssClass: "mdi-content-clear",
            deleteText: "",
            emptyCssClass: "empty-form",
            removed: updateInlineLabel,
            added: (function(row) {
                initPrepopulatedFields(row);
                reinitDateTimeShortCuts();
                updateSelectFilter();
                updateInlineLabel(row);
                initStackedSortable();
                $(row).find('.delete').removeAttr('href').removeClass('delete').parent().addClass('delete').wrap($('<div>', {'class': "pull-right"}));
                initStackedDeleteRow();
            })
        });


    });
})(django.jQuery);

// listener for jquery 1.7.2
(function($) {

    initStackedDeleteRow();

    {% if inline_admin_formset.opts.sortable_field_name %}

    initStackedSortable();

    $("#{{ opts.model_name }}_form").submit(function(e) {
        var sortable_field_name = "{{ inline_admin_formset.opts.sortable_field_name }}",
            i = 0;
        var initial_form_count = $('#id_{{ inline_admin_formset.formset.prefix }}-INITIAL_FORMS').val();

        $('#{{ inline_admin_formset.formset.prefix }}-group > .items').find(".dynamic-{{ inline_admin_formset.formset.prefix }}").each(function(i, e) {
            // make sure we don't assign a position unless extra has been moved
            if ($(this).find("input[name$='" + sortable_field_name + "']").val() || (i <= initial_form_count - 1 )) {
                $(this).find("input[name$='" + sortable_field_name + "']").val(i);
                i++;
            }
        });<commit_msg>Fix stackable design<commit_after>{% load i18n admin_urls admin_static advanced_admin_tags %}
<div class="_inline-group panel" id="{{ inline_admin_formset.formset.prefix }}-group">
    <div class="panel-heading"><a>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</a></div>
    {{ inline_admin_formset.formset.management_form }}

    {% if inline_admin_formset.formset.non_form_errors %}
    <div class="alert alert-danger">
        {{ inline_admin_formset.formset.non_form_errors }}
    </div>
    {% endif %}
    <div class="items inline-stacked panel-body">
        {% for inline_admin_form in inline_admin_formset %}
        <fieldset class="inline-related{% if inline_admin_form.original or inline_admin_form.show_url %} has_original{% endif %}{% if forloop.last %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
            <legend>
                <a data-toggle="collapse"
                   data-target="#{{ inline_admin_formset.formset.prefix }}-{{ forloop.counter0 }} > .collapse">

                    {# Label #}
                    {% if inline_admin_form.original %}
                        {{ inline_admin_form.original }}
                        {% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %}
                            <a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" class="inlinechangelink">
                                {% trans "Change" %}
                            </a>
                        {% endif %}
                    {% else %}
                        <span class="inline-label">{{ inline_admin_formset.opts.verbose_name|capfirst }} #{{ forloop.counter }}</span>
                    {% endif %}

                    {# Collapse icon #}
                    <span class="mdi-action-open-in-new"></span>

                </a>

                {% if inline_admin_form.show_url %}
                    <a href="{{ inline_admin_form.absolute_url }}">{% trans "View on site" %}</a>
                {% endif %}

                <div class="stacked-actions pull-right">
                        {# Order icon #}
                        {% if inline_admin_formset.opts.sortable_field_name %}
                        <span class="drag-handler mdi-action-swap-vert"></span>
                        {% endif %}
                        {# Delete icon #}
                        {% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}
                        <span class="delete">
                            {{ inline_admin_form.deletion_field.field }}
                            <a class="mdi-content-clear" title="{% trans "Delete" %}"></a>
                        </span>
                        {% endif %}
                </div>
          </legend>
          {% for fieldset in inline_admin_form %}
              {% for line in fieldset %}
                  {% if line.errors %}
                      {% for field in line %}
                        <div class="alert alert-danger"><strong>{{ field.field.label }}:</strong> {{ field.errors|striptags }}</div>
                      {% endfor %}
                  {% endif %}
              {% endfor %}
          {% endfor %}

          <div class="panel-body collapse{% if not inline_admin_formset.opts.start_collapsed %} in{% endif %}">
          {% if inline_admin_form.form.non_field_errors %}
              <div class="alert alert-danger">
                  {{ inline_admin_form.form.non_field_errors }}
              </div>
          {% endif %}
          {% with stacked_prefix=forloop.counter %}
              {% for fieldset in inline_admin_form %}
                    {% include "admin/includes/fieldset.html" with group_column_width=fieldset|fieldset_column_width %}
              {% endfor %}
          {% endwith %}
          {% if inline_admin_form.needs_explicit_pk_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
          {{ inline_admin_form.fk_field.field }}
          </div>
        </fieldset>
        {% endfor %}
    </div>
</div>

<script type="text/javascript">
(function($) {
    $(document).ready(function() {
        var rows = "#{{ inline_admin_formset.formset.prefix }}-group .inline-related";
        var updateInlineLabel = function(row) {
            $(rows).find(".inline-label").each(function(i) {
                var count = i + 1;
                $(this).html($(this).html().replace(/(#\d+)/g, "#" + count));
            });
        };
        var reinitDateTimeShortCuts = function() {
            // Reinitialize the calendar and clock widgets by force, yuck.
            if (typeof DateTimeShortcuts != "undefined") {
                $(".datetimeshortcuts").remove();
                DateTimeShortcuts.init();
            }
        };
        var updateSelectFilter = function() {
            // If any SelectFilter widgets were added, instantiate a new instance.
            if (typeof SelectFilter != "undefined"){
                $(".selectfilter").each(function(index, value){
                  var namearr = value.name.split('-');
                  SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% static "admin/" %}");
                });
                $(".selectfilterstacked").each(function(index, value){
                  var namearr = value.name.split('-');
                  SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% static "admin/" %}");
                });
            }
        };
        var initPrepopulatedFields = function(row) {
            row.find('.prepopulated_field').each(function() {
                var field = $(this);
                var input = field.find('input, select, textarea');
                var dependency_list = input.data('dependency_list') || [];
                var dependencies = [];
                $.each(dependency_list, function(i, field_name) {
                  dependencies.push('#' + row.find('.form-row .field-' + field_name).find('input, select, textarea').attr('id'));
                });
                if (dependencies.length) {
                    input.prepopulate(dependencies, input.attr('maxlength'));
                }
            });
        };
        $(rows).formset({
            prefix: "{{ inline_admin_formset.formset.prefix }}",
            addText: "<span class=\"mdi-content-add\"></span>{% trans "Add another" %}",
            formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}",
            deleteCssClass: "mdi-content-clear delete",
            deleteText: "",
            emptyCssClass: "empty-form",
            removed: updateInlineLabel,
            added: (function(row) {
                initPrepopulatedFields(row);
                reinitDateTimeShortCuts();
                updateSelectFilter();
                updateInlineLabel(row);
                initStackedSortable();
                var deleteElement = $(row).find('.delete');
                deleteElement.removeAttr('href').removeClass('delete');
                $(row).find(".stacked-actions").append(deleteElement);
                deleteElement.wrap('<span class="delete">');
                initStackedDeleteRow();
            })
        });


    });
})(django.jQuery);

// listener for jquery 1.7.2
(function($) {

    initStackedDeleteRow();

    {% if inline_admin_formset.opts.sortable_field_name %}

    initStackedSortable();

    $("#{{ opts.model_name }}_form").submit(function(e) {
        var sortable_field_name = "{{ inline_admin_formset.opts.sortable_field_name }}",
            i = 0;
        var initial_form_count = $('#id_{{ inline_admin_formset.formset.prefix }}-INITIAL_FORMS').val();

        $('#{{ inline_admin_formset.formset.prefix }}-group > .items').find(".dynamic-{{ inline_admin_formset.formset.prefix }}").each(function(i, e) {
            // make sure we don't assign a position unless extra has been moved
            if ($(this).find("input[name$='" + sortable_field_name + "']").val() || (i <= initial_form_count - 1 )) {
                $(this).find("input[name$='" + sortable_field_name + "']").val(i);
                i++;
            }
        });
{'fraction_non_alphanumeric': 0.14663007014333637, 'fraction_numerical': 0.001463860933211345, 'mean_word_length': 1.8514782608695652, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2014726', 'n_tokens_mistral': 4749, 'n_tokens_neox': 4340, 'n_words': 766}