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