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

Commit ae98363

Browse files
Update next/previous navigation links
Prevent duplicate links from appearing. Rework code to use css media querries and plain html and rely less on js
1 parent cb22d71 commit ae98363

4 files changed

Lines changed: 56 additions & 89 deletions

File tree

runestone/common/css/runestone-custom-sphinx-bootstrap.css

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -660,23 +660,51 @@ div.flash {
660660
display: inline;
661661
bottom: 65px;
662662
position: fixed;
663+
opacity: 0.4;
663664
}
664665

665-
#relations-next {
666+
.navLink:hover {
667+
opacity: 1;
668+
}
669+
670+
.navLink a {
671+
display: inline-block;
672+
background-color: white;
673+
border-style:solid;
674+
border-color:lightgrey;
675+
border-width:2px;
676+
width:100px;
677+
height:50px
678+
}
679+
680+
.relations-next {
666681
right: 35px;
667682
}
668683

669-
#relations-prev {
684+
.relations-prev {
670685
left: 35px;
671686
}
672687

688+
.nextprev-list {
689+
margin: 10px;
690+
padding-left: 0;
691+
height: 50px;
692+
}
693+
694+
.nextprev-list-top {
695+
display: none;
696+
}
697+
673698
@media (max-width: 600px) {
674699

675-
/* Styling definitions for chevron function in bookfuncs.js */
700+
.nextprev-list-top {
701+
display: block;
702+
}
703+
676704
.navLink {
677-
z-index: 2;
678-
display: inline;
679-
position: static;
705+
display: inline-block;
706+
bottom: auto;
707+
position: absolute;
680708
}
681709

682710
ul#top-relations-console,

runestone/common/js/bookfuncs.js

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -29,47 +29,6 @@
2929
3030
*/
3131

32-
//
33-
// Chevron functions - Must correspond with width in runestone-custom-sphinx-bootstrap.css
34-
//
35-
$(function () {
36-
var resizeWindow = false;
37-
var resizeWidth = 600;
38-
$(window)
39-
.on("resize", function (event) {
40-
if ($(window).width() <= resizeWidth && resizeWindow == false) {
41-
resizeWindow = true;
42-
var topPrev = $("#relations-prev")
43-
.clone()
44-
.attr("id", "top-relations-prev");
45-
var topNext = $("#relations-next")
46-
.clone()
47-
.attr("id", "top-relations-next");
48-
$("#relations-prev, #relations-next").hide();
49-
var bottomPrev = topPrev
50-
.clone()
51-
.attr("id", "bottom-relations-prev");
52-
var bottomNext = topNext
53-
.clone()
54-
.attr("id", "bottom-relations-next");
55-
$("div#main-content > div").prepend(topPrev, topNext);
56-
$("#top-relations-prev, #top-relations-next").wrapAll(
57-
'<ul id="top-relations-console"></ul>'
58-
);
59-
$("div#main-content > div").append(bottomPrev, bottomNext);
60-
$("#bottom-relations-prev, #bottom-relations-next").wrapAll(
61-
'<ul id="bottom-relations-console"></ul>'
62-
);
63-
}
64-
if ($(window).width() >= resizeWidth + 1 && resizeWindow == true) {
65-
resizeWindow = false;
66-
$("#top-relations-console, #bottom-relations-console").remove();
67-
$("#relations-prev, #relations-next").show();
68-
}
69-
})
70-
.resize();
71-
});
72-
7332
//
7433
// Page decoration functions
7534
//

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,11 @@
293293
<div class="container" id="continue-reading"></div>
294294

295295
<div class="container" id="main-content" role="main">
296+
297+
{% with place='top' %}
298+
{% include "subchapter.html" %}
299+
{% endwith %}
300+
296301
<!-- Ad Serving for Runestone Campaign -->
297302
{% if dynamic_pages == 'True' %}
298303
{% raw %}
@@ -314,9 +319,9 @@
314319
<div id=scprogresscontainer>
315320
You have attempted <span id=scprogresstotal></span> of <span id=scprogressposs></span> activities on this page <div id="subchapterprogress"></div>
316321
</div>
317-
{% block nextprevious %}
318-
{% include "subchapter.html" %}
319-
{% endblock %}
322+
{% with place='bottom'%}
323+
{% include "subchapter.html" %}
324+
{% endwith %}
320325
</div>
321326
{%- endblock %}
322327

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,24 @@
1+
<ul role="navigation" class="nextprev-list nextprev-list-{{place}}" aria-label="Change page">
12
{%- if prev %}
2-
<ul>
3-
<li id="relations-prev" style="opacity:0.4" onmouseover="mouseOverPrev()" onmouseout="mouseOutPrev()"class="navLink" title='Previous Section - {{ prev.title|extractText|extractTextII }}' data-toggle="tooltip">
4-
<a href="{{ prev.link|e }}" aria-label="{{ prev.title|extractText|extractTextII }}">
5-
<div style="background-color: white; border-style:solid; border-color:lightgrey; border-width:2px; width:100px; height:50px">
6-
<i class='prevNav glyphicon glyphicon-chevron-left' style="top:50%; transform:translateY(-50%)translateX(-50%); left: 50%; color:black;"></i>
7-
</div>
8-
</a>
9-
</li>
10-
</ul>
11-
12-
{% endif %}
3+
<li id="relations-prev-{{place}}" class="relations-prev navLink" title='Previous Section - {{ prev.title|extractText|extractTextII }}' data-toggle="tooltip">
4+
<a href="{{ prev.link|e }}" aria-label="Previous - {{ prev.title|extractText|extractTextII }}">
5+
<i class='prevNav glyphicon glyphicon-chevron-left' style="top:50%; transform:translateY(-50%)translateX(-50%); left: 50%; color:black;"></i>
6+
</a>
7+
</li>
8+
{% endif %}
139

1410
{%- if next %}
15-
<ul>
16-
<li id="relations-next" style="opacity:0.4" onmouseover="mouseOverNext()" onmouseout="mouseOutNext()" class="navLink" title='Next Section - {{ next.title|extractText|extractTextII }}' data-toggle="tooltip" >
17-
<a href="{{ next.link|e }}" aria-label="{{ next.title|extractText|extractTextII }}">
18-
<div style="background-color: white; border-style:solid; border-color:lightgrey; border-width:2px; width:100px; height:50px">
19-
<i id="relationsNextIcon" class='nextNav glyphicon glyphicon-chevron-right' style="top:50%; transform:translateY(-50%)translateX(-50%); left: 50%; color:black; "></i>
20-
</div>
11+
<li id="relations-next-{{place}}" class="relations-next navLink" title='Next Section - {{ next.title|extractText|extractTextII }}' data-toggle="tooltip" >
12+
<a href="{{ next.link|e }}" aria-label="Next - {{ next.title|extractText|extractTextII }}">
13+
<i id="relationsNextIcon" class='nextNav glyphicon glyphicon-chevron-right' style="top:50%; transform:translateY(-50%)translateX(-50%); left: 50%; color:black; "></i>
2114
</a>
2215
</li>
23-
</ul>
24-
2516
{%- endif %}
17+
</ul>
2618

2719
<script>
28-
document.addEventListener('load', (event) => {
29-
$('#relations-prev').tooltip({'placement':'right', 'selector': '', 'delay': { show: 100, hide: 50}});
30-
$('#relations-next').tooltip({'placement':'left', 'selector': '', 'delay': { show: 100, hide: 50}});
20+
window.addEventListener('load', (event) => {
21+
$('#relations-prev-{{place}}').tooltip({'placement': 'right', 'delay': { show: 100, hide: 50}});
22+
$('#relations-next-{{place}}').tooltip({'placement': 'left', 'delay': { show: 100, hide: 50}});
3123
});
3224
</script>
33-
34-
<script>
35-
function mouseOverPrev() {
36-
document.getElementById("relations-prev").style.opacity=1;
37-
}
38-
39-
function mouseOutPrev() {
40-
document.getElementById("relations-prev").style.opacity=0.4;
41-
}
42-
function mouseOverNext() {
43-
document.getElementById("relations-next").style.opacity=1;
44-
}
45-
46-
function mouseOutNext() {
47-
document.getElementById("relations-next").style.opacity=0.4;
48-
}
49-
</script>

0 commit comments

Comments
 (0)