2015-12-03 13:11:01 +00:00
|
|
|
/* global APP, config, $, interfaceConfig */
|
2014-09-04 13:18:28 +00:00
|
|
|
|
2015-12-10 17:04:39 +00:00
|
|
|
import UIUtil from '../util/UIUtil';
|
2016-04-07 17:08:00 +00:00
|
|
|
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
|
|
|
|
*/
|
2016-06-14 16:34:56 +00:00
|
|
|
let alwaysVisibleToolbar = false;
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-01-13 13:11:05 +00:00
|
|
|
function showDesktopSharingButton() {
|
2016-02-04 15:25:11 +00:00
|
|
|
if (APP.conference.isDesktopSharingEnabled &&
|
2015-09-14 14:25:43 +00:00
|
|
|
UIUtil.isButtonEnabled('desktop')) {
|
2015-08-12 18:06:55 +00:00
|
|
|
$('#toolbar_button_desktopsharing').css({display: "inline-block"});
|
2015-01-13 13:11:05 +00:00
|
|
|
} else {
|
2015-08-05 21:56:08 +00:00
|
|
|
$('#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
|
|
|
*/
|
2016-10-03 16:12:04 +00:00
|
|
|
function hideToolbar(force) { // eslint-disable-line no-unused-vars
|
2016-06-13 21:11:44 +00:00
|
|
|
if (alwaysVisibleToolbar) {
|
2015-05-20 12:10:09 +00:00
|
|
|
return;
|
2015-12-10 17:04:39 +00:00
|
|
|
}
|
2015-05-20 12:10:09 +00:00
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
clearTimeout(toolbarTimeoutObject);
|
|
|
|
toolbarTimeoutObject = null;
|
|
|
|
|
2016-10-21 14:20:17 +00:00
|
|
|
if (force !== true &&
|
2016-10-13 15:34:32 +00:00
|
|
|
(Toolbar.isHovered()
|
2016-10-21 15:27:10 +00:00
|
|
|
|| APP.UI.isRingOverlayVisible()
|
2016-10-13 15:34:32 +00:00
|
|
|
|| SideContainerToggler.isVisible())) {
|
2015-12-10 17:04:39 +00:00
|
|
|
toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
|
2016-09-14 16:51:47 +00:00
|
|
|
} else {
|
2016-04-07 17:08:00 +00:00
|
|
|
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 = {
|
2016-06-14 16:34:56 +00:00
|
|
|
/**
|
|
|
|
* 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-06-14 16:34:56 +00:00
|
|
|
},
|
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
|
|
|
|
2014-09-04 13:18:28 +00:00
|
|
|
/**
|
|
|
|
* Shows the main toolbar.
|
2016-09-09 19:37:04 +00:00
|
|
|
* @param timeout (optional) to specify custom timeout value
|
2014-09-04 13:18:28 +00:00
|
|
|
*/
|
2016-09-09 19:37:04 +00:00
|
|
|
showToolbar (timeout) {
|
2016-04-07 17:08:00 +00:00
|
|
|
if (interfaceConfig.filmStripOnly) {
|
2015-08-06 23:34:40 +00:00
|
|
|
return;
|
2015-12-10 17:04:39 +00:00
|
|
|
}
|
2016-04-07 17:08:00 +00:00
|
|
|
|
|
|
|
var updateTimeout = false;
|
|
|
|
if (Toolbar.isEnabled() && !Toolbar.isVisible()) {
|
|
|
|
Toolbar.show();
|
2014-09-04 13:18:28 +00:00
|
|
|
$('#subject').animate({top: "+=40"}, 300);
|
2016-04-07 17:08:00 +00:00
|
|
|
updateTimeout = true;
|
|
|
|
}
|
2014-09-04 13:18:28 +00:00
|
|
|
|
2016-04-07 17:08:00 +00:00
|
|
|
if (updateTimeout) {
|
2014-09-18 12:39:40 +00:00
|
|
|
if (toolbarTimeoutObject) {
|
|
|
|
clearTimeout(toolbarTimeoutObject);
|
|
|
|
toolbarTimeoutObject = null;
|
2014-09-04 13:18:28 +00:00
|
|
|
}
|
2016-09-30 14:39:12 +00:00
|
|
|
toolbarTimeoutObject
|
|
|
|
= setTimeout(hideToolbar, timeout || toolbarTimeout);
|
2014-09-18 12:39:40 +00:00
|
|
|
toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
|
2014-09-04 13:18:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Show/hide desktop sharing button
|
|
|
|
showDesktopSharingButton();
|
2015-01-07 14:54:03 +00:00
|
|
|
},
|
2014-09-04 13:18:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Docks/undocks the toolbar.
|
|
|
|
*
|
|
|
|
* @param isDock indicates what operation to perform
|
|
|
|
*/
|
2015-12-10 17:04:39 +00:00
|
|
|
dockToolbar (isDock) {
|
2016-04-07 17:08:00 +00:00
|
|
|
if (interfaceConfig.filmStripOnly || !Toolbar.isEnabled()) {
|
2015-08-06 23:34:40 +00:00
|
|
|
return;
|
2015-12-10 17:04:39 +00:00
|
|
|
}
|
2015-08-06 23:34:40 +00:00
|
|
|
|
2014-09-04 13:18:28 +00:00
|
|
|
if (isDock) {
|
|
|
|
// First make sure the toolbar is shown.
|
2016-04-07 17:08:00 +00:00
|
|
|
if (!Toolbar.isVisible()) {
|
2015-01-07 14:54:03 +00:00
|
|
|
this.showToolbar();
|
2014-09-04 13:18:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Then clear the time out, to dock the toolbar.
|
2015-12-10 17:04:39 +00:00
|
|
|
clearTimeout(toolbarTimeoutObject);
|
|
|
|
toolbarTimeoutObject = null;
|
|
|
|
} else {
|
2016-04-07 17:08:00 +00:00
|
|
|
if (Toolbar.isVisible()) {
|
2014-09-18 12:39:40 +00:00
|
|
|
toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
|
2015-12-10 17:04:39 +00:00
|
|
|
} else {
|
|
|
|
this.showToolbar();
|
2014-09-04 13:18:28 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-10 17:04:39 +00:00
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
};
|
2014-09-04 13:18:28 +00:00
|
|
|
|
2015-12-10 17:04:39 +00:00
|
|
|
module.exports = ToolbarToggler;
|