/* global APP, $, config, interfaceConfig */ /* jshint -W101 */ import messageHandler from '../util/MessageHandler'; import UIUtil from '../util/UIUtil'; import AnalyticsAdapter from '../../statistics/AnalyticsAdapter'; import UIEvents from '../../../service/UI/UIEvents'; let roomUrl = null; let emitter = null; /** * Opens the invite link dialog. */ function openLinkDialog () { let inviteAttributes; if (roomUrl === null) { inviteAttributes = 'data-i18n="[value]roomUrlDefaultMsg" value="' + APP.translation.translateString("roomUrlDefaultMsg") + '"'; } else { inviteAttributes = "value=\"" + encodeURI(roomUrl) + "\""; } messageHandler.openTwoButtonDialog( "dialog.shareLink", null, null, ``, false, "dialog.Invite", function (e, v) { if (v && roomUrl) { emitter.emit(UIEvents.USER_INVITED, roomUrl); } }, function (event) { if (roomUrl) { document.getElementById('inviteLinkRef').select(); } else { if (event && event.target) { $(event.target).find('button[value=true]').prop('disabled', true); } } } ); } const buttonHandlers = { "toolbar_button_mute": function () { if (APP.conference.audioMuted) { AnalyticsAdapter.sendEvent('toolbar.audio.unmuted'); emitter.emit(UIEvents.AUDIO_MUTED, false); } else { AnalyticsAdapter.sendEvent('toolbar.audio.muted'); emitter.emit(UIEvents.AUDIO_MUTED, true); } }, "toolbar_button_camera": function () { if (APP.conference.videoMuted) { AnalyticsAdapter.sendEvent('toolbar.video.enabled'); emitter.emit(UIEvents.VIDEO_MUTED, false); } else { AnalyticsAdapter.sendEvent('toolbar.video.disabled'); emitter.emit(UIEvents.VIDEO_MUTED, true); } }, "toolbar_button_security": function () { emitter.emit(UIEvents.ROOM_LOCK_CLICKED); }, "toolbar_button_link": function () { AnalyticsAdapter.sendEvent('toolbar.invite.clicked'); openLinkDialog(); }, "toolbar_button_chat": function () { AnalyticsAdapter.sendEvent('toolbar.chat.toggled'); emitter.emit(UIEvents.TOGGLE_CHAT); }, "toolbar_button_etherpad": function () { AnalyticsAdapter.sendEvent('toolbar.etherpad.clicked'); emitter.emit(UIEvents.ETHERPAD_CLICKED); }, "toolbar_button_sharedvideo": function () { AnalyticsAdapter.sendEvent('toolbar.sharedvideo.clicked'); emitter.emit(UIEvents.SHARED_VIDEO_CLICKED); }, "toolbar_button_desktopsharing": function () { if (APP.conference.isSharingScreen) { AnalyticsAdapter.sendEvent('toolbar.screen.disabled'); } else { AnalyticsAdapter.sendEvent('toolbar.screen.enabled'); } emitter.emit(UIEvents.TOGGLE_SCREENSHARING); }, "toolbar_button_fullScreen": function() { AnalyticsAdapter.sendEvent('toolbar.fullscreen.enabled'); UIUtil.buttonClick("#toolbar_button_fullScreen", "icon-full-screen icon-exit-full-screen"); emitter.emit(UIEvents.FULLSCREEN_TOGGLE); }, "toolbar_button_sip": function () { AnalyticsAdapter.sendEvent('toolbar.sip.clicked'); showSipNumberInput(); }, "toolbar_button_dialpad": function () { AnalyticsAdapter.sendEvent('toolbar.sip.dialpad.clicked'); dialpadButtonClicked(); }, "toolbar_button_settings": function () { AnalyticsAdapter.sendEvent('toolbar.settings.toggled'); emitter.emit(UIEvents.TOGGLE_SETTINGS); }, "toolbar_button_hangup": function () { AnalyticsAdapter.sendEvent('toolbar.hangup'); emitter.emit(UIEvents.HANGUP); }, "toolbar_button_login": function () { AnalyticsAdapter.sendEvent('toolbar.authenticate.login.clicked'); emitter.emit(UIEvents.AUTH_CLICKED); }, "toolbar_button_logout": function () { AnalyticsAdapter.sendEvent('toolbar.authenticate.logout.clicked'); // Ask for confirmation messageHandler.openTwoButtonDialog( "dialog.logoutTitle", null, "dialog.logoutQuestion", null, false, "dialog.Yes", function (evt, yes) { if (yes) { emitter.emit(UIEvents.LOGOUT); } } ); } }; const defaultToolbarButtons = { 'microphone': '#toolbar_button_mute', 'camera': '#toolbar_button_camera', 'desktop': '#toolbar_button_desktopsharing', 'security': '#toolbar_button_security', 'invite': '#toolbar_button_link', 'chat': '#toolbar_button_chat', 'etherpad': '#toolbar_button_etherpad', 'fullscreen': '#toolbar_button_fullScreen', 'settings': '#toolbar_button_settings', 'hangup': '#toolbar_button_hangup' }; function dialpadButtonClicked() { //TODO show the dialpad box } function showSipNumberInput () { let defaultNumber = config.defaultSipNumber ? config.defaultSipNumber : ''; let sipMsg = APP.translation.generateTranslationHTML("dialog.sipMsg"); messageHandler.openTwoButtonDialog( null, null, null, `