mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-07-13 17:42:26 +03:00
Merge pull request #2927 from Andrew-Chen-Wang/defer-js
This commit is contained in:
commit
9ebfd5102c
|
@ -59,12 +59,12 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block javascript %}
|
{% block inline_javascript %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function() {
|
window.addEventListener('DOMContentLoaded',function() {
|
||||||
var message = "{% trans 'Do you really want to remove the selected e-mail address?' %}";
|
const message = "{% trans 'Do you really want to remove the selected e-mail address?' %}";
|
||||||
var actions = document.getElementsByName('action_remove');
|
const actions = document.getElementsByName('action_remove');
|
||||||
if (actions.length) {
|
if (actions.length) {
|
||||||
actions[0].addEventListener("click", function(e) {
|
actions[0].addEventListener("click", function(e) {
|
||||||
if (!confirm(message)) {
|
if (!confirm(message)) {
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})();
|
});
|
||||||
|
|
||||||
$('.form-group').removeClass('row');
|
$('.form-group').removeClass('row');
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -31,6 +31,30 @@
|
||||||
{% endraw %}{% endif %}{% raw %}
|
{% endraw %}{% endif %}{% raw %}
|
||||||
{% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% endcompress %}{% endraw %}{% endif %}{% raw %}
|
{% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% endcompress %}{% endraw %}{% endif %}{% raw %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
<!-- Le javascript
|
||||||
|
================================================== -->
|
||||||
|
{# Placed at the top of the document so pages load faster with defer #}
|
||||||
|
{% block javascript %}
|
||||||
|
{% endraw %}{% if cookiecutter.custom_bootstrap_compilation == "y" and cookiecutter.js_task_runner == "Gulp" %}{% raw %}
|
||||||
|
<!-- Vendor dependencies bundled as one file-->
|
||||||
|
{% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% compress js %}{% endraw %}{% endif %}{% raw %}
|
||||||
|
<script defer src="{% static 'js/vendors.js' %}"></script>
|
||||||
|
{% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% endcompress %}{% endraw %}{% endif %}{% raw %}
|
||||||
|
{% endraw %}{% else %}{% raw %}
|
||||||
|
<!-- Bootstrap JS and its dependencies-->
|
||||||
|
<script defer src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||||
|
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
|
||||||
|
<script defer src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||||
|
|
||||||
|
<!-- Your stuff: Third-party javascript libraries go here -->
|
||||||
|
{% endraw %}{% endif %}{% raw %}
|
||||||
|
|
||||||
|
<!-- place project specific Javascript in this file -->
|
||||||
|
{% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% compress js %}{% endraw %}{% endif %}{% raw %}
|
||||||
|
<script defer src="{% static 'js/project.js' %}"></script>
|
||||||
|
{% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% endcompress %}{% endraw %}{% endif %}{% raw %}
|
||||||
|
|
||||||
|
{% endblock javascript %}
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -92,30 +116,9 @@
|
||||||
|
|
||||||
{% block modal %}{% endblock modal %}
|
{% block modal %}{% endblock modal %}
|
||||||
|
|
||||||
<!-- Le javascript
|
{% block inline_javascript %}
|
||||||
================================================== -->
|
{# Script tags with only code, no src (defer by default) #}
|
||||||
<!-- Placed at the end of the document so the pages load faster -->
|
{% endblock inline_javascript %}
|
||||||
{% block javascript %}
|
|
||||||
{% endraw %}{% if cookiecutter.custom_bootstrap_compilation == "y" and cookiecutter.js_task_runner == "Gulp" %}{% raw %}
|
|
||||||
<!-- Vendor dependencies bundled as one file-->
|
|
||||||
{% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% compress js %}{% endraw %}{% endif %}{% raw %}
|
|
||||||
<script src="{% static 'js/vendors.js' %}"></script>
|
|
||||||
{% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% endcompress %}{% endraw %}{% endif %}{% raw %}
|
|
||||||
{% endraw %}{% else %}{% raw %}
|
|
||||||
<!-- Bootstrap JS and its dependencies-->
|
|
||||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
|
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
|
||||||
|
|
||||||
<!-- Your stuff: Third-party javascript libraries go here -->
|
|
||||||
{% endraw %}{% endif %}{% raw %}
|
|
||||||
|
|
||||||
<!-- place project specific Javascript in this file -->
|
|
||||||
{% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% compress js %}{% endraw %}{% endif %}{% raw %}
|
|
||||||
<script src="{% static 'js/project.js' %}"></script>
|
|
||||||
{% endraw %}{% if cookiecutter.use_compressor == "y" %}{% raw %}{% endcompress %}{% endraw %}{% endif %}{% raw %}
|
|
||||||
|
|
||||||
{% endblock javascript %}
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user