-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.js
More file actions
66 lines (55 loc) · 1.61 KB
/
Copy pathplugin.js
File metadata and controls
66 lines (55 loc) · 1.61 KB
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
import Inspire from "@inspirejs/core";
import { enterPresenterView, onPresenterSlidechange } from "./presenter-ui.js";
export const hasCSS = true;
Inspire.hooks.add({
"init-end": me => {
if (window.name === "projector" && window.opener && opener.Inspire) {
// Projector window was reloaded
document.body.classList.add("projector");
Inspire.presenter = opener;
Inspire.presenter.Inspire.projector = window;
}
},
keyup: env => {
// Ctrl+P : Open Presenter view
if (env.letter === "P") {
// Open new window for projector view
Inspire.projector = open(location, "projector");
// Get the focus back
window.focus();
// Switch this one to presenter view
enterPresenterView();
}
},
slidechange: env => {
let otherWindow = Inspire.projector || Inspire.presenter;
if (Inspire.isActive && otherWindow) {
// Sync slide navigation
otherWindow.Inspire.goto(env.which);
}
onPresenterSlidechange();
},
"gotoitem-end": env => {
let otherWindow = Inspire.projector || Inspire.presenter;
if (Inspire.isActive && otherWindow) {
// Sync slide item navigation
otherWindow.Inspire.gotoItem(env.which);
}
},
});
// Track whether presenter or projector is the active window
addEventListener("focus", _ => {
Inspire.isActive = true;
// If this window is focused, no other can be
if (Inspire.projector) {
Inspire.projector.Inspire.isActive = false;
}
else if (Inspire.presenter) {
Inspire.presenter.Inspire.isActive = false;
}
});
addEventListener("blur", _ => {
Inspire.isActive = false;
// If this window is not focused,
// we cannot make assumptions about which one is.
});