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

114 lines
3.3 KiB
JavaScript
Raw Normal View History

2015-01-13 13:11:05 +00:00
/* global $, interfaceConfig, Moderator, DesktopStreaming.showDesktopSharingButton */
2015-01-07 14:54:03 +00:00
var toolbarTimeoutObject,
toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
2015-01-13 13:11:05 +00:00
function showDesktopSharingButton() {
if (APP.desktopsharing.isDesktopSharingEnabled()) {
2015-01-13 13:11:05 +00:00
$('#desktopsharing').css({display: "inline"});
} else {
$('#desktopsharing').css({display: "none"});
}
}
2015-01-07 14:54:03 +00:00
/**
* Hides the toolbar.
*/
function hideToolbar() {
var header = $("#header"),
bottomToolbar = $("#bottomToolbar");
var isToolbarHover = false;
header.find('*').each(function () {
var id = $(this).attr('id');
if ($("#" + id + ":hover").length > 0) {
isToolbarHover = true;
}
});
if ($("#bottomToolbar:hover").length > 0) {
isToolbarHover = true;
}
clearTimeout(toolbarTimeoutObject);
toolbarTimeoutObject = null;
if (!isToolbarHover) {
header.hide("slide", { direction: "up", duration: 300});
$('#subject').animate({top: "-=40"}, 300);
if ($("#remoteVideos").hasClass("hidden")) {
bottomToolbar.hide(
"slide", {direction: "right", duration: 300});
}
}
else {
toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
}
}
var ToolbarToggler = {
/**
* Shows the main toolbar.
*/
2015-01-07 14:54:03 +00:00
showToolbar: function () {
var header = $("#header"),
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(
"slide", {direction: "right", duration: 300});
}
if (toolbarTimeoutObject) {
clearTimeout(toolbarTimeoutObject);
toolbarTimeoutObject = null;
}
toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
}
if (APP.xmpp.isModerator())
{
// TODO: Enable settings functionality.
// Need to uncomment the settings button in index.html.
// $('#settingsButton').css({visibility:"visible"});
}
// 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-01-07 14:54:03 +00:00
dockToolbar: function (isDock) {
if (isDock) {
// First make sure the toolbar is shown.
if (!$('#header').is(':visible')) {
2015-01-07 14:54:03 +00:00
this.showToolbar();
}
// Then clear the time out, to dock the toolbar.
if (toolbarTimeoutObject) {
clearTimeout(toolbarTimeoutObject);
toolbarTimeoutObject = null;
}
}
else {
if (!$('#header').is(':visible')) {
2015-01-07 14:54:03 +00:00
this.showToolbar();
}
else {
toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
}
}
2015-01-13 13:11:05 +00:00
},
showDesktopSharingButton: showDesktopSharingButton
2015-01-07 14:54:03 +00:00
};
2015-01-07 14:54:03 +00:00
module.exports = ToolbarToggler;