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 41KB

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