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

120 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';
2015-12-10 17:04:39 +00:00
let toolbarTimeoutObject;
let toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
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-12-10 17:04:39 +00:00
function isToolbarVisible () {
return $('#header').is(':visible');
}
2015-01-07 14:54:03 +00:00
/**
* Hides the toolbar.
*/
function hideToolbar() {
2015-12-10 17:04:39 +00:00
if (config.alwaysVisibleToolbar) {
return;
2015-12-10 17:04:39 +00:00
}
2015-12-10 17:04:39 +00:00
let header = $("#header");
let bottomToolbar = $("#bottomToolbar");
let isToolbarHover = false;
2015-01-07 14:54:03 +00:00
header.find('*').each(function () {
2015-12-10 17:04:39 +00:00
let id = $(this).attr('id');
if ($(`#${id}:hover`).length > 0) {
2015-01-07 14:54:03 +00:00
isToolbarHover = true;
}
});
if ($("#bottomToolbar:hover").length > 0) {
isToolbarHover = true;
}
clearTimeout(toolbarTimeoutObject);
toolbarTimeoutObject = null;
2015-12-10 17:04:39 +00:00
if (isToolbarHover) {
toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
} else {
2015-01-07 14:54:03 +00:00
header.hide("slide", { direction: "up", duration: 300});
$('#subject').animate({top: "-=40"}, 300);
2015-12-30 10:55:51 +00:00
if (!BottomToolbar.isFilmStripVisible()) {
2015-01-07 14:54:03 +00:00
bottomToolbar.hide(
2015-12-10 17:04:39 +00:00
"slide", {direction: "right", duration: 300}
);
2015-01-07 14:54:03 +00:00
}
}
}
2015-12-10 17:04:39 +00:00
const ToolbarToggler = {
/**
* 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
}
let header = $("#header");
let bottomToolbar = $("#bottomToolbar");
if (!header.is(':visible') || !bottomToolbar.is(":visible")) {
header.show("slide", { direction: "up", duration: 300});
$('#subject').animate({top: "+=40"}, 300);
if (!bottomToolbar.is(":visible")) {
bottomToolbar.show(
2015-12-10 17:04:39 +00:00
"slide", {direction: "right", duration: 300}
);
}
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) {
return;
2015-12-10 17:04:39 +00:00
}
if (isDock) {
// First make sure the toolbar is shown.
2015-12-10 17:04:39 +00:00
if (!isToolbarVisible()) {
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 (isToolbarVisible()) {
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;