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

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