/* global $, APP, JitsiMeetJS */ import UIUtil from "../../util/UIUtil"; import UIEvents from "../../../../service/UI/UIEvents"; import Settings from '../../../settings/Settings'; const sidePanelsContainerId = 'sideToolbarContainer'; const htmlStr = `
`; function initHTML() { $(`#${sidePanelsContainerId}`) .append(htmlStr); } export default { init (emitter) { initHTML(); // DISPLAY NAME function updateDisplayName () { emitter.emit(UIEvents.NICKNAME_CHANGED, $('#setDisplayName').val()); } $('#setDisplayName') .val(Settings.getDisplayName()) .keyup(function (event) { if (event.keyCode === 13) { // enter updateDisplayName(); } }) .focusout(updateDisplayName); // EMAIL function updateEmail () { emitter.emit(UIEvents.EMAIL_CHANGED, $('#setEmail').val()); } $('#setEmail') .val(Settings.getEmail()) .keyup(function (event) { if (event.keyCode === 13) { // enter updateEmail(); } }).focusout(updateEmail); // LOGIN function loginClicked () { JitsiMeetJS.analytics.sendEvent('authenticate.login.clicked'); emitter.emit(UIEvents.AUTH_CLICKED); } $('#profile_button_login').click(loginClicked); // LOGOUT function logoutClicked () { let titleKey = "dialog.logoutTitle"; let msgKey = "dialog.logoutQuestion"; JitsiMeetJS.analytics.sendEvent('authenticate.logout.clicked'); // Ask for confirmation APP.UI.messageHandler.openTwoButtonDialog({ titleKey: titleKey, msgKey: msgKey, leftButtonKey: "dialog.Yes", submitFunction: function (evt, yes) { if (yes) { emitter.emit(UIEvents.LOGOUT); } } }); } $('#profile_button_logout').click(logoutClicked); }, /** * Check if settings menu is visible or not. * @returns {boolean} */ isVisible () { return UIUtil.isVisible(document.getElementById("profile_container")); }, /** * Change user display name in the settings menu. * @param {string} newDisplayName */ changeDisplayName (newDisplayName) { $('#setDisplayName').val(newDisplayName); }, /** * Change user avatar in the settings menu. * @param {string} avatarUrl url of the new avatar */ changeAvatar (avatarUrl) { $('#avatar').attr('src', avatarUrl); }, /** * Shows or hides authentication related buttons * @param {boolean} show true to show or false to hide */ showAuthenticationButtons (show) { let id = 'profile_auth_container'; UIUtil.setVisible(id, show); }, /** * Shows/hides login button. * @param {boolean} show true to show or false to hide */ showLoginButton (show) { let id = 'profile_button_login'; UIUtil.setVisible(id, show); }, /** * Shows/hides logout button. * @param {boolean} show true to show or false to hide */ showLogoutButton (show) { let id = 'profile_button_logout'; UIUtil.setVisible(id, show); }, /** * Displays user's authenticated identity name (login). * @param {string} authIdentity identity name to be displayed. */ setAuthenticatedIdentity (authIdentity) { let id = 'profile_auth_identity'; UIUtil.setVisible(id, !!authIdentity); $(`#${id}`).text(authIdentity ? authIdentity : ''); } };