From 007c11f04a256a2e8704a9b26320e5c0e3457994 Mon Sep 17 00:00:00 2001 From: pacien Date: Thu, 26 Oct 2023 21:04:02 +0200 Subject: treewide: use fat arrow syntax --- beamer/viewer/stage/actions.js | 28 ++++++++++------------------ beamer/viewer/stage/stage.js | 29 +++++++++++++---------------- 2 files changed, 23 insertions(+), 34 deletions(-) (limited to 'beamer/viewer/stage') 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 @@ /* * Beamer Viewer, a web-based PDF presentation viewer - * Copyright (C) 2018 Pacien TRAN-GIRARD + * Copyright (C) 2018-2023 Pacien TRAN-GIRARD * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -27,10 +27,7 @@ class ActionEventHandler { class KeyboardEventHandler extends ActionEventHandler { register(window) { - const self = this; - window.addEventListener("keydown", function(event) { - self._onCommand(event); - }) + window.addEventListener("keydown", event => this._onCommand(event)); } _onCommand(keyboardEvent) { @@ -52,10 +49,7 @@ class KeyboardEventHandler extends ActionEventHandler { class MouseClickEventHandler extends ActionEventHandler { register(window) { - const self = this; - window.addEventListener("click", function(event) { - self._onCommand(event); - }) + window.addEventListener("click", event => this._onCommand(event)); } _onCommand(mouseEvent) { @@ -71,24 +65,22 @@ class TouchSwipeEventHandler extends ActionEventHandler { } register(window) { - const self = this; - - window.addEventListener("touchstart", function(event) { + window.addEventListener("touchstart", event => { event.preventDefault(); - self._onTouchStart(event); + this._onTouchStart(event); }); - window.addEventListener("touchmove", function(event) { + window.addEventListener("touchmove", event => { event.preventDefault(); - self._onTouchMove(event); + this._onTouchMove(event); }); - window.addEventListener("touchend", function(event) { + window.addEventListener("touchend", event => { event.preventDefault(); - self._onTouchEnd(); + this._onTouchEnd(); }); - window.addEventListener("touchcancel", function(event) { + window.addEventListener("touchcancel", event => { event.preventDefault(); }); } 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 { if (this.projector == null) alert("Please allow pop-ups, then refresh this page."); - const self = this; - this.projector.addEventListener("load", function() { - self.audienceScreen = new Screen(self.projector, false, false); - self.presenterScreen = new Screen(window, true, true); - self._watchDetach(); - self.onReady(); + this.projector.addEventListener("load", () => { + this.audienceScreen = new Screen(this.projector, false, false); + this.presenterScreen = new Screen(window, true, true); + this._watchDetach(); + this.onReady(); }); this._registerEventHandler(window); @@ -56,20 +55,18 @@ class Stage { _registerEventHandler(window) { if (window == null) return; - this.eventHandlers.forEach(function(eventHandler) { - eventHandler.register(window); - }); + this.eventHandlers + .forEach(eventHandler => eventHandler.register(window)); } _watchDetach() { - const self = this; - window.addEventListener("beforeunload", function() { - self._setMessage(self.projector, "Controller detached"); - }); + window.addEventListener("beforeunload", () => + this._setMessage(this.projector, "Controller detached") + ); - this.projector.addEventListener("beforeunload", function() { - self._setMessage(window, "Viewer detached"); - }); + this.projector.addEventListener("beforeunload", () => + this._setMessage(window, "Viewer detached") + ); } _setMessage(window, message) { -- cgit v1.2.3