2015-07-28 21:52:32 +00:00
|
|
|
/* global require, $ */
|
2015-01-07 14:54:03 +00:00
|
|
|
var Chat = require("./chat/Chat");
|
|
|
|
var ContactList = require("./contactlist/ContactList");
|
2015-02-13 09:38:37 +00:00
|
|
|
var Settings = require("./../../settings/Settings");
|
2015-01-07 14:54:03 +00:00
|
|
|
var SettingsMenu = require("./settings/SettingsMenu");
|
|
|
|
var VideoLayout = require("../videolayout/VideoLayout");
|
|
|
|
var ToolbarToggler = require("../toolbars/ToolbarToggler");
|
2015-01-19 09:20:00 +00:00
|
|
|
var UIUtil = require("../util/UIUtil");
|
2015-06-23 08:00:46 +00:00
|
|
|
var LargeVideo = require("../videolayout/LargeVideo");
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2014-10-31 11:47:12 +00:00
|
|
|
/**
|
|
|
|
* Toggler for the chat, contact list, settings menu, etc..
|
|
|
|
*/
|
|
|
|
var PanelToggler = (function(my) {
|
|
|
|
|
|
|
|
var currentlyOpen = null;
|
|
|
|
var buttons = {
|
|
|
|
'#chatspace': '#chatBottomButton',
|
|
|
|
'#contactlist': '#contactListButton',
|
2015-08-05 21:56:08 +00:00
|
|
|
'#settingsmenu': '#toolbar_button_settings'
|
2014-10-31 11:47:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggles the windows in the side panel
|
|
|
|
* @param object the window that should be shown
|
|
|
|
* @param selector the selector for the element containing the panel
|
|
|
|
* @param onOpenComplete function to be called when the panel is opened
|
|
|
|
* @param onOpen function to be called if the window is going to be opened
|
|
|
|
* @param onClose function to be called if the window is going to be closed
|
|
|
|
*/
|
|
|
|
var toggle = function(object, selector, onOpenComplete, onOpen, onClose) {
|
2015-01-19 09:20:00 +00:00
|
|
|
UIUtil.buttonClick(buttons[selector], "active");
|
2014-10-31 11:47:12 +00:00
|
|
|
|
|
|
|
if (object.isVisible()) {
|
|
|
|
$("#toast-container").animate({
|
|
|
|
right: '5px'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
queue: false,
|
|
|
|
duration: 500
|
|
|
|
});
|
|
|
|
$(selector).hide("slide", {
|
|
|
|
direction: "right",
|
|
|
|
queue: false,
|
|
|
|
duration: 500
|
|
|
|
});
|
|
|
|
if(typeof onClose === "function") {
|
|
|
|
onClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
currentlyOpen = null;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Undock the toolbar when the chat is shown and if we're in a
|
|
|
|
// video mode.
|
2015-06-23 08:00:46 +00:00
|
|
|
if (LargeVideo.isLargeVideoVisible()) {
|
2014-10-31 11:47:12 +00:00
|
|
|
ToolbarToggler.dockToolbar(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(currentlyOpen) {
|
|
|
|
var current = $(currentlyOpen);
|
2015-01-19 09:20:00 +00:00
|
|
|
UIUtil.buttonClick(buttons[currentlyOpen], "active");
|
2014-10-31 11:47:12 +00:00
|
|
|
current.css('z-index', 4);
|
|
|
|
setTimeout(function () {
|
|
|
|
current.css('display', 'none');
|
|
|
|
current.css('z-index', 5);
|
|
|
|
}, 500);
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#toast-container").animate({
|
|
|
|
right: (PanelToggler.getPanelSize()[0] + 5) + 'px'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
queue: false,
|
|
|
|
duration: 500
|
|
|
|
});
|
|
|
|
$(selector).show("slide", {
|
|
|
|
direction: "right",
|
|
|
|
queue: false,
|
|
|
|
duration: 500,
|
|
|
|
complete: onOpenComplete
|
|
|
|
});
|
|
|
|
if(typeof onOpen === "function") {
|
|
|
|
onOpen();
|
|
|
|
}
|
|
|
|
|
|
|
|
currentlyOpen = selector;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens / closes the chat area.
|
|
|
|
*/
|
|
|
|
my.toggleChat = function() {
|
|
|
|
var chatCompleteFunction = Chat.isVisible() ?
|
|
|
|
function() {} : function () {
|
|
|
|
Chat.scrollChatToBottom();
|
|
|
|
$('#chatspace').trigger('shown');
|
|
|
|
};
|
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
VideoLayout.resizeVideoArea(!Chat.isVisible(), chatCompleteFunction);
|
2014-10-31 11:47:12 +00:00
|
|
|
|
|
|
|
toggle(Chat,
|
|
|
|
'#chatspace',
|
|
|
|
function () {
|
2015-09-11 02:42:15 +00:00
|
|
|
// Request the focus in the nickname field or the chat input
|
|
|
|
// field.
|
2014-10-31 11:47:12 +00:00
|
|
|
if ($('#nickname').css('visibility') === 'visible') {
|
|
|
|
$('#nickinput').focus();
|
|
|
|
} else {
|
|
|
|
$('#usermsg').focus();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
null,
|
|
|
|
Chat.resizeChat,
|
|
|
|
null);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens / closes the contact list area.
|
|
|
|
*/
|
|
|
|
my.toggleContactList = function () {
|
|
|
|
var completeFunction = ContactList.isVisible() ?
|
|
|
|
function() {} : function () { $('#contactlist').trigger('shown');};
|
2015-06-23 08:00:46 +00:00
|
|
|
VideoLayout.resizeVideoArea(!ContactList.isVisible(), completeFunction);
|
2014-10-31 11:47:12 +00:00
|
|
|
|
|
|
|
toggle(ContactList,
|
|
|
|
'#contactlist',
|
|
|
|
null,
|
|
|
|
function() {
|
|
|
|
ContactList.setVisualNotification(false);
|
|
|
|
},
|
|
|
|
null);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens / closes the settings menu
|
|
|
|
*/
|
|
|
|
my.toggleSettingsMenu = function() {
|
2015-06-23 08:00:46 +00:00
|
|
|
VideoLayout.resizeVideoArea(!SettingsMenu.isVisible(), function (){});
|
2014-10-31 11:47:12 +00:00
|
|
|
toggle(SettingsMenu,
|
|
|
|
'#settingsmenu',
|
|
|
|
null,
|
|
|
|
function() {
|
2015-01-07 14:54:03 +00:00
|
|
|
var settings = Settings.getSettings();
|
|
|
|
$('#setDisplayName').get(0).value = settings.displayName;
|
|
|
|
$('#setEmail').get(0).value = settings.email;
|
2014-10-31 11:47:12 +00:00
|
|
|
},
|
|
|
|
null);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the size of the side panel.
|
|
|
|
*/
|
|
|
|
my.getPanelSize = function () {
|
|
|
|
var availableHeight = window.innerHeight;
|
|
|
|
var availableWidth = window.innerWidth;
|
|
|
|
|
|
|
|
var panelWidth = 200;
|
|
|
|
if (availableWidth * 0.2 < 200) {
|
|
|
|
panelWidth = availableWidth * 0.2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [panelWidth, availableHeight];
|
|
|
|
};
|
|
|
|
|
|
|
|
my.isVisible = function() {
|
2015-09-11 02:42:15 +00:00
|
|
|
return (Chat.isVisible() ||
|
|
|
|
ContactList.isVisible() ||
|
|
|
|
SettingsMenu.isVisible());
|
2014-10-31 11:47:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return my;
|
|
|
|
|
|
|
|
}(PanelToggler || {}));
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
module.exports = PanelToggler;
|