145 lines
4.0 KiB
JavaScript
145 lines
4.0 KiB
JavaScript
/* 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;
|