aboutsummaryrefslogtreecommitdiff
path: root/beamer/viewer/stage
diff options
context:
space:
mode:
authorpacien2023-10-26 21:04:02 +0200
committerpacien2023-10-26 21:16:26 +0200
commit007c11f04a256a2e8704a9b26320e5c0e3457994 (patch)
treeeb51646e2d0bbcbc5abcb81b771d94791c9ca4f2 /beamer/viewer/stage
parent89727493f6dee04e46977c4d283dd35bdfc82c6e (diff)
downloadbeamer-viewer-007c11f04a256a2e8704a9b26320e5c0e3457994.tar.gz
treewide: use fat arrow syntax
Diffstat (limited to 'beamer/viewer/stage')
-rw-r--r--beamer/viewer/stage/actions.js28
-rw-r--r--beamer/viewer/stage/stage.js29
2 files changed, 23 insertions, 34 deletions
diff --git a/beamer/viewer/stage/actions.js b/beamer/viewer/stage/actions.js
index 30634ae..47eda60 100644
--- a/beamer/viewer/stage/actions.js
+++ b/beamer/viewer/stage/actions.js
@@ -1,6 +1,6 @@
1/* 1/*
2 * Beamer Viewer, a web-based PDF presentation viewer 2 * Beamer Viewer, a web-based PDF presentation viewer
3 * Copyright (C) 2018 Pacien TRAN-GIRARD 3 * Copyright (C) 2018-2023 Pacien TRAN-GIRARD
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as 6 * it under the terms of the GNU Affero General Public License as
@@ -27,10 +27,7 @@ class ActionEventHandler {
27 27
28class KeyboardEventHandler extends ActionEventHandler { 28class KeyboardEventHandler extends ActionEventHandler {
29 register(window) { 29 register(window) {
30 const self = this; 30 window.addEventListener("keydown", event => this._onCommand(event));
31 window.addEventListener("keydown", function(event) {
32 self._onCommand(event);
33 })
34 } 31 }
35 32
36 _onCommand(keyboardEvent) { 33 _onCommand(keyboardEvent) {
@@ -52,10 +49,7 @@ class KeyboardEventHandler extends ActionEventHandler {
52 49
53class MouseClickEventHandler extends ActionEventHandler { 50class MouseClickEventHandler extends ActionEventHandler {
54 register(window) { 51 register(window) {
55 const self = this; 52 window.addEventListener("click", event => this._onCommand(event));
56 window.addEventListener("click", function(event) {
57 self._onCommand(event);
58 })
59 } 53 }
60 54
61 _onCommand(mouseEvent) { 55 _onCommand(mouseEvent) {
@@ -71,24 +65,22 @@ class TouchSwipeEventHandler extends ActionEventHandler {
71 } 65 }
72 66
73 register(window) { 67 register(window) {
74 const self = this; 68 window.addEventListener("touchstart", event => {
75
76 window.addEventListener("touchstart", function(event) {
77 event.preventDefault(); 69 event.preventDefault();
78 self._onTouchStart(event); 70 this._onTouchStart(event);
79 }); 71 });
80 72
81 window.addEventListener("touchmove", function(event) { 73 window.addEventListener("touchmove", event => {
82 event.preventDefault(); 74 event.preventDefault();
83 self._onTouchMove(event); 75 this._onTouchMove(event);
84 }); 76 });
85 77
86 window.addEventListener("touchend", function(event) { 78 window.addEventListener("touchend", event => {
87 event.preventDefault(); 79 event.preventDefault();
88 self._onTouchEnd(); 80 this._onTouchEnd();
89 }); 81 });
90 82
91 window.addEventListener("touchcancel", function(event) { 83 window.addEventListener("touchcancel", event => {
92 event.preventDefault(); 84 event.preventDefault();
93 }); 85 });
94 } 86 }
diff --git a/beamer/viewer/stage/stage.js b/beamer/viewer/stage/stage.js
index 3f1a5f5..4882c31 100644
--- a/beamer/viewer/stage/stage.js
+++ b/beamer/viewer/stage/stage.js
@@ -36,12 +36,11 @@ class Stage {
36 if (this.projector == null) 36 if (this.projector == null)
37 alert("Please allow pop-ups, then refresh this page."); 37 alert("Please allow pop-ups, then refresh this page.");
38 38
39 const self = this; 39 this.projector.addEventListener("load", () => {
40 this.projector.addEventListener("load", function() { 40 this.audienceScreen = new Screen(this.projector, false, false);
41 self.audienceScreen = new Screen(self.projector, false, false); 41 this.presenterScreen = new Screen(window, true, true);
42 self.presenterScreen = new Screen(window, true, true); 42 this._watchDetach();
43 self._watchDetach(); 43 this.onReady();
44 self.onReady();
45 }); 44 });
46 45
47 this._registerEventHandler(window); 46 this._registerEventHandler(window);
@@ -56,20 +55,18 @@ class Stage {
56 _registerEventHandler(window) { 55 _registerEventHandler(window) {
57 if (window == null) return; 56 if (window == null) return;
58 57
59 this.eventHandlers.forEach(function(eventHandler) { 58 this.eventHandlers
60 eventHandler.register(window); 59 .forEach(eventHandler => eventHandler.register(window));
61 });
62 } 60 }
63 61
64 _watchDetach() { 62 _watchDetach() {
65 const self = this; 63 window.addEventListener("beforeunload", () =>
66 window.addEventListener("beforeunload", function() { 64 this._setMessage(this.projector, "Controller detached")
67 self._setMessage(self.projector, "Controller detached"); 65 );
68 });
69 66
70 this.projector.addEventListener("beforeunload", function() { 67 this.projector.addEventListener("beforeunload", () =>
71 self._setMessage(window, "Viewer detached"); 68 this._setMessage(window, "Viewer detached")
72 }); 69 );
73 } 70 }
74 71
75 _setMessage(window, message) { 72 _setMessage(window, message) {