Made a slight change to window position randomization; now only non-modal windows...
[philo.git] / templates / admin / philo / edit_inline / grappelli_tabular_attribute.html
1 {% load i18n adminmedia %}
2
3 <!-- group -->
4 <div class="group tabular{% if inline_admin_formset.opts.classes %} {{ inline_admin_formset.opts.classes|join:" " }}{% endif %}"
5         id="{{ inline_admin_formset.formset.prefix }}-group" >
6         <h2 class="collapse-handler">{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
7         <ul class="tools">
8                 <li class="add-handler-container"><a href="javascript://" class="icon add-handler" title="{% trans 'Add Another' %}"> </a></li>
9         </ul>
10         {{ inline_admin_formset.formset.management_form }}
11         {{ inline_admin_formset.formset.non_form_errors }}
12         <!-- container -->
13         <div class="module table">
14                 <div class="module thead">
15                         <div class="tr">
16                                 {% for field in inline_admin_formset.fields %}
17                                         {% if not field.widget.is_hidden %}
18                                                 <div class="th {{ field.label|lower }}{% if field.required %} required{% endif %}">{{ field.label|capfirst }}</div>
19                                         {% endif %}
20                                 {% endfor %}
21                                 <div class="th content_type">Content type</div>
22                                 <div class="th value">Value</div>
23                                 {% if inline_admin_formset.formset.can_delete %}<div class="th">&nbsp;</div>{% endif %}
24                         </div>
25                 </div>
26                 {% for inline_admin_form in inline_admin_formset %}
27                         <!-- element -->
28                         <div class="module tbody{% if inline_admin_form.original or inline_admin_form.show_url %} has_original{% endif %}{% if forloop.last %} empty-form{% endif %}"
29                                 id="{{ inline_admin_formset.formset.prefix }}{% if not forloop.last %}{{ forloop.counter0 }}{% else %}-empty{% endif %}">
30                                 {% if inline_admin_form.form.non_field_errors %}
31                                         <ul class="errorlist"><li>{{ inline_admin_form.form.non_field_errors }}</li></ul>
32                                 {% endif %}
33                                 <h3 style="display: none;"><b>{{ inline_admin_formset.opts.verbose_name|title }} #{{ forloop.counter }}</b>&nbsp;&nbsp;{% if inline_admin_form.original %} {{ inline_admin_form.original }}{% endif %}</h3>
34                                 {% spaceless %}
35                                 {% for fieldset in inline_admin_form %}
36                                         {% for line in fieldset %}
37                                                 {% for field in line %}
38                                                         {% if field.is_hidden %} {{ field.field }} {% endif %}
39                                                 {% endfor %}
40                                         {% endfor %}
41                                 {% endfor %}
42                                 {% endspaceless %}
43                                 <div class="tr">
44                                         {% for fieldset in inline_admin_form %}
45                                                 {% for line in fieldset %}
46                                                         {% for field in line %}
47                                                                 <div class="td {{ field.field.name }} {% if field.field.errors %} error{% endif %}">
48                                                                         {% if field.is_readonly %}
49                                                                                 <p>{{ field.contents }}</p>
50                                                                         {% else %}
51                                                                                 {{ field.field }}
52                                                                                 {{ field.field.errors.as_ul }}
53                                                                         {% endif %}
54                                                                 </div>
55                                                         {% endfor %}
56                                                 {% endfor %}
57                                         {% endfor %}
58                                         {% with inline_admin_form.form.content_type as field %}<div class="td {{ field.name }}{% if field.errors %} error{% endif %}">{{ field }}{{ field.errors.as_ul }}</div>{% endwith %}
59                                         {% with inline_admin_form.form.value as field %}<div class="td {{ field.name }}{% if field.errors %} error{% endif %}">{{ field }}{{ field.errors.as_ul }}</div>{% endwith %}
60                                         <div class="td tools">
61                                                 {% spaceless %}
62                                                 <ul class="tools">
63                                                         {% if inline_admin_form.show_url %}<li class="viewsite-link-container"><a href="../../../r/{{ inline_admin_form.original_content_type_id }}/{{ inline_admin_form.original.id }}/" class="icon viewsite-link" title="{% trans 'View on Site' %}"> </a></li>{% endif %}
64                                                         {% if inline_admin_formset.opts.sortable_field_name %}
65                                                                 <li class="drag-handler-container"><a href="javascript://" class="icon drag-handler" title="{% trans 'Move Item' %}"></a></li>
66                                                         {% endif %}
67                                                         {% if inline_admin_formset.formset.can_delete %}<li class="delete-handler-container">{{ inline_admin_form.deletion_field.field }}<a href="javascript://" class="icon {% if inline_admin_form.original %}delete-handler{% else %}remove-handler{% endif %}" title="{% trans 'Remove' %}"> </a>{% endif %}
68                                                 </ul>
69                                                 {% endspaceless %}
70                                         </div>
71                                         {{ inline_admin_form.fk_field.field }}
72                                         {% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
73                                 </div>
74                         </div>
75                 {% endfor %}
76         </div>
77         <div class="module add-item">
78                 <a href="javascript://" class="add-handler">{% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}</a>
79                 <ul class="tools">
80                         <li class="add-handler-container"><a href="javascript://" class="icon add-handler" title="{% trans 'Add Item' %}"> </a></li>
81                 </ul><br clear="all" />
82         </div>
83 </div>
84
85 <script type="text/javascript">
86 (function($) {
87     $(document).ready(function($) {
88         
89         $("#{{ inline_admin_formset.formset.prefix }}-group").grp_inline({
90             prefix: "{{ inline_admin_formset.formset.prefix }}",
91             onBeforeAdded: function(inline) {},
92             onAfterAdded: function(form) {
93                 grappelli.reinitDateTimeFields(form);
94                 grappelli.updateSelectFilter(form);
95                 form.find("input.vForeignKeyRawIdAdminField").grp_related_fk({lookup_url:"{% url grp_related_lookup %}"});
96                 form.find("input.vManyToManyRawIdAdminField").grp_related_m2m({lookup_url:"{% url grp_m2m_lookup %}"});
97                 form.find("input[name*='object_id'][name$='id']").grp_related_generic({lookup_url:"{% url grp_related_lookup %}"});
98             },
99         });
100         
101         {% if inline_admin_formset.opts.sortable_field_name %}
102         $("#{{ inline_admin_formset.formset.prefix }}-group > div.table").sortable({
103             handle: "a.drag-handler",
104             items: "div.dynamic-form",
105             axis: "y",
106             appendTo: 'body',
107             forceHelperSize: true,
108             containment: '#{{ inline_admin_formset.formset.prefix }}-group > div.table',
109             tolerance: 'pointer',
110         });
111         $("#{{ opts.module_name }}_form").bind("submit", function(){
112             var sortable_field_name = "{{ inline_admin_formset.opts.sortable_field_name }}";
113             var i = 0;
114             $("#{{ inline_admin_formset.formset.prefix }}-group").find("div.dynamic-form").each(function(){
115                 var fields = $(this).find("div.td :input[value]");
116                 if (fields.serialize()) {
117                     $(this).find("input[name$='"+sortable_field_name+"']").val(i);
118                     i++;
119                 }
120             });
121         });
122         {% endif %}
123         
124     });
125 })(django.jQuery);
126 </script>