您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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