jiti-meet/modules/UI/util/UIUtil.js

79 lines
2.1 KiB
JavaScript
Raw Normal View History

/* global $ */
/**
2015-01-07 14:54:03 +00:00
* Created by hristo on 12/22/14.
*/
const UIUtil = {
2015-12-25 16:55:45 +00:00
2015-01-07 14:54:03 +00:00
/**
* Returns the available video width.
*/
getAvailableVideoWidth() {
2016-11-04 16:13:57 +00:00
return window.innerWidth;
},
2015-01-23 12:01:44 +00:00
/**
* Escapes the given text.
*/
escapeHtml(unsafeText) {
return $('<div/>').text(unsafeText)
.html();
2015-01-23 12:01:44 +00:00
},
/**
* Inserts given child element as the first one into the container.
* @param container the container to which new child element will be added
* @param newChild the new element that will be inserted into the container
*/
prependChild(container, newChild) {
const firstChild = container.childNodes[0];
2020-04-17 01:15:07 +00:00
let result;
if (firstChild) {
2020-04-17 01:15:07 +00:00
result = container.insertBefore(newChild, firstChild);
} else {
2020-04-17 01:15:07 +00:00
result = container.appendChild(newChild);
}
2020-04-17 01:15:07 +00:00
return result;
},
/**
* Redirects to a given URL.
*
* @param {string} url - The redirect URL.
* NOTE: Currently used to redirect to 3rd party location for
* authentication. In most cases redirectWithStoredParams action must be
* used instead of this method in order to preserve curent URL params.
*/
redirect(url) {
window.location.href = url;
},
2015-12-25 16:55:45 +00:00
2016-10-13 22:28:24 +00:00
/**
* 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 Boolean(document.fullscreenElement
2016-10-13 22:28:24 +00:00
|| document.mozFullScreenElement
|| document.webkitFullscreenElement
|| document.msFullscreenElement);
2016-10-13 22:28:24 +00:00
},
2016-04-08 15:55:19 +00:00
/**
* Checks if the given DOM element is currently visible. The offsetParent
* will be null if the "display" property of the element or any of its
* parent containers is set to "none". This method will NOT check the
* visibility property though.
* @param {el} The DOM element we'd like to check for visibility
*/
isVisible(el) {
return el.offsetParent !== null;
2016-04-08 15:55:19 +00:00
}
};
2015-12-14 12:26:50 +00:00
export default UIUtil;