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.

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