PageRenderTime 254ms CodeModel.GetById 131ms app.highlight 7ms RepoModel.GetById 113ms app.codeStats 0ms

/django/contrib/admin/templates/admin/edit_inline/stacked.html

https://code.google.com/p/mango-py/
HTML | 82 lines | 80 code | 2 blank | 0 comment | 0 complexity | 92d1955c0d5057fec94c233ce9581600 MD5 | raw file
 1{% load i18n adminmedia %}
 2<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
 3  <h2>{{ inline_admin_formset.opts.verbose_name_plural|title }}</h2>
 4{{ inline_admin_formset.formset.management_form }}
 5{{ inline_admin_formset.formset.non_form_errors }}
 6
 7{% for inline_admin_form in inline_admin_formset %}<div class="inline-related{% if forloop.last %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
 8  <h3><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b>&nbsp;<span class="inline_label">{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %}#{{ forloop.counter }}{% endif %}</span>
 9    {% if inline_admin_form.show_url %}<a href="../../../r/{{ inline_admin_form.original_content_type_id }}/{{ inline_admin_form.original.id }}/">{% trans "View on site" %}</a>{% endif %}
10    {% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}<span class="delete">{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}</span>{% endif %}
11  </h3>
12  {% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %}
13  {% for fieldset in inline_admin_form %}
14    {% include "admin/includes/fieldset.html" %}
15  {% endfor %}
16  {% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
17  {{ inline_admin_form.fk_field.field }}
18</div>{% endfor %}
19</div>
20
21<script type="text/javascript">
22(function($) {
23    $(document).ready(function() {
24        var rows = "#{{ inline_admin_formset.formset.prefix }}-group .inline-related";
25        var updateInlineLabel = function(row) {
26            $(rows).find(".inline_label").each(function(i) {
27                var count = i + 1;
28                $(this).html($(this).html().replace(/(#\d+)/g, "#" + count));
29            });
30        }
31        var reinitDateTimeShortCuts = function() {
32            // Reinitialize the calendar and clock widgets by force, yuck.
33            if (typeof DateTimeShortcuts != "undefined") {
34                $(".datetimeshortcuts").remove();
35                DateTimeShortcuts.init();
36            }
37        }
38        var updateSelectFilter = function() {
39            // If any SelectFilter widgets were added, instantiate a new instance.
40            if (typeof SelectFilter != "undefined"){
41                $(".selectfilter").each(function(index, value){
42                  var namearr = value.name.split('-');
43                  SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% admin_media_prefix %}");
44                });
45                $(".selectfilterstacked").each(function(index, value){
46                  var namearr = value.name.split('-');
47                  SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% admin_media_prefix %}");
48                });
49            }
50        }
51        var initPrepopulatedFields = function(row) {
52            row.find('.prepopulated_field').each(function() {
53                var field = $(this);
54                var input = field.find('input, select, textarea');
55                var dependency_list = input.data('dependency_list') || [];
56                var dependencies = [];
57                $.each(dependency_list, function(i, field_name) {
58                  dependencies.push('#' + row.find(field_name).find('input, select, textarea').attr('id'));
59                });
60                if (dependencies.length) {
61                    input.prepopulate(dependencies, input.attr('maxlength'));
62                }
63            });
64        }
65        $(rows).formset({
66            prefix: "{{ inline_admin_formset.formset.prefix }}",
67            addText: "{% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
68            formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}",
69            deleteCssClass: "inline-deletelink",
70            deleteText: "{% trans "Remove" %}",
71            emptyCssClass: "empty-form",
72            removed: updateInlineLabel,
73            added: (function(row) {
74                initPrepopulatedFields(row);
75                reinitDateTimeShortCuts();
76                updateSelectFilter();
77                updateInlineLabel(row);
78            })
79        });
80    });
81})(django.jQuery);
82</script>