/
javascripts.html
102 lines (93 loc) · 4.44 KB
/
javascripts.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{% load staticfiles ralph_tags %}
{% raven_js %}
<script type="text/javascript">window.__admin_utc_offset__ = "{% filter escapejs %}{% now "Z" %}{% endfilter %}";</script>
<script type="text/javascript">window.__admin_media_prefix__ = "{% static '' %}";</script>
<script type="text/javascript" src="{% static 'admin/js/core.js' %}"></script>
<script type="text/javascript" src="{% static 'admin/js/jquery.js' %}"></script>
<script type="text/javascript" src="{% static 'admin/js/jquery.init.js' %}"></script>
<script type="text/javascript" src="{% static 'admin/js/actions.js' %}"></script>
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
<script type="text/javascript" src="{% static 'admin/js/admin/RelatedObjectLookups.js' %}"></script>
<script type="text/javascript" src="{% static 'vendor/js/jquery.js' %}"></script>
<script type="text/javascript" src="{% static 'src/js/ralph.init.js' %}"></script>
<script type="text/javascript" src="{% static "auto-complete-helpers.js" %}"></script>
<script type="text/javascript" src="{% static 'vendor/js/foundation.min.js' %}"></script>
<script type="text/javascript" src="{% static 'vendor/js/modernizr.js' %}"></script>
<script type="text/javascript" src="{% static 'src/js/fill-fields.js' %}"></script>
<script>
(function($){
$(document).ready(function() {
$('#filter-button').bind('click', function() {
/**
* Because Django change_list uses the form to actions and bulk_edit
* and sends the data via POST. All filters work through the GET
* method.
* We have created an additional form which is responsible for
* generating GET parameters for filters.
*
* Cloned data from #filter-container and insert to #filter-form,
* then click submit.
*/
var $form = $('#filter-form');
$form.empty();
var $orginal = $('.filter-container');
var $clone = $orginal.clone();
var $original_selects = $orginal.find('select');
// We have to select the <select> because jQuery.clone() does not copy it.
$clone.find('select').each(function(index, item) {
$(item).val($original_selects.eq(index).val());
});
$('input, select', $clone).each(function(i, item) {
var $item = $(item);
if($item.val())
$item.appendTo($form);
});
$form[0].submit();
});
// If you press "enter" in the filter form field
// run submit on this form. (Default is not working)
$('.filter-container').on('keypress', function(event) {
if(event.keyCode == 13) { // For "enter" key
event.preventDefault();
$('#filter-button').click();
return false;
}
});
$("tr input.action-select").actions();
var initPopupButtons = function() {
$('.add-related').click(function(e) {
e.preventDefault();
showAddAnotherPopup(this);
});
$('.related-lookup').click(function(e) {
e.preventDefault();
showRelatedObjectLookupPopup(this);
});
$('.change-related').click(function(e) {
e.preventDefault();
showRelatedObjectPopup(this);
});
}
initPopupButtons();
$('.add-row a').click(function() {
initPopupButtons();
});
$('.inline-related').each(function() {
var group_id = $(this).data('group-id'),
prefix = $(this).data('prefix'),
add_text = $(this).data('add-text'),
delete_text = $(this).data('delete-text');
(function($) {
$("#" + group_id + "-group .tabular.inline-related tbody tr").tabularFormset({
prefix: prefix,
addText: add_text,
deleteText: delete_text
});
})(django.jQuery);
});
});
})(django.jQuery);
(function($) {
$(document).foundation();
})(ralph.jQuery);
</script>