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

150 lines
4.1 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';
import Toolbar from './Toolbar';
2016-09-10 02:26:29 +00:00
import SideContainerToggler from "../side_pannels/SideContainerToggler";
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 = false;
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.
2016-09-10 02:26:29 +00:00
*
* @param force {true} to force the hiding of the toolbar without caring about
* the extended toolbar side panels.
2015-01-07 14:54:03 +00:00
*/
function hideToolbar(force) { // eslint-disable-line no-unused-vars
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 (force !== true &&
(Toolbar.isHovered()
|| APP.UI.isRingOverlayVisible()
|| SideContainerToggler.isVisible())) {
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);
}
}
2015-12-10 17:04:39 +00:00
const ToolbarToggler = {
/**
* Initializes the ToolbarToggler
*/
init() {
alwaysVisibleToolbar = (config.alwaysVisibleToolbar === true);
2016-09-10 02:26:29 +00:00
2016-09-13 22:12:10 +00:00
// disabled
//this._registerWindowClickListeners();
2016-09-10 02:26:29 +00:00
},
/**
* 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();
});
},
2016-09-10 02:26:29 +00:00
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;
},
2016-09-10 02:26:29 +00:00
2016-06-13 21:11:44 +00:00
/**
* Resets the value of alwaysVisibleToolbar variable to the default one.
*/
resetAlwaysVisibleToolbar() {
alwaysVisibleToolbar = (config.alwaysVisibleToolbar === true);
},
2016-09-10 02:26:29 +00:00
/**
* Shows the main toolbar.
* @param timeout (optional) to specify custom timeout value
*/
showToolbar (timeout) {
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 (updateTimeout) {
if (toolbarTimeoutObject) {
clearTimeout(toolbarTimeoutObject);
toolbarTimeoutObject = null;
}
2016-09-30 14:39:12 +00:00
toolbarTimeoutObject
= setTimeout(hideToolbar, timeout || 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;