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.

UI.js 40KB

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