-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbreadcrumb.js
42 lines (37 loc) · 1.37 KB
/
breadcrumb.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"use strict";
/**
* A plugin which adds breadcrumbs to the presentation.
*
* @author sedrubal
*/
const RevealBreadcrumb =
window.RevealBreadcrumb ||
(function () {
// var options = window.Reveal.getConfig().breadcrumb || {};
// create breadcrumb bar
const breadcrumb_bar = document.createElement("div");
breadcrumb_bar.classList.add("breadcrumb");
document.getElementsByClassName("reveal")[0].appendChild(breadcrumb_bar);
// change breadcrumb text on slide change
window.Reveal.addEventListener("slidechanged", function (event) {
update_breadcrumb(event.currentSlide);
});
// update innerHTML of all .breadcrumb
function update_breadcrumb(currentSlide) {
const bs = document.getElementsByClassName("breadcrumb");
for (var i = 0; i < bs.length; i++) {
if (
currentSlide.dataset["nobreadcrumb"] === undefined &&
currentSlide.parentElement.dataset["nobreadcrumb"] === undefined
) {
bs[i].innerHTML = currentSlide.id
.replace(/:/g, " › ")
.replace(/_/g, " ");
bs[i].style["opacity"] = 1;
} else {
bs[i].style["opacity"] = 0;
}
}
}
update_breadcrumb(window.Reveal.getCurrentSlide());
})();