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

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