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.

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