From 03417a6bfae33620a511c85d5716167a9a4f2b00 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Wed, 27 Jun 2018 09:57:41 +0200
Subject: [PATCH] Improve jQuery loading

---
 scipost/templates/scipost/bare_base.html      |  4 +-
 .../templates/submissions/report_form.html    | 85 ++++++++++---------
 2 files changed, 46 insertions(+), 43 deletions(-)

diff --git a/scipost/templates/scipost/bare_base.html b/scipost/templates/scipost/bare_base.html
index 5efb4b3ae..c8ea52e70 100644
--- a/scipost/templates/scipost/bare_base.html
+++ b/scipost/templates/scipost/bare_base.html
@@ -9,8 +9,8 @@
     <link href="https://fonts.googleapis.com/css?family=Merriweather+Sans:300,400,700" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="{% static 'scipost/SciPost.css' %}" />
     <link rel="stylesheet" type="text/css" href="{% static 'fa/css/font-awesome.min.css' %}" />
-    <script async src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
-    <script async src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
+    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
 
     {% render_bundle 'main' 'css' %}
 
diff --git a/submissions/templates/submissions/report_form.html b/submissions/templates/submissions/report_form.html
index 12d790a0d..e4013bda5 100644
--- a/submissions/templates/submissions/report_form.html
+++ b/submissions/templates/submissions/report_form.html
@@ -10,47 +10,6 @@
 {% block pagetitle %}: submit report{% endblock pagetitle %}
 
 {% block content %}
-    <script>
-        $(function(){
-            function set_preview(el) {
-                $('[data-receive$="' + $(el).attr('id').split('id_')[1] + '"]').text($(el).val())
-            }
-            function set_preview_select(el) {
-                $('[data-receive$="' + $(el).attr('id').split('id_')[1] + '"]').text($(el).find('option:selected').text())
-            }
-            function update_identity_preview(show_identity) {
-                $('[data-receive="report-identity"] [if-anonymous]').hide();
-                if (show_identity) {
-                    $('[data-receive="report-identity"] [if-anonymous="false"]').show();
-                } else {
-                    $('[data-receive="report-identity"] [if-anonymous="true"]').show();
-                }
-            }
-            $('#id_weaknesses, #id_strengths, #id_report, #id_requested_changes').on('keyup', function(){
-                set_preview(this)
-                if (typeof MathJax !== "undefined") {
-                    // First trigger will fail since MathJax is loaded in the footer.
-                    MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
-                }
-            }).trigger('keyup');
-            $('#id_validity, #id_originality, #id_significance, #id_clarity, #id_formatting, #id_grammar').on('change', function(){
-                set_preview_select(this);
-            }).trigger('change');
-
-            $('input[name$="anonymous"]').on('change', function() {
-                $('.anonymous-alert').show()
-                .children('h3').hide()
-                if ($(this).prop('checked')) {
-                    update_identity_preview(false);
-                    $('.anonymous-yes').show();
-                } else {
-                    update_identity_preview(true);
-                    $('.anonymous-no').show();
-                }
-            }).trigger('change');
-        });
-    </script>
-
 
 {% if user.is_authenticated %}
     <div class="row">
@@ -122,3 +81,47 @@
 {% endif %}
 
 {% endblock %}
+
+
+{% block footer_script %}
+<script type="text/javascript">
+    $(function(){
+        function set_preview(el) {
+            $('[data-receive$="' + $(el).attr('id').split('id_')[1] + '"]').text($(el).val())
+        }
+        function set_preview_select(el) {
+            $('[data-receive$="' + $(el).attr('id').split('id_')[1] + '"]').text($(el).find('option:selected').text())
+        }
+        function update_identity_preview(show_identity) {
+            $('[data-receive="report-identity"] [if-anonymous]').hide();
+            if (show_identity) {
+                $('[data-receive="report-identity"] [if-anonymous="false"]').show();
+            } else {
+                $('[data-receive="report-identity"] [if-anonymous="true"]').show();
+            }
+        }
+        $('#id_weaknesses, #id_strengths, #id_report, #id_requested_changes').on('keyup', function(){
+            set_preview(this)
+            if (typeof MathJax !== "undefined") {
+                // First trigger will fail since MathJax is loaded in the footer.
+                MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
+            }
+        }).trigger('keyup');
+        $('#id_validity, #id_originality, #id_significance, #id_clarity, #id_formatting, #id_grammar').on('change', function(){
+            set_preview_select(this);
+        }).trigger('change');
+
+        $('input[name$="anonymous"]').on('change', function() {
+            $('.anonymous-alert').show()
+            .children('h3').hide()
+            if ($(this).prop('checked')) {
+                update_identity_preview(false);
+                $('.anonymous-yes').show();
+            } else {
+                update_identity_preview(true);
+                $('.anonymous-no').show();
+            }
+        }).trigger('change');
+    });
+</script>
+{% endblock %}
-- 
GitLab