123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- /* global APP, config, $, interfaceConfig */
-
- import UIUtil from '../util/UIUtil';
- import Toolbar from './Toolbar';
- import SideContainerToggler from "../side_pannels/SideContainerToggler";
- import FilmStrip from '../videolayout/FilmStrip.js';
-
- let toolbarTimeoutObject;
- let toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
- /**
- * If true the toolbar will be always displayed
- */
- let alwaysVisibleToolbar = false;
-
- function showDesktopSharingButton() {
- if (APP.conference.isDesktopSharingEnabled &&
- UIUtil.isButtonEnabled('desktop')) {
- $('#toolbar_button_desktopsharing').css({display: "inline-block"});
- } else {
- $('#toolbar_button_desktopsharing').css({display: "none"});
- }
- }
-
- /**
- * Hides the toolbar.
- *
- * @param force {true} to force the hiding of the toolbar without caring about
- * the extended toolbar side panels.
- */
- function hideToolbar(force) {
- if (alwaysVisibleToolbar) {
- return;
- }
-
- clearTimeout(toolbarTimeoutObject);
- toolbarTimeoutObject = null;
-
- if (Toolbar.isHovered() || APP.UI.isRingOverlayVisible()) {
- toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
- } else if (!SideContainerToggler.isVisible() || force) {
- Toolbar.hide();
- $('#subject').animate({top: "-=40"}, 300);
- }
- }
-
- const ToolbarToggler = {
- /**
- * Initializes the ToolbarToggler
- */
- init() {
- alwaysVisibleToolbar = (config.alwaysVisibleToolbar === true);
-
- this._registerWindowClickListeners();
- },
-
- /**
- * Registers click listeners handling the show and hode of toolbars when
- * user clicks outside of toolbar area.
- */
- _registerWindowClickListeners() {
- $(window).click(function() {
- (Toolbar.isEnabled() && Toolbar.isVisible())
- ? hideToolbar(true)
- : this.showToolbar();
- }.bind(this));
-
- Toolbar.registerClickListeners(function(event){
- event.stopPropagation();
- });
- },
-
- /**
- * Sets the value of alwaysVisibleToolbar variable.
- * @param value {boolean} the new value of alwaysVisibleToolbar variable
- */
- setAlwaysVisibleToolbar(value) {
- alwaysVisibleToolbar = value;
- },
-
- /**
- * Resets the value of alwaysVisibleToolbar variable to the default one.
- */
- resetAlwaysVisibleToolbar() {
- alwaysVisibleToolbar = (config.alwaysVisibleToolbar === true);
- },
-
- /**
- * Shows the main toolbar.
- */
- showToolbar () {
- if (interfaceConfig.filmStripOnly) {
- return;
- }
-
- var updateTimeout = false;
- if (Toolbar.isEnabled() && !Toolbar.isVisible()) {
- Toolbar.show();
- $('#subject').animate({top: "+=40"}, 300);
- updateTimeout = true;
- }
-
- if (updateTimeout) {
- if (toolbarTimeoutObject) {
- clearTimeout(toolbarTimeoutObject);
- toolbarTimeoutObject = null;
- }
- toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
- toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
- }
-
- // Show/hide desktop sharing button
- showDesktopSharingButton();
- },
-
- /**
- * Docks/undocks the toolbar.
- *
- * @param isDock indicates what operation to perform
- */
- dockToolbar (isDock) {
- if (interfaceConfig.filmStripOnly || !Toolbar.isEnabled()) {
- return;
- }
-
- if (isDock) {
- // First make sure the toolbar is shown.
- if (!Toolbar.isVisible()) {
- this.showToolbar();
- }
-
- // Then clear the time out, to dock the toolbar.
- clearTimeout(toolbarTimeoutObject);
- toolbarTimeoutObject = null;
- } else {
- if (Toolbar.isVisible()) {
- toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
- } else {
- this.showToolbar();
- }
- }
- }
- };
-
- module.exports = ToolbarToggler;
|