Skip to content

Commit f58cef8

Browse files
committed
Fix: show next reading link in PreTeXt books
1 parent 804f706 commit f58cef8

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

bases/rsptx/interactives/runestone/common/js/bookfuncs.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ function addReadingList() {
4141
cur_path_parts[cur_path_parts.length - 2] +
4242
"/" +
4343
cur_path_parts[cur_path_parts.length - 1];
44+
// if body has pretext class, then strip the leading path parts from each of the strings in eBookConfig.readings
45+
let body = document.getElementsByTagName("body")[0];
46+
let ptxbook = false;
47+
if (body.classList.contains("pretext")) {
48+
ptxbook = true;
49+
eBookConfig.readings = eBookConfig.readings.map(r => r.split("/").pop());
50+
name = name.split("/").pop();
51+
}
52+
4453
let position = eBookConfig.readings.indexOf(name);
4554
let num_readings = eBookConfig.readings.length;
4655
if (position == eBookConfig.readings.length - 1) {
@@ -56,17 +65,28 @@ function addReadingList() {
5665
nxt_link = path_parts.join("/");
5766
l = $("<a />", {
5867
name: "link",
59-
class: "btn btn-lg ' + 'buttonConfirmCompletion'",
68+
class: "btn btn-lg reading-navigation buttonConfirmCompletion",
6069
href: nxt_link,
6170
text: `Continue to page ${
6271
position + 2
6372
} of ${num_readings} in the reading assignment.`,
6473
});
6574
} else {
6675
l = $("<div />", {
76+
class: "reading-navigation no-assignment",
6777
text: "This page is not part of the last reading assignment you visited.",
6878
});
6979
}
80+
// check the body tag to see if it has a pretext class (no jquery)
81+
if (ptxbook) {
82+
//append l to the body
83+
let pc = document.getElementById("scprogresscontainer");
84+
if (pc) {
85+
pc.style.marginBottom = "20px";
86+
}
87+
pc.appendChild(l[0]);
88+
return;
89+
}
7090
$("#main-content").append(l);
7191
}
7292
}

0 commit comments

Comments
 (0)