2015-07-28 21:52:32 +00:00
|
|
|
/* global require, $ */
|
2015-12-11 14:48:16 +00:00
|
|
|
import Chat from "./chat/Chat";
|
|
|
|
import ContactList from "./contactlist/ContactList";
|
|
|
|
import Settings from "./../../settings/Settings";
|
|
|
|
import SettingsMenu from "./settings/SettingsMenu";
|
|
|
|
import VideoLayout from "../videolayout/VideoLayout";
|
|
|
|
import ToolbarToggler from "../toolbars/ToolbarToggler";
|
|
|
|
import UIUtil from "../util/UIUtil";
|
|
|
|
|
|
|
|
const buttons = {
|
|
|
|
'#chatspace': '#chatBottomButton',
|
|
|
|
'#contactlist': '#contactListButton',
|
|
|
|
'#settingsmenu': '#toolbar_button_settings'
|
|
|
|
};
|
|
|
|
|
|
|
|
var currentlyOpen = null;
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2014-10-31 11:47:12 +00:00
|
|
|
/**
|
2015-12-11 14:48:16 +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
|
2016-03-02 19:21:26 +00:00
|
|
|
* @param onVideoResizeComplete function to be called after the video area
|
|
|
|
* is resized
|
2014-10-31 11:47:12 +00:00
|
|
|
*/
|
2016-03-02 19:21:26 +00:00
|
|
|
function toggle (object, selector, onOpenComplete,
|
|
|
|
onOpen, onClose, onVideoResizeComplete) {
|
|
|
|
let isSideBarVisible = object.isVisible();
|
|
|
|
|
2015-12-11 14:48:16 +00:00
|
|
|
UIUtil.buttonClick(buttons[selector], "active");
|
|
|
|
|
2016-03-02 19:21:26 +00:00
|
|
|
if (isSideBarVisible) {
|
2015-12-11 14:48:16 +00:00
|
|
|
$("#toast-container").animate({
|
|
|
|
right: 5
|
|
|
|
}, {
|
|
|
|
queue: false,
|
|
|
|
duration: 500
|
|
|
|
});
|
|
|
|
$(selector).hide("slide", {
|
|
|
|
direction: "right",
|
|
|
|
queue: false,
|
|
|
|
duration: 500
|
|
|
|
});
|
2016-03-02 19:21:26 +00:00
|
|
|
|
|
|
|
resizeVideoArea(isSideBarVisible, onVideoResizeComplete);
|
|
|
|
|
2015-12-11 14:48:16 +00:00
|
|
|
if(typeof onClose === "function") {
|
|
|
|
onClose();
|
|
|
|
}
|
2014-10-31 11:47:12 +00:00
|
|
|
|
2015-12-11 14:48:16 +00:00
|
|
|
currentlyOpen = null;
|
|
|
|
} else {
|
2016-03-02 19:21:26 +00:00
|
|
|
resizeVideoArea(isSideBarVisible, onVideoResizeComplete);
|
|
|
|
|
2015-12-11 14:48:16 +00:00
|
|
|
// Undock the toolbar when the chat is shown and if we're in a
|
|
|
|
// video mode.
|
2015-12-25 16:55:45 +00:00
|
|
|
if (VideoLayout.isLargeVideoVisible()) {
|
2015-12-11 14:48:16 +00:00
|
|
|
ToolbarToggler.dockToolbar(false);
|
|
|
|
}
|
2014-10-31 11:47:12 +00:00
|
|
|
|
2015-12-11 14:48:16 +00:00
|
|
|
if (currentlyOpen) {
|
|
|
|
var current = $(currentlyOpen);
|
|
|
|
UIUtil.buttonClick(buttons[currentlyOpen], "active");
|
|
|
|
current.css('z-index', 4);
|
|
|
|
setTimeout(function () {
|
|
|
|
current.css('display', 'none');
|
|
|
|
current.css('z-index', 5);
|
|
|
|
}, 500);
|
2014-10-31 11:47:12 +00:00
|
|
|
}
|
2015-12-11 14:48:16 +00:00
|
|
|
|
|
|
|
$("#toast-container").animate({
|
2015-12-25 16:55:45 +00:00
|
|
|
right: (UIUtil.getSidePanelSize()[0] + 5)
|
2015-12-11 14:48:16 +00:00
|
|
|
}, {
|
|
|
|
queue: false,
|
|
|
|
duration: 500
|
|
|
|
});
|
|
|
|
$(selector).show("slide", {
|
|
|
|
direction: "right",
|
|
|
|
queue: false,
|
|
|
|
duration: 500,
|
|
|
|
complete: onOpenComplete
|
|
|
|
});
|
|
|
|
if(typeof onOpen === "function") {
|
|
|
|
onOpen();
|
2014-10-31 11:47:12 +00:00
|
|
|
}
|
2015-12-11 14:48:16 +00:00
|
|
|
|
|
|
|
currentlyOpen = selector;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-02 19:21:26 +00:00
|
|
|
function resizeVideoArea(isSidePanelVisible, completeFunction) {
|
|
|
|
VideoLayout.resizeVideoArea(!isSidePanelVisible,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
completeFunction);
|
|
|
|
}
|
|
|
|
|
2015-12-11 14:48:16 +00:00
|
|
|
/**
|
|
|
|
* Toggler for the chat, contact list, settings menu, etc..
|
|
|
|
*/
|
|
|
|
var PanelToggler = {
|
2014-10-31 11:47:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens / closes the chat area.
|
|
|
|
*/
|
2015-12-11 14:48:16 +00:00
|
|
|
toggleChat () {
|
|
|
|
var chatCompleteFunction = Chat.isVisible()
|
|
|
|
? function () {}
|
|
|
|
: function () {
|
|
|
|
Chat.scrollChatToBottom();
|
|
|
|
$('#chatspace').trigger('shown');
|
|
|
|
};
|
2014-10-31 11:47:12 +00:00
|
|
|
|
2016-02-24 21:05:24 +00:00
|
|
|
toggle(Chat, //Object
|
|
|
|
'#chatspace', // Selector
|
|
|
|
function () { //onOpenComplete
|
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();
|
|
|
|
}
|
|
|
|
},
|
2016-02-24 21:05:24 +00:00
|
|
|
() => this.resizeChat(), //OnOpen
|
2016-03-02 19:21:26 +00:00
|
|
|
null,
|
|
|
|
chatCompleteFunction); //OnClose
|
2015-12-11 14:48:16 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
resizeChat () {
|
2015-12-25 16:55:45 +00:00
|
|
|
let [width, height] = UIUtil.getSidePanelSize();
|
2015-12-11 14:48:16 +00:00
|
|
|
Chat.resizeChat(width, height);
|
|
|
|
},
|
2014-10-31 11:47:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens / closes the contact list area.
|
|
|
|
*/
|
2015-12-11 14:48:16 +00:00
|
|
|
toggleContactList () {
|
|
|
|
var completeFunction = ContactList.isVisible()
|
|
|
|
? function () {}
|
|
|
|
: function () {
|
|
|
|
$('#contactlist').trigger('shown');
|
|
|
|
};
|
2014-10-31 11:47:12 +00:00
|
|
|
|
|
|
|
toggle(ContactList,
|
|
|
|
'#contactlist',
|
|
|
|
null,
|
|
|
|
function() {
|
|
|
|
ContactList.setVisualNotification(false);
|
|
|
|
},
|
2016-03-02 19:21:26 +00:00
|
|
|
null,
|
|
|
|
completeFunction);
|
2015-12-11 14:48:16 +00:00
|
|
|
},
|
2014-10-31 11:47:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens / closes the settings menu
|
|
|
|
*/
|
2015-12-11 14:48:16 +00:00
|
|
|
toggleSettingsMenu () {
|
2014-10-31 11:47:12 +00:00
|
|
|
toggle(SettingsMenu,
|
|
|
|
'#settingsmenu',
|
|
|
|
null,
|
2016-03-02 15:39:39 +00:00
|
|
|
function() {},
|
2014-10-31 11:47:12 +00:00
|
|
|
null);
|
2015-12-11 14:48:16 +00:00
|
|
|
},
|
2014-10-31 11:47:12 +00:00
|
|
|
|
2015-12-11 14:48:16 +00:00
|
|
|
isVisible () {
|
2015-09-11 02:42:15 +00:00
|
|
|
return (Chat.isVisible() ||
|
|
|
|
ContactList.isVisible() ||
|
|
|
|
SettingsMenu.isVisible());
|
2015-12-11 14:48:16 +00:00
|
|
|
}
|
|
|
|
};
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-12-11 14:48:16 +00:00
|
|
|
export default PanelToggler;
|