You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393
  1. /* global APP, JitsiMeetJS, $, config, interfaceConfig, toastr */
  2. const logger = require("jitsi-meet-logger").getLogger(__filename);
  3. var UI = {};
  4. import Chat from "./side_pannels/chat/Chat";
  5. import SidePanels from "./side_pannels/SidePanels";
  6. import Toolbar from "./toolbars/Toolbar";
  7. import ToolbarToggler from "./toolbars/ToolbarToggler";
  8. import Avatar from "./avatar/Avatar";
  9. import SideContainerToggler from "./side_pannels/SideContainerToggler";
  10. import UIUtil from "./util/UIUtil";
  11. import UIEvents from "../../service/UI/UIEvents";
  12. import EtherpadManager from './etherpad/Etherpad';
  13. import SharedVideoManager from './shared_video/SharedVideo';
  14. import Recording from "./recording/Recording";
  15. import VideoLayout from "./videolayout/VideoLayout";
  16. import FilmStrip from "./videolayout/FilmStrip";
  17. import SettingsMenu from "./side_pannels/settings/SettingsMenu";
  18. import Profile from "./side_pannels/profile/Profile";
  19. import Settings from "./../settings/Settings";
  20. import RingOverlay from "./ring_overlay/RingOverlay";
  21. import UIErrors from './UIErrors';
  22. import { debounce } from "../util/helpers";
  23. var EventEmitter = require("events");
  24. UI.messageHandler = require("./util/MessageHandler");
  25. var messageHandler = UI.messageHandler;
  26. var JitsiPopover = require("./util/JitsiPopover");
  27. import Feedback from "./feedback/Feedback";
  28. import FollowMe from "../FollowMe";
  29. var eventEmitter = new EventEmitter();
  30. UI.eventEmitter = eventEmitter;
  31. /**
  32. * Whether an overlay is visible or not.
  33. *
  34. * FIXME: This is temporary solution. Don't use this variable!
  35. * Should be removed when all the code is move to react.
  36. *
  37. * @type {boolean}
  38. * @public
  39. */
  40. UI.overlayVisible = false;
  41. let etherpadManager;
  42. let sharedVideoManager;
  43. let followMeHandler;
  44. let deviceErrorDialog;
  45. const TrackErrors = JitsiMeetJS.errors.track;
  46. const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
  47. microphone: {},
  48. camera: {}
  49. };
  50. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.UNSUPPORTED_RESOLUTION]
  51. = "dialog.cameraUnsupportedResolutionError";
  52. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  53. = "dialog.cameraUnknownError";
  54. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.PERMISSION_DENIED]
  55. = "dialog.cameraPermissionDeniedError";
  56. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NOT_FOUND]
  57. = "dialog.cameraNotFoundError";
  58. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.CONSTRAINT_FAILED]
  59. = "dialog.cameraConstraintFailedError";
  60. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NO_DATA_FROM_SOURCE]
  61. = "dialog.cameraNotSendingData";
  62. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  63. = "dialog.micUnknownError";
  64. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.PERMISSION_DENIED]
  65. = "dialog.micPermissionDeniedError";
  66. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NOT_FOUND]
  67. = "dialog.micNotFoundError";
  68. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.CONSTRAINT_FAILED]
  69. = "dialog.micConstraintFailedError";
  70. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NO_DATA_FROM_SOURCE]
  71. = "dialog.micNotSendingData";
  72. /**
  73. * Initialize toolbars with side panels.
  74. */
  75. function setupToolbars() {
  76. // Initialize toolbar buttons
  77. Toolbar.init(eventEmitter);
  78. // Initialize side panels
  79. SidePanels.init(eventEmitter);
  80. }
  81. /**
  82. * Toggles the application in and out of full screen mode
  83. * (a.k.a. presentation mode in Chrome).
  84. */
  85. UI.toggleFullScreen = function() {
  86. (UIUtil.isFullScreen())
  87. ? UIUtil.exitFullScreen()
  88. : UIUtil.enterFullScreen();
  89. };
  90. /**
  91. * Notify user that server has shut down.
  92. */
  93. UI.notifyGracefulShutdown = function () {
  94. messageHandler.openMessageDialog(
  95. 'dialog.serviceUnavailable',
  96. 'dialog.gracefulShutdown'
  97. );
  98. };
  99. /**
  100. * Notify user that reservation error happened.
  101. */
  102. UI.notifyReservationError = function (code, msg) {
  103. var message = APP.translation.generateTranslationHTML(
  104. "dialog.reservationErrorMsg", {code: code, msg: msg});
  105. messageHandler.openDialog(
  106. "dialog.reservationError", message, true, {}, () => false);
  107. };
  108. /**
  109. * Notify user that he has been kicked from the server.
  110. */
  111. UI.notifyKicked = function () {
  112. messageHandler.openMessageDialog(
  113. "dialog.sessTerminated",
  114. "dialog.kickMessage");
  115. };
  116. /**
  117. * Notify user that conference was destroyed.
  118. * @param reason {string} the reason text
  119. */
  120. UI.notifyConferenceDestroyed = function (reason) {
  121. //FIXME: use Session Terminated from translation, but
  122. // 'reason' text comes from XMPP packet and is not translated
  123. messageHandler.openDialog(
  124. "dialog.sessTerminated", reason, true, {}, () => false);
  125. };
  126. /**
  127. * Show chat error.
  128. * @param err the Error
  129. * @param msg
  130. */
  131. UI.showChatError = function (err, msg) {
  132. if (interfaceConfig.filmStripOnly) {
  133. return;
  134. }
  135. Chat.chatAddError(err, msg);
  136. };
  137. /**
  138. * Change nickname for the user.
  139. * @param {string} id user id
  140. * @param {string} displayName new nickname
  141. */
  142. UI.changeDisplayName = function (id, displayName) {
  143. if (UI.ContactList)
  144. UI.ContactList.onDisplayNameChange(id, displayName);
  145. VideoLayout.onDisplayNameChanged(id, displayName);
  146. if (APP.conference.isLocalId(id) || id === 'localVideoContainer') {
  147. Profile.changeDisplayName(displayName);
  148. Chat.setChatConversationMode(!!displayName);
  149. }
  150. };
  151. /**
  152. * Shows/hides the indication about local connection being interrupted.
  153. *
  154. * @param {boolean} isInterrupted <tt>true</tt> if local connection is
  155. * currently in the interrupted state or <tt>false</tt> if the connection
  156. * is fine.
  157. */
  158. UI.showLocalConnectionInterrupted = function (isInterrupted) {
  159. VideoLayout.showLocalConnectionInterrupted(isInterrupted);
  160. };
  161. /**
  162. * Sets the "raised hand" status for a participant.
  163. */
  164. UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
  165. VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
  166. if (raisedHandStatus) {
  167. messageHandler.notify(participant.getDisplayName(), 'notify.somebody',
  168. 'connected', 'notify.raisedHand');
  169. }
  170. };
  171. /**
  172. * Sets the local "raised hand" status.
  173. */
  174. UI.setLocalRaisedHandStatus = (raisedHandStatus) => {
  175. VideoLayout.setRaisedHandStatus(
  176. APP.conference.getMyUserId(),
  177. raisedHandStatus);
  178. };
  179. /**
  180. * Initialize conference UI.
  181. */
  182. UI.initConference = function () {
  183. let id = APP.conference.getMyUserId();
  184. // Add myself to the contact list.
  185. if (UI.ContactList)
  186. UI.ContactList.addContact(id, true);
  187. // Update default button states before showing the toolbar
  188. // if local role changes buttons state will be again updated.
  189. UI.updateLocalRole(APP.conference.isModerator);
  190. UI.showToolbar();
  191. let displayName = config.displayJids ? id : Settings.getDisplayName();
  192. if (displayName) {
  193. UI.changeDisplayName('localVideoContainer', displayName);
  194. }
  195. // Make sure we configure our avatar id, before creating avatar for us
  196. let email = Settings.getEmail();
  197. if (email) {
  198. UI.setUserEmail(id, email);
  199. } else {
  200. UI.setUserAvatarID(id, Settings.getAvatarId());
  201. }
  202. Toolbar.checkAutoEnableDesktopSharing();
  203. if(!interfaceConfig.filmStripOnly) {
  204. Feedback.init(eventEmitter);
  205. }
  206. // FollowMe attempts to copy certain aspects of the moderator's UI into the
  207. // other participants' UI. Consequently, it needs (1) read and write access
  208. // to the UI (depending on the moderator role of the local participant) and
  209. // (2) APP.conference as means of communication between the participants.
  210. followMeHandler = new FollowMe(APP.conference, UI);
  211. UIUtil.activateTooltips();
  212. };
  213. UI.mucJoined = function () {
  214. VideoLayout.mucJoined();
  215. };
  216. /***
  217. * Handler for toggling filmstrip
  218. */
  219. UI.handleToggleFilmStrip = () => UI.toggleFilmStrip();
  220. /**
  221. * Sets tooltip defaults.
  222. *
  223. * @private
  224. */
  225. function _setTooltipDefaults() {
  226. $.fn.tooltip.defaults = {
  227. opacity: 1, //defaults to 1
  228. offset: 1,
  229. delayIn: 0, //defaults to 500
  230. hoverable: true,
  231. hideOnClick: true,
  232. aria: true
  233. };
  234. }
  235. /**
  236. * Returns the shared document manager object.
  237. * @return {EtherpadManager} the shared document manager object
  238. */
  239. UI.getSharedVideoManager = function () {
  240. return sharedVideoManager;
  241. };
  242. /**
  243. * Starts the UI module and initializes all related components.
  244. *
  245. * @returns {boolean} true if the UI is ready and the conference should be
  246. * esablished, false - otherwise (for example in the case of welcome page)
  247. */
  248. UI.start = function () {
  249. document.title = interfaceConfig.APP_NAME;
  250. // Set the defaults for prompt dialogs.
  251. $.prompt.setDefaults({persistent: false});
  252. // Set the defaults for tooltips.
  253. _setTooltipDefaults();
  254. ToolbarToggler.init();
  255. SideContainerToggler.init(eventEmitter);
  256. FilmStrip.init(eventEmitter);
  257. VideoLayout.init(eventEmitter);
  258. if (!interfaceConfig.filmStripOnly) {
  259. VideoLayout.initLargeVideo();
  260. }
  261. VideoLayout.resizeVideoArea(true, true);
  262. sharedVideoManager = new SharedVideoManager(eventEmitter);
  263. if (!interfaceConfig.filmStripOnly) {
  264. let debouncedShowToolbar = debounce(() => {
  265. UI.showToolbar();
  266. }, 100, { leading: true, trailing: false });
  267. $("#videoconference_page").mousemove(debouncedShowToolbar);
  268. setupToolbars();
  269. // Initialise the recording module.
  270. if (config.enableRecording)
  271. Recording.init(eventEmitter, config.recordingType);
  272. } else {
  273. $("body").addClass("filmstrip-only");
  274. UIUtil.setVisible('mainToolbarContainer', false);
  275. FilmStrip.setupFilmStripOnly();
  276. messageHandler.enableNotifications(false);
  277. JitsiPopover.enabled = false;
  278. }
  279. document.title = interfaceConfig.APP_NAME;
  280. if (!interfaceConfig.filmStripOnly) {
  281. toastr.options = {
  282. "closeButton": true,
  283. "debug": false,
  284. "positionClass": "notification-bottom-right",
  285. "onclick": null,
  286. "showDuration": "300",
  287. "hideDuration": "1000",
  288. "timeOut": "2000",
  289. "extendedTimeOut": "1000",
  290. "showEasing": "swing",
  291. "hideEasing": "linear",
  292. "showMethod": "fadeIn",
  293. "hideMethod": "fadeOut",
  294. "newestOnTop": false,
  295. // this is the default toastr close button html, just adds tabIndex
  296. "closeHtml": '<button type="button" tabIndex="-1">&times;</button>'
  297. };
  298. }
  299. if(APP.tokenData.callee) {
  300. UI.showRingOverlay();
  301. }
  302. };
  303. /**
  304. * Setup some UI event listeners.
  305. */
  306. UI.registerListeners
  307. = () => UIListeners.forEach((value, key) => UI.addListener(key, value));
  308. /**
  309. * Unregister some UI event listeners.
  310. */
  311. UI.unregisterListeners
  312. = () => UIListeners.forEach((value, key) => UI.removeListener(key, value));
  313. /**
  314. * Setup some DOM event listeners.
  315. */
  316. UI.bindEvents = () => {
  317. function onResize() {
  318. SideContainerToggler.resize();
  319. VideoLayout.resizeVideoArea();
  320. }
  321. // Resize and reposition videos in full screen mode.
  322. $(document).on(
  323. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  324. () => {
  325. eventEmitter.emit(
  326. UIEvents.FULLSCREEN_TOGGLED,
  327. UIUtil.isFullScreen());
  328. onResize();
  329. });
  330. $(window).resize(onResize);
  331. };
  332. /**
  333. * Unbind some DOM event listeners.
  334. */
  335. UI.unbindEvents = () => {
  336. $(document).off(
  337. 'webkitfullscreenchange mozfullscreenchange fullscreenchange');
  338. $(window).off('resize');
  339. };
  340. /**
  341. * Show local stream on UI.
  342. * @param {JitsiTrack} track stream to show
  343. */
  344. UI.addLocalStream = track => {
  345. switch (track.getType()) {
  346. case 'audio':
  347. VideoLayout.changeLocalAudio(track);
  348. break;
  349. case 'video':
  350. VideoLayout.changeLocalVideo(track);
  351. break;
  352. default:
  353. logger.error("Unknown stream type: " + track.getType());
  354. break;
  355. }
  356. };
  357. /**
  358. * Show remote stream on UI.
  359. * @param {JitsiTrack} track stream to show
  360. */
  361. UI.addRemoteStream = track => VideoLayout.onRemoteStreamAdded(track);
  362. /**
  363. * Removed remote stream from UI.
  364. * @param {JitsiTrack} track stream to remove
  365. */
  366. UI.removeRemoteStream = track => VideoLayout.onRemoteStreamRemoved(track);
  367. /**
  368. * Update chat subject.
  369. * @param {string} subject new chat subject
  370. */
  371. UI.setSubject = subject => Chat.setSubject(subject);
  372. /**
  373. * Setup and show Etherpad.
  374. * @param {string} name etherpad id
  375. */
  376. UI.initEtherpad = name => {
  377. if (etherpadManager || !config.etherpad_base || !name) {
  378. return;
  379. }
  380. logger.log('Etherpad is enabled');
  381. etherpadManager
  382. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  383. Toolbar.showEtherpadButton();
  384. };
  385. /**
  386. * Returns the shared document manager object.
  387. * @return {EtherpadManager} the shared document manager object
  388. */
  389. UI.getSharedDocumentManager = () => etherpadManager;
  390. /**
  391. * Show user on UI.
  392. * @param {JitsiParticipant} user
  393. */
  394. UI.addUser = function (user) {
  395. var id = user.getId();
  396. var displayName = user.getDisplayName();
  397. UI.hideRingOverLay();
  398. if (UI.ContactList)
  399. UI.ContactList.addContact(id);
  400. messageHandler.notify(
  401. displayName,'notify.somebody', 'connected', 'notify.connected'
  402. );
  403. if (!config.startAudioMuted ||
  404. config.startAudioMuted > APP.conference.membersCount)
  405. UIUtil.playSoundNotification('userJoined');
  406. // Add Peer's container
  407. VideoLayout.addParticipantContainer(user);
  408. // Configure avatar
  409. UI.setUserEmail(id);
  410. // set initial display name
  411. if(displayName)
  412. UI.changeDisplayName(id, displayName);
  413. };
  414. /**
  415. * Remove user from UI.
  416. * @param {string} id user id
  417. * @param {string} displayName user nickname
  418. */
  419. UI.removeUser = function (id, displayName) {
  420. if (UI.ContactList)
  421. UI.ContactList.removeContact(id);
  422. messageHandler.notify(
  423. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  424. );
  425. if (!config.startAudioMuted
  426. || config.startAudioMuted > APP.conference.membersCount) {
  427. UIUtil.playSoundNotification('userLeft');
  428. }
  429. VideoLayout.removeParticipantContainer(id);
  430. };
  431. /**
  432. * Update videotype for specified user.
  433. * @param {string} id user id
  434. * @param {string} newVideoType new videotype
  435. */
  436. UI.onPeerVideoTypeChanged
  437. = (id, newVideoType) => VideoLayout.onVideoTypeChanged(id, newVideoType);
  438. /**
  439. * Update local user role and show notification if user is moderator.
  440. * @param {boolean} isModerator if local user is moderator or not
  441. */
  442. UI.updateLocalRole = isModerator => {
  443. VideoLayout.showModeratorIndicator();
  444. Toolbar.showSipCallButton(isModerator);
  445. Toolbar.showSharedVideoButton(isModerator);
  446. Recording.showRecordingButton(isModerator);
  447. SettingsMenu.showStartMutedOptions(isModerator);
  448. SettingsMenu.showFollowMeOptions(isModerator);
  449. if (isModerator) {
  450. if (!interfaceConfig.DISABLE_FOCUS_INDICATOR)
  451. messageHandler
  452. .notify(null, "notify.me", 'connected', "notify.moderator");
  453. Recording.checkAutoRecord();
  454. }
  455. };
  456. /**
  457. * Check the role for the user and reflect it in the UI, moderator ui indication
  458. * and notifies user who is the moderator
  459. * @param user to check for moderator
  460. */
  461. UI.updateUserRole = user => {
  462. VideoLayout.showModeratorIndicator();
  463. // We don't need to show moderator notifications when the focus (moderator)
  464. // indicator is disabled.
  465. if (!user.isModerator() || interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  466. return;
  467. }
  468. var displayName = user.getDisplayName();
  469. if (displayName) {
  470. messageHandler.notify(
  471. displayName, 'notify.somebody',
  472. 'connected', 'notify.grantedTo', {
  473. to: UIUtil.escapeHtml(displayName)
  474. }
  475. );
  476. } else {
  477. messageHandler.notify(
  478. '', 'notify.somebody',
  479. 'connected', 'notify.grantedToUnknown');
  480. }
  481. };
  482. /**
  483. * Toggles smileys in the chat.
  484. */
  485. UI.toggleSmileys = () => Chat.toggleSmileys();
  486. /**
  487. * Toggles film strip.
  488. */
  489. UI.toggleFilmStrip = function () {
  490. var self = FilmStrip;
  491. self.toggleFilmStrip.apply(self, arguments);
  492. VideoLayout.resizeVideoArea(true, false);
  493. };
  494. /**
  495. * Indicates if the film strip is currently visible or not.
  496. * @returns {true} if the film strip is currently visible, otherwise
  497. */
  498. UI.isFilmStripVisible = () => FilmStrip.isFilmStripVisible();
  499. /**
  500. * Toggles chat panel.
  501. */
  502. UI.toggleChat = () => UI.toggleSidePanel("chat_container");
  503. /**
  504. * Toggles contact list panel.
  505. */
  506. UI.toggleContactList = () => UI.toggleSidePanel("contacts_container");
  507. /**
  508. * Toggles the given side panel.
  509. *
  510. * @param {String} sidePanelId the identifier of the side panel to toggle
  511. */
  512. UI.toggleSidePanel = sidePanelId => SideContainerToggler.toggle(sidePanelId);
  513. /**
  514. * Handle new user display name.
  515. */
  516. UI.inputDisplayNameHandler = function (newDisplayName) {
  517. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  518. };
  519. /**
  520. * Show custom popup/tooltip for a specified button.
  521. * @param popupSelectorID the selector id of the popup to show
  522. * @param show true or false/show or hide the popup
  523. * @param timeout the time to show the popup
  524. */
  525. UI.showCustomToolbarPopup = function (popupSelectorID, show, timeout) {
  526. eventEmitter.emit(UIEvents.SHOW_CUSTOM_TOOLBAR_BUTTON_POPUP,
  527. popupSelectorID, show, timeout);
  528. };
  529. /**
  530. * Return the type of the remote video.
  531. * @param jid the jid for the remote video
  532. * @returns the video type video or screen.
  533. */
  534. UI.getRemoteVideoType = function (jid) {
  535. return VideoLayout.getRemoteVideoType(jid);
  536. };
  537. UI.connectionIndicatorShowMore = function(id) {
  538. VideoLayout.showMore(id);
  539. return false;
  540. };
  541. // FIXME check if someone user this
  542. UI.showLoginPopup = function(callback) {
  543. logger.log('password is required');
  544. let message = (
  545. `<input name="username" type="text"
  546. placeholder="user@domain.net"
  547. class="input-control" autofocus>
  548. <input name="password" type="password"
  549. data-i18n="[placeholder]dialog.userPassword"
  550. class="input-control"
  551. placeholder="user password">`
  552. );
  553. let submitFunction = (e, v, m, f) => {
  554. if (v) {
  555. if (f.username && f.password) {
  556. callback(f.username, f.password);
  557. }
  558. }
  559. };
  560. messageHandler.openTwoButtonDialog({
  561. titleKey : "dialog.passwordRequired",
  562. msgString: message,
  563. leftButtonKey: 'dialog.Ok',
  564. submitFunction,
  565. focus: ':input:first'
  566. });
  567. };
  568. UI.askForNickname = function () {
  569. return window.prompt('Your nickname (optional)');
  570. };
  571. /**
  572. * Sets muted audio state for participant
  573. */
  574. UI.setAudioMuted = function (id, muted) {
  575. VideoLayout.onAudioMute(id, muted);
  576. if (APP.conference.isLocalId(id)) {
  577. Toolbar.toggleAudioIcon(muted);
  578. }
  579. };
  580. /**
  581. * Sets muted video state for participant
  582. */
  583. UI.setVideoMuted = function (id, muted) {
  584. VideoLayout.onVideoMute(id, muted);
  585. if (APP.conference.isLocalId(id)) {
  586. Toolbar.toggleVideoIcon(muted);
  587. }
  588. };
  589. /**
  590. * Adds a listener that would be notified on the given type of event.
  591. *
  592. * @param type the type of the event we're listening for
  593. * @param listener a function that would be called when notified
  594. */
  595. UI.addListener = function (type, listener) {
  596. eventEmitter.on(type, listener);
  597. };
  598. /**
  599. * Removes the given listener for the given type of event.
  600. *
  601. * @param type the type of the event we're listening for
  602. * @param listener the listener we want to remove
  603. */
  604. UI.removeListener = function (type, listener) {
  605. eventEmitter.removeListener(type, listener);
  606. };
  607. /**
  608. * Emits the event of given type by specifying the parameters in options.
  609. *
  610. * @param type the type of the event we're emitting
  611. * @param options the parameters for the event
  612. */
  613. UI.emitEvent = function (type, options) {
  614. eventEmitter.emit(type, options);
  615. };
  616. UI.clickOnVideo = function (videoNumber) {
  617. let videos = $("#remoteVideos .videocontainer:not(#mixedstream)");
  618. let videosLength = videos.length;
  619. if(videosLength <= videoNumber) {
  620. return;
  621. }
  622. let videoIndex = videoNumber === 0 ? 0 : videosLength - videoNumber;
  623. videos[videoIndex].click();
  624. };
  625. //Used by torture
  626. UI.showToolbar = function (timeout) {
  627. return ToolbarToggler.showToolbar(timeout);
  628. };
  629. //Used by torture
  630. UI.dockToolbar = function (isDock) {
  631. ToolbarToggler.dockToolbar(isDock);
  632. };
  633. /**
  634. * Updates the avatar for participant.
  635. * @param {string} id user id
  636. * @param {string} avatarUrl the URL for the avatar
  637. */
  638. function changeAvatar(id, avatarUrl) {
  639. VideoLayout.changeUserAvatar(id, avatarUrl);
  640. if (UI.ContactList)
  641. UI.ContactList.changeUserAvatar(id, avatarUrl);
  642. if (APP.conference.isLocalId(id)) {
  643. Profile.changeAvatar(avatarUrl);
  644. }
  645. }
  646. /**
  647. * Update user email.
  648. * @param {string} id user id
  649. * @param {string} email user email
  650. */
  651. UI.setUserEmail = function (id, email) {
  652. // update avatar
  653. Avatar.setUserEmail(id, email);
  654. changeAvatar(id, Avatar.getAvatarUrl(id));
  655. };
  656. /**
  657. * Update user avtar id.
  658. * @param {string} id user id
  659. * @param {string} avatarId user's avatar id
  660. */
  661. UI.setUserAvatarID = function (id, avatarId) {
  662. // update avatar
  663. Avatar.setUserAvatarID(id, avatarId);
  664. changeAvatar(id, Avatar.getAvatarUrl(id));
  665. };
  666. /**
  667. * Update user avatar URL.
  668. * @param {string} id user id
  669. * @param {string} url user avatar url
  670. */
  671. UI.setUserAvatarUrl = function (id, url) {
  672. // update avatar
  673. Avatar.setUserAvatarUrl(id, url);
  674. changeAvatar(id, Avatar.getAvatarUrl(id));
  675. };
  676. /**
  677. * Notify user that connection failed.
  678. * @param {string} stropheErrorMsg raw Strophe error message
  679. */
  680. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  681. var message;
  682. if (stropheErrorMsg) {
  683. message = APP.translation.generateTranslationHTML(
  684. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  685. } else {
  686. message = APP.translation.generateTranslationHTML(
  687. "dialog.connectError");
  688. }
  689. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  690. };
  691. /**
  692. * Notify user that maximum users limit has been reached.
  693. */
  694. UI.notifyMaxUsersLimitReached = function () {
  695. var message = APP.translation.generateTranslationHTML(
  696. "dialog.maxUsersLimitReached");
  697. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  698. };
  699. /**
  700. * Notify user that he was automatically muted when joned the conference.
  701. */
  702. UI.notifyInitiallyMuted = function () {
  703. messageHandler.notify(
  704. null,
  705. "notify.mutedTitle",
  706. "connected",
  707. "notify.muted",
  708. null,
  709. { timeOut: 120000 });
  710. };
  711. /**
  712. * Mark user as dominant speaker.
  713. * @param {string} id user id
  714. */
  715. UI.markDominantSpeaker = function (id) {
  716. VideoLayout.onDominantSpeakerChanged(id);
  717. };
  718. UI.handleLastNEndpoints = function (ids, enteringIds) {
  719. VideoLayout.onLastNEndpointsChanged(ids, enteringIds);
  720. };
  721. /**
  722. * Will handle notification about participant's connectivity status change.
  723. *
  724. * @param {string} id the id of remote participant(MUC jid)
  725. * @param {boolean} isActive true if the connection is ok or false if the user
  726. * is having connectivity issues.
  727. */
  728. UI.participantConnectionStatusChanged = function (id, isActive) {
  729. VideoLayout.onParticipantConnectionStatusChanged(id, isActive);
  730. };
  731. /**
  732. * Prompt user for nickname.
  733. */
  734. UI.promptDisplayName = () => {
  735. const labelKey = 'dialog.enterDisplayName';
  736. const message = (
  737. `<div class="form-control">
  738. <label data-i18n="${labelKey}" class="form-control__label"></label>
  739. <input name="displayName" type="text"
  740. data-i18n="[placeholder]defaultNickname"
  741. class="input-control" autofocus>
  742. </div>`
  743. );
  744. // Don't use a translation string, because we're too early in the call and
  745. // the translation may not be initialised.
  746. const buttons = { Ok: true };
  747. const dialog = messageHandler.openDialog(
  748. 'dialog.displayNameRequired',
  749. message,
  750. true,
  751. buttons,
  752. (e, v, m, f) => {
  753. e.preventDefault();
  754. if (v) {
  755. const displayName = f.displayName;
  756. if (displayName) {
  757. UI.inputDisplayNameHandler(displayName);
  758. dialog.close();
  759. return;
  760. }
  761. }
  762. },
  763. () => {
  764. const form = $.prompt.getPrompt();
  765. const input = form.find("input[name='displayName']");
  766. const button = form.find("button");
  767. input.focus();
  768. button.attr("disabled", "disabled");
  769. input.keyup(() => {
  770. if (input.val()) {
  771. button.removeAttr("disabled");
  772. } else {
  773. button.attr("disabled", "disabled");
  774. }
  775. });
  776. }
  777. );
  778. };
  779. /**
  780. * Update audio level visualization for specified user.
  781. * @param {string} id user id
  782. * @param {number} lvl audio level
  783. */
  784. UI.setAudioLevel = function (id, lvl) {
  785. VideoLayout.setAudioLevel(id, lvl);
  786. };
  787. /**
  788. * Update state of desktop sharing buttons.
  789. */
  790. UI.updateDesktopSharingButtons = function () {
  791. Toolbar.updateDesktopSharingButtonState();
  792. };
  793. /**
  794. * Hide connection quality statistics from UI.
  795. */
  796. UI.hideStats = function () {
  797. VideoLayout.hideStats();
  798. };
  799. /**
  800. * Update local connection quality statistics.
  801. * @param {number} percent
  802. * @param {object} stats
  803. */
  804. UI.updateLocalStats = function (percent, stats) {
  805. VideoLayout.updateLocalConnectionStats(percent, stats);
  806. };
  807. /**
  808. * Update connection quality statistics for remote user.
  809. * @param {string} id user id
  810. * @param {number} percent
  811. * @param {object} stats
  812. */
  813. UI.updateRemoteStats = function (id, percent, stats) {
  814. VideoLayout.updateConnectionStats(id, percent, stats);
  815. };
  816. /**
  817. * Mark video as interrupted or not.
  818. * @param {boolean} interrupted if video is interrupted
  819. */
  820. UI.markVideoInterrupted = function (interrupted) {
  821. if (interrupted) {
  822. VideoLayout.onVideoInterrupted();
  823. } else {
  824. VideoLayout.onVideoRestored();
  825. }
  826. };
  827. /**
  828. * Add chat message.
  829. * @param {string} from user id
  830. * @param {string} displayName user nickname
  831. * @param {string} message message text
  832. * @param {number} stamp timestamp when message was created
  833. */
  834. UI.addMessage = function (from, displayName, message, stamp) {
  835. Chat.updateChatConversation(from, displayName, message, stamp);
  836. };
  837. // eslint-disable-next-line no-unused-vars
  838. UI.updateDTMFSupport = function (isDTMFSupported) {
  839. //TODO: enable when the UI is ready
  840. //Toolbar.showDialPadButton(isDTMFSupported);
  841. };
  842. /**
  843. * Show user feedback dialog if its required and enabled after pressing the
  844. * hangup button.
  845. * @returns {Promise} Resolved with value - false if the dialog is enabled and
  846. * resolved with true if the dialog is disabled or the feedback was already
  847. * submitted. Rejected if another dialog is already displayed. This values are
  848. * used to display or not display the thank you dialog from
  849. * conference.maybeRedirectToWelcomePage method.
  850. */
  851. UI.requestFeedbackOnHangup = function () {
  852. if (Feedback.isVisible())
  853. return Promise.reject(UIErrors.FEEDBACK_REQUEST_IN_PROGRESS);
  854. // Feedback has been submitted already.
  855. else if (Feedback.isEnabled() && Feedback.isSubmitted()) {
  856. return Promise.resolve({
  857. thankYouDialogVisible : true,
  858. feedbackSubmitted: true
  859. });
  860. }
  861. else
  862. return new Promise(function (resolve) {
  863. if (Feedback.isEnabled()) {
  864. Feedback.openFeedbackWindow(
  865. (options) => {
  866. options.thankYouDialogVisible = false;
  867. resolve(options);
  868. });
  869. } else {
  870. // If the feedback functionality isn't enabled we show a thank
  871. // you dialog. Signaling it (true), so the caller
  872. // of requestFeedback can act on it
  873. resolve(
  874. {thankYouDialogVisible : true, feedbackSubmitted: false});
  875. }
  876. });
  877. };
  878. UI.updateRecordingState = function (state) {
  879. Recording.updateRecordingState(state);
  880. };
  881. UI.notifyTokenAuthFailed = function () {
  882. messageHandler.showError( "dialog.tokenAuthFailedTitle",
  883. "dialog.tokenAuthFailed");
  884. };
  885. UI.notifyInternalError = function () {
  886. messageHandler.showError( "dialog.internalErrorTitle",
  887. "dialog.internalError");
  888. };
  889. UI.notifyFocusDisconnected = function (focus, retrySec) {
  890. messageHandler.notify(
  891. null, "notify.focus",
  892. 'disconnected', "notify.focusFail",
  893. {component: focus, ms: retrySec}
  894. );
  895. };
  896. /**
  897. * Updates auth info on the UI.
  898. * @param {boolean} isAuthEnabled if authentication is enabled
  899. * @param {string} [login] current login
  900. */
  901. UI.updateAuthInfo = function (isAuthEnabled, login) {
  902. let showAuth = isAuthEnabled && UIUtil.isAuthenticationEnabled();
  903. let loggedIn = !!login;
  904. Profile.showAuthenticationButtons(showAuth);
  905. if (showAuth) {
  906. Profile.setAuthenticatedIdentity(login);
  907. Profile.showLoginButton(!loggedIn);
  908. Profile.showLogoutButton(loggedIn);
  909. }
  910. };
  911. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  912. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  913. };
  914. /**
  915. * Notifies interested listeners that the raise hand property has changed.
  916. *
  917. * @param {boolean} isRaisedHand indicates the current state of the
  918. * "raised hand"
  919. */
  920. UI.onLocalRaiseHandChanged = function (isRaisedHand) {
  921. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  922. };
  923. /**
  924. * Update list of available physical devices.
  925. * @param {object[]} devices new list of available devices
  926. */
  927. UI.onAvailableDevicesChanged = function (devices) {
  928. SettingsMenu.changeDevicesList(devices);
  929. };
  930. /**
  931. * Sets microphone's <select> element to select microphone ID from settings.
  932. */
  933. UI.setSelectedMicFromSettings = function () {
  934. SettingsMenu.setSelectedMicFromSettings();
  935. };
  936. /**
  937. * Sets camera's <select> element to select camera ID from settings.
  938. */
  939. UI.setSelectedCameraFromSettings = function () {
  940. SettingsMenu.setSelectedCameraFromSettings();
  941. };
  942. /**
  943. * Sets audio outputs's <select> element to select audio output ID from
  944. * settings.
  945. */
  946. UI.setSelectedAudioOutputFromSettings = function () {
  947. SettingsMenu.setSelectedAudioOutputFromSettings();
  948. };
  949. /**
  950. * Returns the id of the current video shown on large.
  951. * Currently used by tests (torture).
  952. */
  953. UI.getLargeVideoID = function () {
  954. return VideoLayout.getLargeVideoID();
  955. };
  956. /**
  957. * Returns the current video shown on large.
  958. * Currently used by tests (torture).
  959. */
  960. UI.getLargeVideo = function () {
  961. return VideoLayout.getLargeVideo();
  962. };
  963. /**
  964. * Shows dialog with a link to FF extension.
  965. */
  966. UI.showExtensionRequiredDialog = function (url) {
  967. messageHandler.openMessageDialog(
  968. "dialog.extensionRequired",
  969. "[html]dialog.firefoxExtensionPrompt",
  970. {url: url});
  971. };
  972. /**
  973. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  974. * 2 button dialog with buttons - cancel and go to web store.
  975. * @param url {string} the url of the extension.
  976. */
  977. UI.showExtensionExternalInstallationDialog = function (url) {
  978. let submitFunction = function(e,v){
  979. if (v) {
  980. e.preventDefault();
  981. eventEmitter.emit(UIEvents.OPEN_EXTENSION_STORE, url);
  982. }
  983. };
  984. let closeFunction = function () {
  985. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  986. };
  987. messageHandler.openTwoButtonDialog({
  988. titleKey: 'dialog.externalInstallationTitle',
  989. msgKey: 'dialog.externalInstallationMsg',
  990. leftButtonKey: 'dialog.goToStore',
  991. submitFunction,
  992. loadedFunction: $.noop,
  993. closeFunction
  994. });
  995. };
  996. /**
  997. * Shows dialog with combined information about camera and microphone errors.
  998. * @param {JitsiTrackError} micError
  999. * @param {JitsiTrackError} cameraError
  1000. */
  1001. UI.showDeviceErrorDialog = function (micError, cameraError) {
  1002. let dontShowAgain = {
  1003. id: "doNotShowWarningAgain",
  1004. localStorageKey: "doNotShowErrorAgain",
  1005. textKey: "dialog.doNotShowWarningAgain"
  1006. };
  1007. let isMicJitsiTrackErrorAndHasName = micError && micError.name &&
  1008. micError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1009. let isCameraJitsiTrackErrorAndHasName = cameraError && cameraError.name &&
  1010. cameraError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1011. let showDoNotShowWarning = false;
  1012. if (micError && cameraError && isMicJitsiTrackErrorAndHasName &&
  1013. isCameraJitsiTrackErrorAndHasName) {
  1014. showDoNotShowWarning = true;
  1015. } else if (micError && isMicJitsiTrackErrorAndHasName && !cameraError) {
  1016. showDoNotShowWarning = true;
  1017. } else if (cameraError && isCameraJitsiTrackErrorAndHasName && !micError) {
  1018. showDoNotShowWarning = true;
  1019. }
  1020. if (micError) {
  1021. dontShowAgain.localStorageKey += "-mic-" + micError.name;
  1022. }
  1023. if (cameraError) {
  1024. dontShowAgain.localStorageKey += "-camera-" + cameraError.name;
  1025. }
  1026. let cameraJitsiTrackErrorMsg = cameraError
  1027. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[cameraError.name]
  1028. : undefined;
  1029. let micJitsiTrackErrorMsg = micError
  1030. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[micError.name]
  1031. : undefined;
  1032. let cameraErrorMsg = cameraError
  1033. ? cameraJitsiTrackErrorMsg ||
  1034. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  1035. : "";
  1036. let micErrorMsg = micError
  1037. ? micJitsiTrackErrorMsg ||
  1038. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  1039. : "";
  1040. let additionalCameraErrorMsg = !cameraJitsiTrackErrorMsg && cameraError &&
  1041. cameraError.message
  1042. ? `<div>${cameraError.message}</div>`
  1043. : ``;
  1044. let additionalMicErrorMsg = !micJitsiTrackErrorMsg && micError &&
  1045. micError.message
  1046. ? `<div>${micError.message}</div>`
  1047. : ``;
  1048. let message = '';
  1049. if (micError) {
  1050. message = `
  1051. ${message}
  1052. <h3 data-i18n='dialog.micErrorPresent'></h3>
  1053. <h4 data-i18n='${micErrorMsg}'></h4>
  1054. ${additionalMicErrorMsg}`;
  1055. }
  1056. if (cameraError) {
  1057. message = `
  1058. ${message}
  1059. <h3 data-i18n='dialog.cameraErrorPresent'></h3>
  1060. <h4 data-i18n='${cameraErrorMsg}'></h4>
  1061. ${additionalCameraErrorMsg}`;
  1062. }
  1063. // To make sure we don't have multiple error dialogs open at the same time,
  1064. // we will just close the previous one if we are going to show a new one.
  1065. deviceErrorDialog && deviceErrorDialog.close();
  1066. deviceErrorDialog = messageHandler.openDialog(
  1067. getTitleKey(),
  1068. message,
  1069. false,
  1070. {Ok: true},
  1071. function () {},
  1072. null,
  1073. function () {
  1074. // Reset dialog reference to null to avoid memory leaks when
  1075. // user closed the dialog manually.
  1076. deviceErrorDialog = null;
  1077. },
  1078. showDoNotShowWarning ? dontShowAgain : undefined
  1079. );
  1080. function getTitleKey() {
  1081. let title = "dialog.error";
  1082. if (micError && micError.name === TrackErrors.PERMISSION_DENIED) {
  1083. if (!cameraError
  1084. || cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1085. title = "dialog.permissionDenied";
  1086. }
  1087. } else if (cameraError
  1088. && cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1089. title = "dialog.permissionDenied";
  1090. }
  1091. return title;
  1092. }
  1093. };
  1094. /**
  1095. * Shows error dialog that informs the user that no data is received from the
  1096. * device.
  1097. */
  1098. UI.showTrackNotWorkingDialog = function (stream) {
  1099. messageHandler.openMessageDialog(
  1100. "dialog.error",
  1101. stream.isAudioTrack()? "dialog.micNotSendingData" :
  1102. "dialog.cameraNotSendingData");
  1103. };
  1104. UI.updateDevicesAvailability = function (id, devices) {
  1105. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1106. };
  1107. /**
  1108. * Show shared video.
  1109. * @param {string} id the id of the sender of the command
  1110. * @param {string} url video url
  1111. * @param {string} attributes
  1112. */
  1113. UI.onSharedVideoStart = function (id, url, attributes) {
  1114. if (sharedVideoManager)
  1115. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1116. };
  1117. /**
  1118. * Update shared video.
  1119. * @param {string} id the id of the sender of the command
  1120. * @param {string} url video url
  1121. * @param {string} attributes
  1122. */
  1123. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1124. if (sharedVideoManager)
  1125. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1126. };
  1127. /**
  1128. * Stop showing shared video.
  1129. * @param {string} id the id of the sender of the command
  1130. * @param {string} attributes
  1131. */
  1132. UI.onSharedVideoStop = function (id, attributes) {
  1133. if (sharedVideoManager)
  1134. sharedVideoManager.onSharedVideoStop(id, attributes);
  1135. };
  1136. /**
  1137. * Enables / disables camera toolbar button.
  1138. *
  1139. * @param {boolean} enabled indicates if the camera button should be enabled
  1140. * or disabled
  1141. */
  1142. UI.setCameraButtonEnabled = enabled => Toolbar.setVideoIconEnabled(enabled);
  1143. /**
  1144. * Enables / disables microphone toolbar button.
  1145. *
  1146. * @param {boolean} enabled indicates if the microphone button should be
  1147. * enabled or disabled
  1148. */
  1149. UI.setMicrophoneButtonEnabled = enabled => Toolbar.setAudioIconEnabled(enabled);
  1150. UI.showRingOverlay = function () {
  1151. RingOverlay.show(APP.tokenData.callee, interfaceConfig.DISABLE_RINGING);
  1152. FilmStrip.toggleFilmStrip(false, false);
  1153. };
  1154. UI.hideRingOverLay = function () {
  1155. if (!RingOverlay.hide())
  1156. return;
  1157. FilmStrip.toggleFilmStrip(true, false);
  1158. };
  1159. /**
  1160. * Indicates if any the "top" overlays are currently visible. The check includes
  1161. * the call overlay, suspended overlay, GUM permissions overlay
  1162. * and a page reload overlay.
  1163. *
  1164. * @returns {*|boolean} {true} if the overlay is visible, {false} otherwise
  1165. */
  1166. UI.isOverlayVisible = function () {
  1167. return RingOverlay.isVisible() || this.overlayVisible;
  1168. };
  1169. /**
  1170. * Indicates if the ring overlay is currently visible.
  1171. *
  1172. * @returns {*|boolean} {true} if the ring overlay is visible, {false} otherwise
  1173. */
  1174. UI.isRingOverlayVisible = () => RingOverlay.isVisible();
  1175. /**
  1176. * Handles user's features changes.
  1177. */
  1178. UI.onUserFeaturesChanged = user => VideoLayout.onUserFeaturesChanged(user);
  1179. const UIListeners = new Map([
  1180. [
  1181. UIEvents.ETHERPAD_CLICKED,
  1182. () => etherpadManager && etherpadManager.toggleEtherpad()
  1183. ], [
  1184. UIEvents.SHARED_VIDEO_CLICKED,
  1185. () => sharedVideoManager && sharedVideoManager.toggleSharedVideo()
  1186. ], [
  1187. UIEvents.TOGGLE_FULLSCREEN,
  1188. UI.toggleFullScreen
  1189. ], [
  1190. UIEvents.TOGGLE_CHAT,
  1191. UI.toggleChat
  1192. ], [
  1193. UIEvents.TOGGLE_SETTINGS,
  1194. () => UI.toggleSidePanel("settings_container")
  1195. ], [
  1196. UIEvents.TOGGLE_CONTACT_LIST,
  1197. UI.toggleContactList
  1198. ], [
  1199. UIEvents.TOGGLE_PROFILE,
  1200. () => APP.tokenData.isGuest && UI.toggleSidePanel("profile_container")
  1201. ], [
  1202. UIEvents.TOGGLE_FILM_STRIP,
  1203. UI.handleToggleFilmStrip
  1204. ], [
  1205. UIEvents.FOLLOW_ME_ENABLED,
  1206. enabled => (followMeHandler && followMeHandler.enableFollowMe(enabled))
  1207. ]
  1208. ]);
  1209. module.exports = UI;