Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit e73cd3b

Browse files
Fixes for html and injected html that expect jquery to be loaded as page body is being parsed
1 parent b894bdc commit e73cd3b

7 files changed

Lines changed: 40 additions & 24 deletions

File tree

runestone/animation/chart.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
// $("#visualization").gchart({type: 'graphviz', series: [$.gchart.series([20, 50, 30])]});
1919
// label: '<f0> left | <f1> middle | <f2> right'
2020

21-
$('#visualization').gchart($.gchart.graphviz(true,
21+
document.addEventListener('load', (event) => {
22+
$('#visualization').gchart($.gchart.graphviz(true,
2223
{
2324
struct1: {label: '<f0> left |<f1> middle |<f2> right'},
2425
struct2: {label: '<f0> one|<f1> two'},
@@ -32,6 +33,7 @@
3233
node: {shape: 'record'}
3334
}
3435
));
36+
});
3537

3638

3739
// $('#visualization').gchart($.gchart.graphviz(true,

runestone/animation/jqchart/gChartBasic.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
</style>
99
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
1010
<script type="text/javascript" src="jquery.gchart.js"></script>
11-
<script type="text/javascript">
11+
<script>
12+
document.addEventListener('load', (event) => {
1213
$(function () {
1314
$('#basicGChart').gchart({type: 'line', maxValue: 40,
1415
title: 'Weather for|Brisbane, Australia', titleColor: 'green',
@@ -27,6 +28,7 @@
2728
$.gchart.axis('right', ['mm'], [50], 'blue', 'left')],
2829
legend: 'right'});
2930
});
31+
});
3032
</script>
3133
</head>
3234
<body>

runestone/common/project_template/_templates/plugin_layouts/sphinx_bootstrap/layout.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@
392392
{% endif %}
393393
{% endif %}
394394

395-
<script> runestoneComponents.getSwitch(); </script>
395+
<script>
396+
document.addEventListener('load', (event) => {
397+
runestoneComponents.getSwitch();
398+
});
399+
</script>
396400

397401
{% endblock %}

runestone/common/project_template/_templates/plugin_layouts/sphinx_bootstrap/relations.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
'delay': { show: 100, hide: 50}
2626
};
2727

28-
$('#relations-prev').tooltip(opts);
29-
$('#relations-next').tooltip(opts);
28+
document.addEventListener('load', (event) => {
29+
$('#relations-prev').tooltip(opts);
30+
$('#relations-next').tooltip(opts);
31+
});
3032
</script>

runestone/common/project_template/_templates/plugin_layouts/sphinx_bootstrap/subchapter.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
{%- endif %}
2626

2727
<script type="text/javascript">
28-
28+
document.addEventListener('load', (event) => {
2929
$('#relations-prev').tooltip({'placement':'right', 'selector': '', 'delay': { show: 100, hide: 50}});
3030
$('#relations-next').tooltip({'placement':'left', 'selector': '', 'delay': { show: 100, hide: 50}});
31-
31+
});
3232
</script>
3333

3434
<script>

runestone/disqus/disqus.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@
5656
"""
5757

5858
DISQUS_LINK = """
59-
<a href="#disqus_thread" class='disqus_thread_link' data-disqus-identifier="%(identifier)s" onclick="%(identifier)s_disqus(this);">Show Comments</a>
60-
<script type='text/javascript'>
59+
<a href="#disqus_thread" class="disqus_thread_link" data-disqus-identifier="%(identifier)s" onclick="%(identifier)s_disqus(this);">Show Comments</a>
60+
<script>
61+
document.addEventListener('load', (event) => {
6162
$("a[data-disqus-identifier='%(identifier)s']").attr('data-disqus-identifier', '%(identifier)s_' + eBookConfig.course);
63+
});
6264
</script>
6365
"""
6466

runestone/video/video.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,37 @@ def setup(app):
4848
<div class='video-play-overlay'></div>
4949
</a>
5050
<script>
51+
document.addEventListener('load', (event) => {
5152
jQuery(function ($) {
5253
$('#%(divid)s_thumb').click(function (e) {
5354
$('#%(divid)s').modal();
5455
return false;
5556
});
5657
});
58+
});
5759
</script>
5860
5961
"""
6062

6163
INLINE = """\
6264
<script>
63-
jQuery(function($) {
64-
var rb = new RunestoneBase();
65-
$('#%(divid)s_thumb').click(function(e) {
66-
$('#%(divid)s').show();
67-
$('#%(divid)s_thumb').hide();
68-
rb.logBookEvent({'event':'video','act':'play','div_id': '%(divid)s'});
69-
// Log the run event
70-
});
71-
$('#%(divid)s video').one("click", function(){
72-
this.play();
73-
});
74-
$('#%(divid)s video').one("play", function(){
75-
rb.logBookEvent({'event':'video','act':'play','div_id': '%(divid)s'});
76-
});
77-
});
65+
document.addEventListener('load', (event) => {
66+
jQuery(function($) {
67+
var rb = new RunestoneBase();
68+
$('#%(divid)s_thumb').click(function(e) {
69+
$('#%(divid)s').show();
70+
$('#%(divid)s_thumb').hide();
71+
rb.logBookEvent({'event':'video','act':'play','div_id': '%(divid)s'});
72+
// Log the run event
73+
});
74+
$('#%(divid)s video').one("click", function(){
75+
this.play();
76+
});
77+
$('#%(divid)s video').one("play", function(){
78+
rb.logBookEvent({'event':'video','act':'play','div_id': '%(divid)s'});
79+
});
80+
});
81+
});
7882
</script>
7983
"""
8084
SOURCE = """<source src="%s" type="video/%s"></source>"""

0 commit comments

Comments
 (0)