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 41KB

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