jiti-meet/modules/UI/toolbars/ToolbarToggler.js

123 lines
3.3 KiB
JavaScript
Raw Normal View History

2015-12-03 13:11:01 +00:00
/* global APP, config, $, interfaceConfig */
2015-12-10 17:04:39 +00:00
import UIUtil from '../util/UIUtil';
2015-12-30 10:55:51 +00:00
import BottomToolbar from './BottomToolbar';
import Toolbar from './Toolbar';
import FilmStrip from '../videolayout/FilmStrip.js';
2015-12-10 17:04:39 +00:00
let toolbarTimeoutObject;
let toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
2016-06-13 21:11:44 +00:00
/**
* If true the toolbar will be always displayed
*/
let alwaysVisibleToolbar = (config.alwaysVisibleToolbar === true);
2015-01-07 14:54:03 +00:00
2015-01-13 13:11:05 +00:00
function showDesktopSharingButton() {
if (APP.conference.isDesktopSharingEnabled &&
2015-09-14 14:25:43 +00:00
UIUtil.isButtonEnabled('desktop')) {
$('#toolbar_button_desktopsharing').css({display: "inline-block"});
2015-01-13 13:11:05 +00:00
} else {
$('#toolbar_button_desktopsharing').css({display: "none"});
2015-01-13 13:11:05 +00:00
}
}
2015-01-07 14:54:03 +00:00
/**
* Hides the toolbar.
*/
function hideToolbar() {
2016-06-13 21:11:44 +00:00
if (alwaysVisibleToolbar) {
return;
2015-12-10 17:04:39 +00:00
}
2015-01-07 14:54:03 +00:00
clearTimeout(toolbarTimeoutObject);
toolbarTimeoutObject = null;
if (Toolbar.isHovered()) {
2015-12-10 17:04:39 +00:00
toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
} else {
Toolbar.hide();
2015-01-07 14:54:03 +00:00
$('#subject').animate({top: "-=40"}, 300);
if (!FilmStrip.isFilmStripVisible()) {
BottomToolbar.hide(true);
2015-01-07 14:54:03 +00:00
}
}
}
2015-12-10 17:04:39 +00:00
const ToolbarToggler = {
2016-06-13 21:11:44 +00:00
/**
* 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.
*/
2015-12-10 17:04:39 +00:00
showToolbar () {
if (interfaceConfig.filmStripOnly) {
return;
2015-12-10 17:04:39 +00:00
}
var updateTimeout = false;
if (Toolbar.isEnabled() && !Toolbar.isVisible()) {
Toolbar.show();
$('#subject').animate({top: "+=40"}, 300);
updateTimeout = true;
}
if (BottomToolbar.isEnabled() && !BottomToolbar.isVisible()) {
BottomToolbar.show(true);
updateTimeout = true;
}
if (updateTimeout) {
if (toolbarTimeoutObject) {
clearTimeout(toolbarTimeoutObject);
toolbarTimeoutObject = null;
}
toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
}
// Show/hide desktop sharing button
showDesktopSharingButton();
2015-01-07 14:54:03 +00:00
},
/**
* Docks/undocks the toolbar.
*
* @param isDock indicates what operation to perform
*/
2015-12-10 17:04:39 +00:00
dockToolbar (isDock) {
if (interfaceConfig.filmStripOnly || !Toolbar.isEnabled()) {
return;
2015-12-10 17:04:39 +00:00
}
if (isDock) {
// First make sure the toolbar is shown.
if (!Toolbar.isVisible()) {
2015-01-07 14:54:03 +00:00
this.showToolbar();
}
// Then clear the time out, to dock the toolbar.
2015-12-10 17:04:39 +00:00
clearTimeout(toolbarTimeoutObject);
toolbarTimeoutObject = null;
} else {
if (Toolbar.isVisible()) {
toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
2015-12-10 17:04:39 +00:00
} else {
this.showToolbar();
}
}
2015-12-10 17:04:39 +00:00
}
2015-01-07 14:54:03 +00:00
};
2015-12-10 17:04:39 +00:00
module.exports = ToolbarToggler;