-
Notifications
You must be signed in to change notification settings - Fork 177
/
reveal.js
97 lines (85 loc) · 2.61 KB
/
reveal.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import URI from 'urijs';
export const options = {
fragments: {
default : false,
flag : true,
help : 'Enable or disable fragments',
},
progress: {
default : false,
flag : true,
help : 'Enable or disable progress bar',
},
};
export const create = (page, opts) => new Reveal(page, opts);
class Reveal {
constructor(page, opts) {
this.page = page;
this.fragments = opts.fragments;
this.progress = opts.progress;
}
getName() {
return 'Reveal JS';
}
isActive() {
return this.page.evaluate(_ => {
if (typeof Reveal === 'undefined') {
return false;
}
if (typeof Jupyter !== 'undefined') {
// Let's delegate to the RISE plugin
return false;
}
if (!(typeof Reveal.availableFragments === 'function')) {
console.log('Reveal JS plugin isn\'t compatible with reveal.js version < 2.4.0');
return false;
}
return true;
});
}
configure() {
return this.page.evaluate(config => {
Reveal.configure({
controls : false,
progress : config.progress,
fragments : config.fragments,
transition : 'none',
autoAnimate: false,
});
// This is a workaround to disable the open button of the RevealMenu plugin.
// See the following issue for more details: https://github.com/denehyg/reveal.js-menu/issues/99
var menuOpenButtons = document.getElementsByClassName('slide-menu-button');
for (var i = 0; i < menuOpenButtons.length; i++) {
menuOpenButtons[i].style.display = 'none';
}
},
{
fragments: this.fragments,
progress: this.progress
});
}
slideCount() {
// TODO: the getTotalSlides API does not report the number of slides accurately
// as it does not take stacks and some index-less fragments into account
// getTotalSlides API is only available starting reveal.js version 3.0.0
return this.page.evaluate(_ => typeof Reveal.getTotalSlides === 'function'
? Reveal.getTotalSlides()
: undefined);
}
hasNextSlide() {
// check with fragments option?
return this.page.evaluate(_ => !Reveal.isLastSlide() || Reveal.availableFragments().next);
}
nextSlide() {
return this.page.evaluate(_ => Reveal.next());
}
currentSlideIndex() {
return this.page.evaluate(_ => {
const indices = Reveal.getIndices();
const id = Reveal.getCurrentSlide().getAttribute('id');
return typeof id === 'string' && id.length
? '/' + id
: '/' + indices.h + (indices.v > 0 ? '/' + indices.v : '');
});
}
}