| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 | /* global $ */
/**
 * Created by hristo on 12/22/14.
 */
const UIUtil = {
    /**
     * Returns the available video width.
     */
    getAvailableVideoWidth() {
        return window.innerWidth;
    },
    /**
     * Escapes the given text.
     */
    escapeHtml(unsafeText) {
        return $('<div/>').text(unsafeText)
            .html();
    },
    /**
     * 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];
        if (firstChild) {
            container.insertBefore(newChild, firstChild);
        } else {
            container.appendChild(newChild);
        }
    },
    /**
     * 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;
    },
    /**
     * 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
            || document.mozFullScreenElement
            || document.webkitFullscreenElement
            || document.msFullscreenElement);
    },
    /**
     * 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;
    }
};
export default UIUtil;
 |