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
|
2014-10-31 11:47:12 +00:00
|
|
|
*/
|
2015-12-11 14:48:16 +00:00
|
|
|
function toggle (object, selector, onOpenComplete, onOpen, onClose) {
|
|
|
|
UIUtil.buttonClick(buttons[selector], "active");
|
|
|
|
|
|
|
|
if (object.isVisible()) {
|
|
|
|
$("#toast-container").animate({
|
|
|
|
right: 5
|
|
|
|
}, {
|
|
|
|
queue: false,
|
|
|
|
duration: 500
|
|
|
|
});
|
|
|
|
$(selector).hide("slide", {
|
|
|
|
direction: "right",
|
|
|
|
queue: false,
|
|
|
|
duration: 500
|
|
|
|
});
|
|
|
|
if(typeof onClose === "function") {
|
|
|
|
onClose();
|
|
|
|
}
|
2014-10-31 11:47:12 +00:00
|
|
|
|
2015-12-11 14:48:16 +00:00
|
|
|
currentlyOpen = null;
|
|
|
|
} else {
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
VideoLayout.resizeVideoArea(!Chat.isVisible(),
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
chatCompleteFunction);
|
|
|
|
|
|
|
|
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
|
|
|
|
null); //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');
|
|
|
|
};
|
2016-02-24 21:05:24 +00:00
|
|
|
VideoLayout.resizeVideoArea(
|
|
|
|
!ContactList.isVisible(),
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
completeFunction);
|
2014-10-31 11:47:12 +00:00
|
|
|
|
|
|
|
toggle(ContactList,
|
|
|
|
'#contactlist',
|
|
|
|
null,
|
|
|
|
function() {
|
|
|
|
ContactList.setVisualNotification(false);
|
|
|
|
},
|
|
|
|
null);
|
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 () {
|
2016-02-24 21:05:24 +00:00
|
|
|
VideoLayout.resizeVideoArea(
|
|
|
|
!SettingsMenu.isVisible(), false, true, function (){});
|
2014-10-31 11:47:12 +00:00
|
|
|
toggle(SettingsMenu,
|
|
|
|
'#settingsmenu',
|
|
|
|
null,
|
|
|
|
function() {
|
2016-02-12 12:48:57 +00:00
|
|
|
$('#setDisplayName').val(Settings.getDisplayName());
|
|
|
|
$('#setEmail').val(Settings.getEmail());
|
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;
|