Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

UI.js 39KB

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