Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Moves full screen functions in UIUtil

yanas26ff54366b0e
diff --git a/modules/UI/UI.js b/modules/UI/UI.js
index 9e7389d03c..95dec167e2 100644
--- a/modules/UI/UI.js
+++ b/modules/UI/UI.js
@@ -140,36 +140,11 @@ function setupToolbars() {
/**
* Toggles the application in and out of full screen mode
* (a.k.a. presentation mode in Chrome).
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
*/
UI.toggleFullScreen = function() {
- let isFullScreen = document.fullscreenElement
- || document.mozFullScreenElement // current working methods
- || document.webkitFullscreenElement
- || document.msFullscreenElement;
-
- if (isFullScreen) {
- if (document.exitFullscreen) {
- document.exitFullscreen();
- } else if (document.msExitFullscreen) {
- document.msExitFullscreen();
- } else if (document.mozCancelFullScreen) {
- document.mozCancelFullScreen();
- } else if (document.webkitExitFullscreen) {
- document.webkitExitFullscreen();
- }
- } else {
- if (document.documentElement.requestFullscreen) {
- document.documentElement.requestFullscreen();
- } else if (document.documentElement.msRequestFullscreen) {
- document.documentElement.msRequestFullscreen();
- } else if (document.documentElement.mozRequestFullScreen) {
- document.documentElement.mozRequestFullScreen();
- } else if (document.documentElement.webkitRequestFullscreen) {
- document.documentElement
- .webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
- }
- }
+ (UIUtil.isFullScreen())
+ ? UIUtil.exitFullScreen()
+ : UIUtil.enterFullScreen();
};
/**
@@ -415,12 +390,8 @@ function bindEvents() {
$(document).on(
'webkitfullscreenchange mozfullscreenchange fullscreenchange',
() => {
- let isFullScreen = document.fullscreenElement
- || document.mozFullScreenElement
- || document.webkitFullscreenElement
- || document.msFullscreenElement;
-
- eventEmitter.emit(UIEvents.FULLSCREEN_TOGGLED, isFullScreen);
+ eventEmitter.emit( UIEvents.FULLSCREEN_TOGGLED,
+ UIUtil.isFullScreen());
onResize();
}
diff --git a/modules/UI/util/UIUtil.js b/modules/UI/util/UIUtil.js
index b7ff1fb0e5..5644833555 100644
--- a/modules/UI/util/UIUtil.js
+++ b/modules/UI/util/UIUtil.js
@@ -240,13 +240,53 @@ const TOOLTIP_POSITIONS = {
window.location.href = url;
},
- isFullScreen () {
- return document.fullScreen
- || document.mozFullScreen
- || document.webkitIsFullScreen;
- },
+ /**
+ * Indicates if we're currently in full screen mode.
+ *
+ * @return {boolean} {true} to indicate that we're currently in full screen
+ * mode, {false} otherwise
+ */
+ isFullScreen() {
+ return document.fullscreenElement
+ || document.mozFullScreenElement
+ || document.webkitFullscreenElement
+ || document.msFullscreenElement;
+ },
+
+ /**
+ * Exits full screen mode.
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
+ */
+ exitFullScreen() {
+ if (document.exitFullscreen) {
+ document.exitFullscreen();
+ } else if (document.msExitFullscreen) {
+ document.msExitFullscreen();
+ } else if (document.mozCancelFullScreen) {
+ document.mozCancelFullScreen();
+ } else if (document.webkitExitFullscreen) {
+ document.webkitExitFullscreen();
+ }
+ },
+
+ /**
+ * Enter full screen mode.
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
+ */
+ enterFullScreen() {
+ if (document.documentElement.requestFullscreen) {
+ document.documentElement.requestFullscreen();
+ } else if (document.documentElement.msRequestFullscreen) {
+ document.documentElement.msRequestFullscreen();
+ } else if (document.documentElement.mozRequestFullScreen) {
+ document.documentElement.mozRequestFullScreen();
+ } else if (document.documentElement.webkitRequestFullscreen) {
+ document.documentElement
+ .webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
+ }
+ },
- /**
+ /**
* Create html attributes string out of object properties.
* @param {Object} attrs object with properties
* @returns {String} string of html element attributes