Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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