Merge pull request #231 from whs/master

Moved inline css/javascripts out to their own files
This commit is contained in:
Camilo Nova 2017-08-09 18:53:05 -05:00 committed by GitHub
commit f0defe80fa
4 changed files with 38 additions and 21 deletions

View file

@ -0,0 +1,15 @@
#result_list .changed {
background-color: #ffc;
}
#changelist table thead th .text {
padding: 2px 5px;
}
#changelist table tbody td:first-child {
text-align: left;
}
#changelist-form ul.errorlist {
margin: 0 !important;
}
.help {
font-weight: normal !important;
}

View file

@ -0,0 +1,17 @@
(function($) {
'use strict';
$(function() {
$('#content-main').on('click', '.reset-link', function(e) {
e.preventDefault();
var field = $('#' + this.dataset.fieldId);
if (field.attr('type') === 'checkbox') {
field.prop('checked', this.dataset.default === 'true');
} else {
field.val(this.dataset.default);
}
});
});
})(django.jQuery);

View file

@ -6,23 +6,7 @@
<link rel="stylesheet" type="text/css" href="{% static 'admin/css/changelists.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'admin/css/forms.css' %}" />
{{ media.css }}
<style>
#result_list .changed {
background-color: #ffc;
}
#changelist table thead th .text {
padding: 2px 5px;
}
#changelist table tbody td:first-child {
text-align: left;
}
#changelist-form ul.errorlist {
margin: 0 !important;
}
.help {
font-weight: normal !important;
}
</style>
<link rel="stylesheet" type="text/css" href="{% static 'admin/css/constance.css' %}" />
{% endblock %}
{% block extrahead %}
@ -30,6 +14,7 @@
<script type="text/javascript" src="{{ jsi18nurl|default:'../../jsi18n/' }}"></script>
{{ block.super }}
{{ media.js }}
<script type="text/javascript" src="{% static 'admin/js/constance.js' %}"></script>
{% endblock %}
{% block bodyclass %}change-list{% endblock %}

View file

@ -20,10 +20,10 @@
{{ item.form_field.errors }}
{{ item.form_field }}
<br>
<a href="#" onClick="
document.getElementById('{{ item.form_field.auto_id }}').{% if item.is_checkbox %}checked =
{% if item.raw_default %} true {% else %} false {% endif %}
{% else %}value = '{{ item.default|escapejs }}'{% endif %}; return false;">Reset to default</a>
<a href="#" class="reset-link" data-field-id="{{ item.form_field.auto_id }}" data-default="{% spaceless %}
{% if item.is_checkbox %}{% if item.raw_default %} true {% else %} false {% endif %}
{% else %}{{ item.default }}{% endif %}
{% endspaceless %}">Reset to default</a>
</td>
<td>
{% if item.modified %}