SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 03417a6b authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Improve jQuery loading

parent 2a58c2bc
No related branches found
No related tags found
No related merge requests found
......@@ -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' %}
......
......@@ -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 %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment