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.

UI.js 39KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399
  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. // Display notice message at the top of the toolbar
  273. if (config.noticeMessage) {
  274. $('#noticeText').text(config.noticeMessage);
  275. UIUtil.setVisible('notice', true);
  276. }
  277. } else {
  278. $("body").addClass("filmstrip-only");
  279. UIUtil.setVisible('mainToolbarContainer', false);
  280. FilmStrip.setupFilmStripOnly();
  281. messageHandler.enableNotifications(false);
  282. JitsiPopover.enabled = false;
  283. }
  284. document.title = interfaceConfig.APP_NAME;
  285. if (!interfaceConfig.filmStripOnly) {
  286. toastr.options = {
  287. "closeButton": true,
  288. "debug": false,
  289. "positionClass": "notification-bottom-right",
  290. "onclick": null,
  291. "showDuration": "300",
  292. "hideDuration": "1000",
  293. "timeOut": "2000",
  294. "extendedTimeOut": "1000",
  295. "showEasing": "swing",
  296. "hideEasing": "linear",
  297. "showMethod": "fadeIn",
  298. "hideMethod": "fadeOut",
  299. "newestOnTop": false,
  300. // this is the default toastr close button html, just adds tabIndex
  301. "closeHtml": '<button type="button" tabIndex="-1">&times;</button>'
  302. };
  303. }
  304. if(APP.tokenData.callee) {
  305. UI.showRingOverlay();
  306. }
  307. };
  308. /**
  309. * Setup some UI event listeners.
  310. */
  311. UI.registerListeners
  312. = () => UIListeners.forEach((value, key) => UI.addListener(key, value));
  313. /**
  314. * Unregister some UI event listeners.
  315. */
  316. UI.unregisterListeners
  317. = () => UIListeners.forEach((value, key) => UI.removeListener(key, value));
  318. /**
  319. * Setup some DOM event listeners.
  320. */
  321. UI.bindEvents = () => {
  322. function onResize() {
  323. SideContainerToggler.resize();
  324. VideoLayout.resizeVideoArea();
  325. }
  326. // Resize and reposition videos in full screen mode.
  327. $(document).on(
  328. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  329. () => {
  330. eventEmitter.emit(
  331. UIEvents.FULLSCREEN_TOGGLED,
  332. UIUtil.isFullScreen());
  333. onResize();
  334. });
  335. $(window).resize(onResize);
  336. };
  337. /**
  338. * Unbind some DOM event listeners.
  339. */
  340. UI.unbindEvents = () => {
  341. $(document).off(
  342. 'webkitfullscreenchange mozfullscreenchange fullscreenchange');
  343. $(window).off('resize');
  344. };
  345. /**
  346. * Show local stream on UI.
  347. * @param {JitsiTrack} track stream to show
  348. */
  349. UI.addLocalStream = track => {
  350. switch (track.getType()) {
  351. case 'audio':
  352. VideoLayout.changeLocalAudio(track);
  353. break;
  354. case 'video':
  355. VideoLayout.changeLocalVideo(track);
  356. break;
  357. default:
  358. logger.error("Unknown stream type: " + track.getType());
  359. break;
  360. }
  361. };
  362. /**
  363. * Show remote stream on UI.
  364. * @param {JitsiTrack} track stream to show
  365. */
  366. UI.addRemoteStream = track => VideoLayout.onRemoteStreamAdded(track);
  367. /**
  368. * Removed remote stream from UI.
  369. * @param {JitsiTrack} track stream to remove
  370. */
  371. UI.removeRemoteStream = track => VideoLayout.onRemoteStreamRemoved(track);
  372. /**
  373. * Update chat subject.
  374. * @param {string} subject new chat subject
  375. */
  376. UI.setSubject = subject => Chat.setSubject(subject);
  377. /**
  378. * Setup and show Etherpad.
  379. * @param {string} name etherpad id
  380. */
  381. UI.initEtherpad = name => {
  382. if (etherpadManager || !config.etherpad_base || !name) {
  383. return;
  384. }
  385. logger.log('Etherpad is enabled');
  386. etherpadManager
  387. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  388. Toolbar.showEtherpadButton();
  389. };
  390. /**
  391. * Returns the shared document manager object.
  392. * @return {EtherpadManager} the shared document manager object
  393. */
  394. UI.getSharedDocumentManager = () => etherpadManager;
  395. /**
  396. * Show user on UI.
  397. * @param {JitsiParticipant} user
  398. */
  399. UI.addUser = function (user) {
  400. var id = user.getId();
  401. var displayName = user.getDisplayName();
  402. UI.hideRingOverLay();
  403. if (UI.ContactList)
  404. UI.ContactList.addContact(id);
  405. messageHandler.notify(
  406. displayName,'notify.somebody', 'connected', 'notify.connected'
  407. );
  408. if (!config.startAudioMuted ||
  409. config.startAudioMuted > APP.conference.membersCount)
  410. UIUtil.playSoundNotification('userJoined');
  411. // Add Peer's container
  412. VideoLayout.addParticipantContainer(user);
  413. // Configure avatar
  414. UI.setUserEmail(id);
  415. // set initial display name
  416. if(displayName)
  417. UI.changeDisplayName(id, displayName);
  418. };
  419. /**
  420. * Remove user from UI.
  421. * @param {string} id user id
  422. * @param {string} displayName user nickname
  423. */
  424. UI.removeUser = function (id, displayName) {
  425. if (UI.ContactList)
  426. UI.ContactList.removeContact(id);
  427. messageHandler.notify(
  428. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  429. );
  430. if (!config.startAudioMuted
  431. || config.startAudioMuted > APP.conference.membersCount) {
  432. UIUtil.playSoundNotification('userLeft');
  433. }
  434. VideoLayout.removeParticipantContainer(id);
  435. };
  436. /**
  437. * Update videotype for specified user.
  438. * @param {string} id user id
  439. * @param {string} newVideoType new videotype
  440. */
  441. UI.onPeerVideoTypeChanged
  442. = (id, newVideoType) => VideoLayout.onVideoTypeChanged(id, newVideoType);
  443. /**
  444. * Update local user role and show notification if user is moderator.
  445. * @param {boolean} isModerator if local user is moderator or not
  446. */
  447. UI.updateLocalRole = isModerator => {
  448. VideoLayout.showModeratorIndicator();
  449. Toolbar.showSipCallButton(isModerator);
  450. Toolbar.showSharedVideoButton(isModerator);
  451. Recording.showRecordingButton(isModerator);
  452. SettingsMenu.showStartMutedOptions(isModerator);
  453. SettingsMenu.showFollowMeOptions(isModerator);
  454. if (isModerator) {
  455. if (!interfaceConfig.DISABLE_FOCUS_INDICATOR)
  456. messageHandler
  457. .notify(null, "notify.me", 'connected', "notify.moderator");
  458. Recording.checkAutoRecord();
  459. }
  460. };
  461. /**
  462. * Check the role for the user and reflect it in the UI, moderator ui indication
  463. * and notifies user who is the moderator
  464. * @param user to check for moderator
  465. */
  466. UI.updateUserRole = user => {
  467. VideoLayout.showModeratorIndicator();
  468. // We don't need to show moderator notifications when the focus (moderator)
  469. // indicator is disabled.
  470. if (!user.isModerator() || interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  471. return;
  472. }
  473. var displayName = user.getDisplayName();
  474. if (displayName) {
  475. messageHandler.notify(
  476. displayName, 'notify.somebody',
  477. 'connected', 'notify.grantedTo', {
  478. to: UIUtil.escapeHtml(displayName)
  479. }
  480. );
  481. } else {
  482. messageHandler.notify(
  483. '', 'notify.somebody',
  484. 'connected', 'notify.grantedToUnknown');
  485. }
  486. };
  487. /**
  488. * Toggles smileys in the chat.
  489. */
  490. UI.toggleSmileys = () => Chat.toggleSmileys();
  491. /**
  492. * Toggles film strip.
  493. */
  494. UI.toggleFilmStrip = function () {
  495. var self = FilmStrip;
  496. self.toggleFilmStrip.apply(self, arguments);
  497. VideoLayout.resizeVideoArea(true, false);
  498. };
  499. /**
  500. * Indicates if the film strip is currently visible or not.
  501. * @returns {true} if the film strip is currently visible, otherwise
  502. */
  503. UI.isFilmStripVisible = () => FilmStrip.isFilmStripVisible();
  504. /**
  505. * Toggles chat panel.
  506. */
  507. UI.toggleChat = () => UI.toggleSidePanel("chat_container");
  508. /**
  509. * Toggles contact list panel.
  510. */
  511. UI.toggleContactList = () => UI.toggleSidePanel("contacts_container");
  512. /**
  513. * Toggles the given side panel.
  514. *
  515. * @param {String} sidePanelId the identifier of the side panel to toggle
  516. */
  517. UI.toggleSidePanel = sidePanelId => SideContainerToggler.toggle(sidePanelId);
  518. /**
  519. * Handle new user display name.
  520. */
  521. UI.inputDisplayNameHandler = function (newDisplayName) {
  522. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  523. };
  524. /**
  525. * Show custom popup/tooltip for a specified button.
  526. * @param popupSelectorID the selector id of the popup to show
  527. * @param show true or false/show or hide the popup
  528. * @param timeout the time to show the popup
  529. */
  530. UI.showCustomToolbarPopup = function (popupSelectorID, show, timeout) {
  531. eventEmitter.emit(UIEvents.SHOW_CUSTOM_TOOLBAR_BUTTON_POPUP,
  532. popupSelectorID, show, timeout);
  533. };
  534. /**
  535. * Return the type of the remote video.
  536. * @param jid the jid for the remote video
  537. * @returns the video type video or screen.
  538. */
  539. UI.getRemoteVideoType = function (jid) {
  540. return VideoLayout.getRemoteVideoType(jid);
  541. };
  542. UI.connectionIndicatorShowMore = function(id) {
  543. VideoLayout.showMore(id);
  544. return false;
  545. };
  546. // FIXME check if someone user this
  547. UI.showLoginPopup = function(callback) {
  548. logger.log('password is required');
  549. let message = (
  550. `<input name="username" type="text"
  551. placeholder="user@domain.net"
  552. class="input-control" autofocus>
  553. <input name="password" type="password"
  554. data-i18n="[placeholder]dialog.userPassword"
  555. class="input-control"
  556. placeholder="user password">`
  557. );
  558. let submitFunction = (e, v, m, f) => {
  559. if (v) {
  560. if (f.username && f.password) {
  561. callback(f.username, f.password);
  562. }
  563. }
  564. };
  565. messageHandler.openTwoButtonDialog({
  566. titleKey : "dialog.passwordRequired",
  567. msgString: message,
  568. leftButtonKey: 'dialog.Ok',
  569. submitFunction,
  570. focus: ':input:first'
  571. });
  572. };
  573. UI.askForNickname = function () {
  574. return window.prompt('Your nickname (optional)');
  575. };
  576. /**
  577. * Sets muted audio state for participant
  578. */
  579. UI.setAudioMuted = function (id, muted) {
  580. VideoLayout.onAudioMute(id, muted);
  581. if (APP.conference.isLocalId(id)) {
  582. Toolbar.toggleAudioIcon(muted);
  583. }
  584. };
  585. /**
  586. * Sets muted video state for participant
  587. */
  588. UI.setVideoMuted = function (id, muted) {
  589. VideoLayout.onVideoMute(id, muted);
  590. if (APP.conference.isLocalId(id)) {
  591. Toolbar.toggleVideoIcon(muted);
  592. }
  593. };
  594. /**
  595. * Adds a listener that would be notified on the given type of event.
  596. *
  597. * @param type the type of the event we're listening for
  598. * @param listener a function that would be called when notified
  599. */
  600. UI.addListener = function (type, listener) {
  601. eventEmitter.on(type, listener);
  602. };
  603. /**
  604. * Removes the given listener for the given type of event.
  605. *
  606. * @param type the type of the event we're listening for
  607. * @param listener the listener we want to remove
  608. */
  609. UI.removeListener = function (type, listener) {
  610. eventEmitter.removeListener(type, listener);
  611. };
  612. /**
  613. * Emits the event of given type by specifying the parameters in options.
  614. *
  615. * @param type the type of the event we're emitting
  616. * @param options the parameters for the event
  617. */
  618. UI.emitEvent = function (type, options) {
  619. eventEmitter.emit(type, options);
  620. };
  621. UI.clickOnVideo = function (videoNumber) {
  622. let videos = $("#remoteVideos .videocontainer:not(#mixedstream)");
  623. let videosLength = videos.length;
  624. if(videosLength <= videoNumber) {
  625. return;
  626. }
  627. let videoIndex = videoNumber === 0 ? 0 : videosLength - videoNumber;
  628. videos[videoIndex].click();
  629. };
  630. //Used by torture
  631. UI.showToolbar = function (timeout) {
  632. return ToolbarToggler.showToolbar(timeout);
  633. };
  634. //Used by torture
  635. UI.dockToolbar = function (isDock) {
  636. ToolbarToggler.dockToolbar(isDock);
  637. };
  638. /**
  639. * Updates the avatar for participant.
  640. * @param {string} id user id
  641. * @param {string} avatarUrl the URL for the avatar
  642. */
  643. function changeAvatar(id, avatarUrl) {
  644. VideoLayout.changeUserAvatar(id, avatarUrl);
  645. if (UI.ContactList)
  646. UI.ContactList.changeUserAvatar(id, avatarUrl);
  647. if (APP.conference.isLocalId(id)) {
  648. Profile.changeAvatar(avatarUrl);
  649. }
  650. }
  651. /**
  652. * Update user email.
  653. * @param {string} id user id
  654. * @param {string} email user email
  655. */
  656. UI.setUserEmail = function (id, email) {
  657. // update avatar
  658. Avatar.setUserEmail(id, email);
  659. changeAvatar(id, Avatar.getAvatarUrl(id));
  660. };
  661. /**
  662. * Update user avtar id.
  663. * @param {string} id user id
  664. * @param {string} avatarId user's avatar id
  665. */
  666. UI.setUserAvatarID = function (id, avatarId) {
  667. // update avatar
  668. Avatar.setUserAvatarID(id, avatarId);
  669. changeAvatar(id, Avatar.getAvatarUrl(id));
  670. };
  671. /**
  672. * Update user avatar URL.
  673. * @param {string} id user id
  674. * @param {string} url user avatar url
  675. */
  676. UI.setUserAvatarUrl = function (id, url) {
  677. // update avatar
  678. Avatar.setUserAvatarUrl(id, url);
  679. changeAvatar(id, Avatar.getAvatarUrl(id));
  680. };
  681. /**
  682. * Notify user that connection failed.
  683. * @param {string} stropheErrorMsg raw Strophe error message
  684. */
  685. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  686. var message;
  687. if (stropheErrorMsg) {
  688. message = APP.translation.generateTranslationHTML(
  689. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  690. } else {
  691. message = APP.translation.generateTranslationHTML(
  692. "dialog.connectError");
  693. }
  694. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  695. };
  696. /**
  697. * Notify user that maximum users limit has been reached.
  698. */
  699. UI.notifyMaxUsersLimitReached = function () {
  700. var message = APP.translation.generateTranslationHTML(
  701. "dialog.maxUsersLimitReached");
  702. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  703. };
  704. /**
  705. * Notify user that he was automatically muted when joned the conference.
  706. */
  707. UI.notifyInitiallyMuted = function () {
  708. messageHandler.notify(
  709. null,
  710. "notify.mutedTitle",
  711. "connected",
  712. "notify.muted",
  713. null,
  714. { timeOut: 120000 });
  715. };
  716. /**
  717. * Mark user as dominant speaker.
  718. * @param {string} id user id
  719. */
  720. UI.markDominantSpeaker = function (id) {
  721. VideoLayout.onDominantSpeakerChanged(id);
  722. };
  723. UI.handleLastNEndpoints = function (ids, enteringIds) {
  724. VideoLayout.onLastNEndpointsChanged(ids, enteringIds);
  725. };
  726. /**
  727. * Will handle notification about participant's connectivity status change.
  728. *
  729. * @param {string} id the id of remote participant(MUC jid)
  730. * @param {boolean} isActive true if the connection is ok or false if the user
  731. * is having connectivity issues.
  732. */
  733. UI.participantConnectionStatusChanged = function (id, isActive) {
  734. VideoLayout.onParticipantConnectionStatusChanged(id, isActive);
  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 = function (id, lvl) {
  790. VideoLayout.setAudioLevel(id, lvl);
  791. };
  792. /**
  793. * Update state of desktop sharing buttons.
  794. */
  795. UI.updateDesktopSharingButtons = function () {
  796. Toolbar.updateDesktopSharingButtonState();
  797. };
  798. /**
  799. * Hide connection quality statistics from UI.
  800. */
  801. UI.hideStats = function () {
  802. VideoLayout.hideStats();
  803. };
  804. /**
  805. * Update local connection quality statistics.
  806. * @param {number} percent
  807. * @param {object} stats
  808. */
  809. UI.updateLocalStats = function (percent, stats) {
  810. VideoLayout.updateLocalConnectionStats(percent, stats);
  811. };
  812. /**
  813. * Update connection quality statistics for remote user.
  814. * @param {string} id user id
  815. * @param {number} percent
  816. * @param {object} stats
  817. */
  818. UI.updateRemoteStats = function (id, percent, stats) {
  819. VideoLayout.updateConnectionStats(id, percent, stats);
  820. };
  821. /**
  822. * Mark video as interrupted or not.
  823. * @param {boolean} interrupted if video is interrupted
  824. */
  825. UI.markVideoInterrupted = function (interrupted) {
  826. if (interrupted) {
  827. VideoLayout.onVideoInterrupted();
  828. } else {
  829. VideoLayout.onVideoRestored();
  830. }
  831. };
  832. /**
  833. * Add chat message.
  834. * @param {string} from user id
  835. * @param {string} displayName user nickname
  836. * @param {string} message message text
  837. * @param {number} stamp timestamp when message was created
  838. */
  839. UI.addMessage = function (from, displayName, message, stamp) {
  840. Chat.updateChatConversation(from, displayName, message, stamp);
  841. };
  842. // eslint-disable-next-line no-unused-vars
  843. UI.updateDTMFSupport = function (isDTMFSupported) {
  844. //TODO: enable when the UI is ready
  845. //Toolbar.showDialPadButton(isDTMFSupported);
  846. };
  847. /**
  848. * Show user feedback dialog if its required and enabled after pressing the
  849. * hangup button.
  850. * @returns {Promise} Resolved with value - false if the dialog is enabled and
  851. * resolved with true if the dialog is disabled or the feedback was already
  852. * submitted. Rejected if another dialog is already displayed. This values are
  853. * used to display or not display the thank you dialog from
  854. * conference.maybeRedirectToWelcomePage method.
  855. */
  856. UI.requestFeedbackOnHangup = function () {
  857. if (Feedback.isVisible())
  858. return Promise.reject(UIErrors.FEEDBACK_REQUEST_IN_PROGRESS);
  859. // Feedback has been submitted already.
  860. else if (Feedback.isEnabled() && Feedback.isSubmitted()) {
  861. return Promise.resolve({
  862. thankYouDialogVisible : true,
  863. feedbackSubmitted: true
  864. });
  865. }
  866. else
  867. return new Promise(function (resolve) {
  868. if (Feedback.isEnabled()) {
  869. Feedback.openFeedbackWindow(
  870. (options) => {
  871. options.thankYouDialogVisible = false;
  872. resolve(options);
  873. });
  874. } else {
  875. // If the feedback functionality isn't enabled we show a thank
  876. // you dialog. Signaling it (true), so the caller
  877. // of requestFeedback can act on it
  878. resolve(
  879. {thankYouDialogVisible : true, feedbackSubmitted: false});
  880. }
  881. });
  882. };
  883. UI.updateRecordingState = function (state) {
  884. Recording.updateRecordingState(state);
  885. };
  886. UI.notifyTokenAuthFailed = function () {
  887. messageHandler.showError( "dialog.tokenAuthFailedTitle",
  888. "dialog.tokenAuthFailed");
  889. };
  890. UI.notifyInternalError = function () {
  891. messageHandler.showError( "dialog.internalErrorTitle",
  892. "dialog.internalError");
  893. };
  894. UI.notifyFocusDisconnected = function (focus, retrySec) {
  895. messageHandler.notify(
  896. null, "notify.focus",
  897. 'disconnected', "notify.focusFail",
  898. {component: focus, ms: retrySec}
  899. );
  900. };
  901. /**
  902. * Updates auth info on the UI.
  903. * @param {boolean} isAuthEnabled if authentication is enabled
  904. * @param {string} [login] current login
  905. */
  906. UI.updateAuthInfo = function (isAuthEnabled, login) {
  907. let showAuth = isAuthEnabled && UIUtil.isAuthenticationEnabled();
  908. let loggedIn = !!login;
  909. Profile.showAuthenticationButtons(showAuth);
  910. if (showAuth) {
  911. Profile.setAuthenticatedIdentity(login);
  912. Profile.showLoginButton(!loggedIn);
  913. Profile.showLogoutButton(loggedIn);
  914. }
  915. };
  916. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  917. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  918. };
  919. /**
  920. * Notifies interested listeners that the raise hand property has changed.
  921. *
  922. * @param {boolean} isRaisedHand indicates the current state of the
  923. * "raised hand"
  924. */
  925. UI.onLocalRaiseHandChanged = function (isRaisedHand) {
  926. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  927. };
  928. /**
  929. * Update list of available physical devices.
  930. * @param {object[]} devices new list of available devices
  931. */
  932. UI.onAvailableDevicesChanged = function (devices) {
  933. SettingsMenu.changeDevicesList(devices);
  934. };
  935. /**
  936. * Sets microphone's <select> element to select microphone ID from settings.
  937. */
  938. UI.setSelectedMicFromSettings = function () {
  939. SettingsMenu.setSelectedMicFromSettings();
  940. };
  941. /**
  942. * Sets camera's <select> element to select camera ID from settings.
  943. */
  944. UI.setSelectedCameraFromSettings = function () {
  945. SettingsMenu.setSelectedCameraFromSettings();
  946. };
  947. /**
  948. * Sets audio outputs's <select> element to select audio output ID from
  949. * settings.
  950. */
  951. UI.setSelectedAudioOutputFromSettings = function () {
  952. SettingsMenu.setSelectedAudioOutputFromSettings();
  953. };
  954. /**
  955. * Returns the id of the current video shown on large.
  956. * Currently used by tests (torture).
  957. */
  958. UI.getLargeVideoID = function () {
  959. return VideoLayout.getLargeVideoID();
  960. };
  961. /**
  962. * Returns the current video shown on large.
  963. * Currently used by tests (torture).
  964. */
  965. UI.getLargeVideo = function () {
  966. return VideoLayout.getLargeVideo();
  967. };
  968. /**
  969. * Shows dialog with a link to FF extension.
  970. */
  971. UI.showExtensionRequiredDialog = function (url) {
  972. messageHandler.openMessageDialog(
  973. "dialog.extensionRequired",
  974. "[html]dialog.firefoxExtensionPrompt",
  975. {url: url});
  976. };
  977. /**
  978. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  979. * 2 button dialog with buttons - cancel and go to web store.
  980. * @param url {string} the url of the extension.
  981. */
  982. UI.showExtensionExternalInstallationDialog = function (url) {
  983. let submitFunction = function(e,v){
  984. if (v) {
  985. e.preventDefault();
  986. eventEmitter.emit(UIEvents.OPEN_EXTENSION_STORE, url);
  987. }
  988. };
  989. let closeFunction = function () {
  990. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  991. };
  992. messageHandler.openTwoButtonDialog({
  993. titleKey: 'dialog.externalInstallationTitle',
  994. msgKey: 'dialog.externalInstallationMsg',
  995. leftButtonKey: 'dialog.goToStore',
  996. submitFunction,
  997. loadedFunction: $.noop,
  998. closeFunction
  999. });
  1000. };
  1001. /**
  1002. * Shows dialog with combined information about camera and microphone errors.
  1003. * @param {JitsiTrackError} micError
  1004. * @param {JitsiTrackError} cameraError
  1005. */
  1006. UI.showDeviceErrorDialog = function (micError, cameraError) {
  1007. let dontShowAgain = {
  1008. id: "doNotShowWarningAgain",
  1009. localStorageKey: "doNotShowErrorAgain",
  1010. textKey: "dialog.doNotShowWarningAgain"
  1011. };
  1012. let isMicJitsiTrackErrorAndHasName = micError && micError.name &&
  1013. micError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1014. let isCameraJitsiTrackErrorAndHasName = cameraError && cameraError.name &&
  1015. cameraError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1016. let showDoNotShowWarning = false;
  1017. if (micError && cameraError && isMicJitsiTrackErrorAndHasName &&
  1018. isCameraJitsiTrackErrorAndHasName) {
  1019. showDoNotShowWarning = true;
  1020. } else if (micError && isMicJitsiTrackErrorAndHasName && !cameraError) {
  1021. showDoNotShowWarning = true;
  1022. } else if (cameraError && isCameraJitsiTrackErrorAndHasName && !micError) {
  1023. showDoNotShowWarning = true;
  1024. }
  1025. if (micError) {
  1026. dontShowAgain.localStorageKey += "-mic-" + micError.name;
  1027. }
  1028. if (cameraError) {
  1029. dontShowAgain.localStorageKey += "-camera-" + cameraError.name;
  1030. }
  1031. let cameraJitsiTrackErrorMsg = cameraError
  1032. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[cameraError.name]
  1033. : undefined;
  1034. let micJitsiTrackErrorMsg = micError
  1035. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[micError.name]
  1036. : undefined;
  1037. let cameraErrorMsg = cameraError
  1038. ? cameraJitsiTrackErrorMsg ||
  1039. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  1040. : "";
  1041. let micErrorMsg = micError
  1042. ? micJitsiTrackErrorMsg ||
  1043. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  1044. : "";
  1045. let additionalCameraErrorMsg = !cameraJitsiTrackErrorMsg && cameraError &&
  1046. cameraError.message
  1047. ? `<div>${cameraError.message}</div>`
  1048. : ``;
  1049. let additionalMicErrorMsg = !micJitsiTrackErrorMsg && micError &&
  1050. micError.message
  1051. ? `<div>${micError.message}</div>`
  1052. : ``;
  1053. let message = '';
  1054. if (micError) {
  1055. message = `
  1056. ${message}
  1057. <h3 data-i18n='dialog.micErrorPresent'></h3>
  1058. <h4 data-i18n='${micErrorMsg}'></h4>
  1059. ${additionalMicErrorMsg}`;
  1060. }
  1061. if (cameraError) {
  1062. message = `
  1063. ${message}
  1064. <h3 data-i18n='dialog.cameraErrorPresent'></h3>
  1065. <h4 data-i18n='${cameraErrorMsg}'></h4>
  1066. ${additionalCameraErrorMsg}`;
  1067. }
  1068. // To make sure we don't have multiple error dialogs open at the same time,
  1069. // we will just close the previous one if we are going to show a new one.
  1070. deviceErrorDialog && deviceErrorDialog.close();
  1071. deviceErrorDialog = messageHandler.openDialog(
  1072. getTitleKey(),
  1073. message,
  1074. false,
  1075. {Ok: true},
  1076. function () {},
  1077. null,
  1078. function () {
  1079. // Reset dialog reference to null to avoid memory leaks when
  1080. // user closed the dialog manually.
  1081. deviceErrorDialog = null;
  1082. },
  1083. showDoNotShowWarning ? dontShowAgain : undefined
  1084. );
  1085. function getTitleKey() {
  1086. let title = "dialog.error";
  1087. if (micError && micError.name === TrackErrors.PERMISSION_DENIED) {
  1088. if (!cameraError
  1089. || cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1090. title = "dialog.permissionDenied";
  1091. }
  1092. } else if (cameraError
  1093. && cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1094. title = "dialog.permissionDenied";
  1095. }
  1096. return title;
  1097. }
  1098. };
  1099. /**
  1100. * Shows error dialog that informs the user that no data is received from the
  1101. * device.
  1102. */
  1103. UI.showTrackNotWorkingDialog = function (stream) {
  1104. messageHandler.openMessageDialog(
  1105. "dialog.error",
  1106. stream.isAudioTrack()? "dialog.micNotSendingData" :
  1107. "dialog.cameraNotSendingData");
  1108. };
  1109. UI.updateDevicesAvailability = function (id, devices) {
  1110. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1111. };
  1112. /**
  1113. * Show shared video.
  1114. * @param {string} id the id of the sender of the command
  1115. * @param {string} url video url
  1116. * @param {string} attributes
  1117. */
  1118. UI.onSharedVideoStart = function (id, url, attributes) {
  1119. if (sharedVideoManager)
  1120. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1121. };
  1122. /**
  1123. * Update shared video.
  1124. * @param {string} id the id of the sender of the command
  1125. * @param {string} url video url
  1126. * @param {string} attributes
  1127. */
  1128. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1129. if (sharedVideoManager)
  1130. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1131. };
  1132. /**
  1133. * Stop showing shared video.
  1134. * @param {string} id the id of the sender of the command
  1135. * @param {string} attributes
  1136. */
  1137. UI.onSharedVideoStop = function (id, attributes) {
  1138. if (sharedVideoManager)
  1139. sharedVideoManager.onSharedVideoStop(id, attributes);
  1140. };
  1141. /**
  1142. * Enables / disables camera toolbar button.
  1143. *
  1144. * @param {boolean} enabled indicates if the camera button should be enabled
  1145. * or disabled
  1146. */
  1147. UI.setCameraButtonEnabled = enabled => Toolbar.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 = enabled => Toolbar.setAudioIconEnabled(enabled);
  1155. UI.showRingOverlay = function () {
  1156. RingOverlay.show(APP.tokenData.callee, interfaceConfig.DISABLE_RINGING);
  1157. FilmStrip.toggleFilmStrip(false, false);
  1158. };
  1159. UI.hideRingOverLay = function () {
  1160. if (!RingOverlay.hide())
  1161. return;
  1162. FilmStrip.toggleFilmStrip(true, false);
  1163. };
  1164. /**
  1165. * Indicates if any the "top" overlays are currently visible. The check includes
  1166. * the call overlay, suspended overlay, GUM permissions overlay
  1167. * and a page reload overlay.
  1168. *
  1169. * @returns {*|boolean} {true} if the overlay is visible, {false} otherwise
  1170. */
  1171. UI.isOverlayVisible = function () {
  1172. return RingOverlay.isVisible() || this.overlayVisible;
  1173. };
  1174. /**
  1175. * Indicates if the ring overlay is currently visible.
  1176. *
  1177. * @returns {*|boolean} {true} if the ring overlay is visible, {false} otherwise
  1178. */
  1179. UI.isRingOverlayVisible = () => RingOverlay.isVisible();
  1180. /**
  1181. * Handles user's features changes.
  1182. */
  1183. UI.onUserFeaturesChanged = user => VideoLayout.onUserFeaturesChanged(user);
  1184. const UIListeners = new Map([
  1185. [
  1186. UIEvents.ETHERPAD_CLICKED,
  1187. () => etherpadManager && etherpadManager.toggleEtherpad()
  1188. ], [
  1189. UIEvents.SHARED_VIDEO_CLICKED,
  1190. () => sharedVideoManager && sharedVideoManager.toggleSharedVideo()
  1191. ], [
  1192. UIEvents.TOGGLE_FULLSCREEN,
  1193. UI.toggleFullScreen
  1194. ], [
  1195. UIEvents.TOGGLE_CHAT,
  1196. UI.toggleChat
  1197. ], [
  1198. UIEvents.TOGGLE_SETTINGS,
  1199. () => UI.toggleSidePanel("settings_container")
  1200. ], [
  1201. UIEvents.TOGGLE_CONTACT_LIST,
  1202. UI.toggleContactList
  1203. ], [
  1204. UIEvents.TOGGLE_PROFILE,
  1205. () => APP.tokenData.isGuest && UI.toggleSidePanel("profile_container")
  1206. ], [
  1207. UIEvents.TOGGLE_FILM_STRIP,
  1208. UI.handleToggleFilmStrip
  1209. ], [
  1210. UIEvents.FOLLOW_ME_ENABLED,
  1211. enabled => (followMeHandler && followMeHandler.enableFollowMe(enabled))
  1212. ]
  1213. ]);
  1214. module.exports = UI;