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.

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