Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

UI.js 40KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395
  1. /* global APP, JitsiMeetJS, $, config, interfaceConfig */
  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. setToolbarButton,
  31. showDialPadButton,
  32. showEtherpadButton,
  33. showSharedVideoButton,
  34. showDialOutButton,
  35. showToolbox
  36. } from '../../react/features/toolbox';
  37. import {
  38. maybeShowNotificationWithDoNotDisplay
  39. } from '../../react/features/notifications';
  40. var EventEmitter = require("events");
  41. UI.messageHandler = messageHandler;
  42. import Feedback from "./feedback/Feedback";
  43. import FollowMe from "../FollowMe";
  44. var eventEmitter = new EventEmitter();
  45. UI.eventEmitter = eventEmitter;
  46. /**
  47. * Whether an overlay is visible or not.
  48. *
  49. * FIXME: This is temporary solution. Don't use this variable!
  50. * Should be removed when all the code is move to react.
  51. *
  52. * @type {boolean}
  53. * @public
  54. */
  55. UI.overlayVisible = false;
  56. let etherpadManager;
  57. let sharedVideoManager;
  58. let followMeHandler;
  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.participantNotification(participant.getDisplayName(),
  173. 'notify.somebody', '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. // Update local video now that a conference is joined a user ID should be
  221. // set.
  222. UI.changeDisplayName('localVideoContainer', APP.settings.getDisplayName());
  223. };
  224. /***
  225. * Handler for toggling filmstrip
  226. */
  227. UI.handleToggleFilmstrip = () => UI.toggleFilmstrip();
  228. /**
  229. * Sets tooltip defaults.
  230. *
  231. * @private
  232. */
  233. function _setTooltipDefaults() {
  234. $.fn.tooltip.defaults = {
  235. opacity: 1, //defaults to 1
  236. offset: 1,
  237. delayIn: 0, //defaults to 500
  238. hoverable: true,
  239. hideOnClick: true,
  240. aria: true
  241. };
  242. }
  243. /**
  244. * Returns the shared document manager object.
  245. * @return {EtherpadManager} the shared document manager object
  246. */
  247. UI.getSharedVideoManager = function () {
  248. return sharedVideoManager;
  249. };
  250. /**
  251. * Starts the UI module and initializes all related components.
  252. *
  253. * @returns {boolean} true if the UI is ready and the conference should be
  254. * established, false - otherwise (for example in the case of welcome page)
  255. */
  256. UI.start = function () {
  257. document.title = interfaceConfig.APP_NAME;
  258. // Set the defaults for prompt dialogs.
  259. $.prompt.setDefaults({persistent: false});
  260. // Set the defaults for tooltips.
  261. _setTooltipDefaults();
  262. SideContainerToggler.init(eventEmitter);
  263. Filmstrip.init(eventEmitter);
  264. // By default start with remote videos hidden and rely on other logic to
  265. // make them visible.
  266. UI.setRemoteThumbnailsVisibility(false);
  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. if (interfaceConfig.VERTICAL_FILMSTRIP) {
  294. $("body").addClass("vertical-filmstrip");
  295. }
  296. document.title = interfaceConfig.APP_NAME;
  297. };
  298. /**
  299. * Invokes cleanup of any deferred execution within relevant UI modules.
  300. *
  301. * @returns {void}
  302. */
  303. UI.stopDaemons = () => {
  304. VideoLayout.resetLargeVideo();
  305. };
  306. /**
  307. * Setup some UI event listeners.
  308. */
  309. UI.registerListeners
  310. = () => UIListeners.forEach((value, key) => UI.addListener(key, value));
  311. /**
  312. * Unregister some UI event listeners.
  313. */
  314. UI.unregisterListeners
  315. = () => UIListeners.forEach((value, key) => UI.removeListener(key, value));
  316. /**
  317. * Setup some DOM event listeners.
  318. */
  319. UI.bindEvents = () => {
  320. function onResize() {
  321. SideContainerToggler.resize();
  322. VideoLayout.resizeVideoArea();
  323. }
  324. // Resize and reposition videos in full screen mode.
  325. $(document).on(
  326. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  327. () => {
  328. eventEmitter.emit(
  329. UIEvents.FULLSCREEN_TOGGLED,
  330. UIUtil.isFullScreen());
  331. onResize();
  332. });
  333. $(window).resize(onResize);
  334. };
  335. /**
  336. * Unbind some DOM event listeners.
  337. */
  338. UI.unbindEvents = () => {
  339. $(document).off(
  340. 'webkitfullscreenchange mozfullscreenchange fullscreenchange');
  341. $(window).off('resize');
  342. };
  343. /**
  344. * Show local stream on UI.
  345. * @param {JitsiTrack} track stream to show
  346. */
  347. UI.addLocalStream = track => {
  348. switch (track.getType()) {
  349. case 'audio':
  350. VideoLayout.changeLocalAudio(track);
  351. break;
  352. case 'video':
  353. VideoLayout.changeLocalVideo(track);
  354. break;
  355. default:
  356. logger.error("Unknown stream type: " + track.getType());
  357. break;
  358. }
  359. };
  360. /**
  361. * Show remote stream on UI.
  362. * @param {JitsiTrack} track stream to show
  363. */
  364. UI.addRemoteStream = track => VideoLayout.onRemoteStreamAdded(track);
  365. /**
  366. * Removed remote stream from UI.
  367. * @param {JitsiTrack} track stream to remove
  368. */
  369. UI.removeRemoteStream = track => VideoLayout.onRemoteStreamRemoved(track);
  370. /**
  371. * Update chat subject.
  372. * @param {string} subject new chat subject
  373. */
  374. UI.setSubject = subject => Chat.setSubject(subject);
  375. /**
  376. * Setup and show Etherpad.
  377. * @param {string} name etherpad id
  378. */
  379. UI.initEtherpad = name => {
  380. if (etherpadManager || !config.etherpad_base || !name) {
  381. return;
  382. }
  383. logger.log('Etherpad is enabled');
  384. etherpadManager
  385. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  386. APP.store.dispatch(showEtherpadButton());
  387. };
  388. /**
  389. * Returns the shared document manager object.
  390. * @return {EtherpadManager} the shared document manager object
  391. */
  392. UI.getSharedDocumentManager = () => etherpadManager;
  393. /**
  394. * Show user on UI.
  395. * @param {JitsiParticipant} user
  396. */
  397. UI.addUser = function (user) {
  398. var id = user.getId();
  399. var displayName = user.getDisplayName();
  400. if (UI.ContactList)
  401. UI.ContactList.addContact(id);
  402. messageHandler.participantNotification(
  403. displayName,'notify.somebody', 'connected', 'notify.connected'
  404. );
  405. if (!config.startAudioMuted ||
  406. config.startAudioMuted > APP.conference.membersCount)
  407. UIUtil.playSoundNotification('userJoined');
  408. // Add Peer's container
  409. VideoLayout.addParticipantContainer(user);
  410. // Configure avatar
  411. UI.setUserEmail(id);
  412. // set initial display name
  413. if(displayName)
  414. UI.changeDisplayName(id, displayName);
  415. };
  416. /**
  417. * Remove user from UI.
  418. * @param {string} id user id
  419. * @param {string} displayName user nickname
  420. */
  421. UI.removeUser = function (id, displayName) {
  422. if (UI.ContactList)
  423. UI.ContactList.removeContact(id);
  424. messageHandler.participantNotification(
  425. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  426. );
  427. if (!config.startAudioMuted
  428. || config.startAudioMuted > APP.conference.membersCount) {
  429. UIUtil.playSoundNotification('userLeft');
  430. }
  431. VideoLayout.removeParticipantContainer(id);
  432. };
  433. /**
  434. * Update videotype for specified user.
  435. * @param {string} id user id
  436. * @param {string} newVideoType new videotype
  437. */
  438. UI.onPeerVideoTypeChanged
  439. = (id, newVideoType) => VideoLayout.onVideoTypeChanged(id, newVideoType);
  440. /**
  441. * Update local user role and show notification if user is moderator.
  442. * @param {boolean} isModerator if local user is moderator or not
  443. */
  444. UI.updateLocalRole = isModerator => {
  445. VideoLayout.showModeratorIndicator();
  446. APP.store.dispatch(showDialOutButton(isModerator));
  447. APP.store.dispatch(showSharedVideoButton());
  448. Recording.showRecordingButton(isModerator);
  449. SettingsMenu.showStartMutedOptions(isModerator);
  450. SettingsMenu.showFollowMeOptions(isModerator);
  451. if (isModerator) {
  452. if (!interfaceConfig.DISABLE_FOCUS_INDICATOR)
  453. messageHandler.participantNotification(
  454. null, "notify.me", 'connected', "notify.moderator");
  455. Recording.checkAutoRecord();
  456. }
  457. };
  458. /**
  459. * Check the role for the user and reflect it in the UI, moderator ui indication
  460. * and notifies user who is the moderator
  461. * @param user to check for moderator
  462. */
  463. UI.updateUserRole = user => {
  464. VideoLayout.showModeratorIndicator();
  465. // We don't need to show moderator notifications when the focus (moderator)
  466. // indicator is disabled.
  467. if (!user.isModerator() || interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  468. return;
  469. }
  470. var displayName = user.getDisplayName();
  471. if (displayName) {
  472. messageHandler.participantNotification(
  473. displayName, 'notify.somebody',
  474. 'connected', 'notify.grantedTo', {
  475. to: UIUtil.escapeHtml(displayName)
  476. }
  477. );
  478. } else {
  479. messageHandler.participantNotification(
  480. '', 'notify.somebody',
  481. 'connected', 'notify.grantedToUnknown');
  482. }
  483. };
  484. /**
  485. * Updates the user status.
  486. *
  487. * @param {JitsiParticipant} user - The user which status we need to update.
  488. * @param {string} status - The new status.
  489. */
  490. UI.updateUserStatus = (user, status) => {
  491. let displayName = user.getDisplayName();
  492. messageHandler.participantNotification(
  493. displayName, '', 'connected', "dialOut.statusMessage",
  494. {
  495. status: UIUtil.escapeHtml(status)
  496. });
  497. };
  498. /**
  499. * Toggles smileys in the chat.
  500. */
  501. UI.toggleSmileys = () => Chat.toggleSmileys();
  502. /**
  503. * Toggles filmstrip.
  504. */
  505. UI.toggleFilmstrip = function () {
  506. var self = Filmstrip;
  507. self.toggleFilmstrip.apply(self, arguments);
  508. VideoLayout.resizeVideoArea(true, false);
  509. };
  510. /**
  511. * Indicates if the filmstrip is currently visible or not.
  512. * @returns {true} if the filmstrip is currently visible, otherwise
  513. */
  514. UI.isFilmstripVisible = () => Filmstrip.isFilmstripVisible();
  515. /**
  516. * Toggles chat panel.
  517. */
  518. UI.toggleChat = () => UI.toggleSidePanel("chat_container");
  519. /**
  520. * Toggles contact list panel.
  521. */
  522. UI.toggleContactList = () => UI.toggleSidePanel("contacts_container");
  523. /**
  524. * Toggles the given side panel.
  525. *
  526. * @param {String} sidePanelId the identifier of the side panel to toggle
  527. */
  528. UI.toggleSidePanel = sidePanelId => SideContainerToggler.toggle(sidePanelId);
  529. /**
  530. * Handle new user display name.
  531. */
  532. UI.inputDisplayNameHandler = function (newDisplayName) {
  533. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  534. };
  535. /**
  536. * Show custom popup/tooltip for a specified button.
  537. * @param popupSelectorID the selector id of the popup to show
  538. * @param show true or false/show or hide the popup
  539. * @param timeout the time to show the popup
  540. */
  541. UI.showCustomToolbarPopup = function (popupSelectorID, show, timeout) {
  542. eventEmitter.emit(UIEvents.SHOW_CUSTOM_TOOLBAR_BUTTON_POPUP,
  543. popupSelectorID, show, timeout);
  544. };
  545. /**
  546. * Return the type of the remote video.
  547. * @param jid the jid for the remote video
  548. * @returns the video type video or screen.
  549. */
  550. UI.getRemoteVideoType = function (jid) {
  551. return VideoLayout.getRemoteVideoType(jid);
  552. };
  553. // FIXME check if someone user this
  554. UI.showLoginPopup = function(callback) {
  555. logger.log('password is required');
  556. let message = (
  557. `<input name="username" type="text"
  558. placeholder="user@domain.net"
  559. class="input-control" autofocus>
  560. <input name="password" type="password"
  561. data-i18n="[placeholder]dialog.userPassword"
  562. class="input-control"
  563. placeholder="user password">`
  564. );
  565. let submitFunction = (e, v, m, f) => {
  566. if (v) {
  567. if (f.username && f.password) {
  568. callback(f.username, f.password);
  569. }
  570. }
  571. };
  572. messageHandler.openTwoButtonDialog({
  573. titleKey : "dialog.passwordRequired",
  574. msgString: message,
  575. leftButtonKey: 'dialog.Ok',
  576. submitFunction,
  577. focus: ':input:first'
  578. });
  579. };
  580. UI.askForNickname = function () {
  581. return window.prompt('Your nickname (optional)');
  582. };
  583. /**
  584. * Sets muted audio state for participant
  585. */
  586. UI.setAudioMuted = function (id, muted) {
  587. VideoLayout.onAudioMute(id, muted);
  588. if (APP.conference.isLocalId(id)) {
  589. APP.store.dispatch(setAudioMuted(muted));
  590. APP.conference.updateAudioIconEnabled();
  591. }
  592. };
  593. /**
  594. * Sets muted video state for participant
  595. */
  596. UI.setVideoMuted = function (id, muted) {
  597. VideoLayout.onVideoMute(id, muted);
  598. if (APP.conference.isLocalId(id)) {
  599. APP.store.dispatch(setVideoMuted(muted));
  600. APP.conference.updateVideoIconEnabled();
  601. }
  602. };
  603. /**
  604. * Triggers an update of remote video and large video displays so they may pick
  605. * up any state changes that have occurred elsewhere.
  606. *
  607. * @returns {void}
  608. */
  609. UI.updateAllVideos = () => VideoLayout.updateAllVideos();
  610. /**
  611. * Adds a listener that would be notified on the given type of event.
  612. *
  613. * @param type the type of the event we're listening for
  614. * @param listener a function that would be called when notified
  615. */
  616. UI.addListener = function (type, listener) {
  617. eventEmitter.on(type, listener);
  618. };
  619. /**
  620. * Removes the given listener for the given type of event.
  621. *
  622. * @param type the type of the event we're listening for
  623. * @param listener the listener we want to remove
  624. */
  625. UI.removeListener = function (type, listener) {
  626. eventEmitter.removeListener(type, listener);
  627. };
  628. /**
  629. * Emits the event of given type by specifying the parameters in options.
  630. *
  631. * @param type the type of the event we're emitting
  632. * @param options the parameters for the event
  633. */
  634. UI.emitEvent = (type, ...options) => eventEmitter.emit(type, ...options);
  635. UI.clickOnVideo = function (videoNumber) {
  636. let videos = $("#remoteVideos .videocontainer:not(#mixedstream)");
  637. let videosLength = videos.length;
  638. if(videosLength <= videoNumber) {
  639. return;
  640. }
  641. let videoIndex = videoNumber === 0 ? 0 : videosLength - videoNumber;
  642. videos[videoIndex].click();
  643. };
  644. // Used by torture.
  645. UI.showToolbar = timeout => APP.store.dispatch(showToolbox(timeout));
  646. // Used by torture.
  647. UI.dockToolbar = dock => APP.store.dispatch(dockToolbox(dock));
  648. /**
  649. * Updates the avatar for participant.
  650. * @param {string} id user id
  651. * @param {string} avatarUrl the URL for the avatar
  652. */
  653. function changeAvatar(id, avatarUrl) {
  654. VideoLayout.changeUserAvatar(id, avatarUrl);
  655. if (UI.ContactList)
  656. UI.ContactList.changeUserAvatar(id, avatarUrl);
  657. if (APP.conference.isLocalId(id)) {
  658. Profile.changeAvatar(avatarUrl);
  659. }
  660. }
  661. /**
  662. * Update user email.
  663. * @param {string} id user id
  664. * @param {string} email user email
  665. */
  666. UI.setUserEmail = function (id, email) {
  667. // update avatar
  668. Avatar.setUserEmail(id, email);
  669. changeAvatar(id, Avatar.getAvatarUrl(id));
  670. if (APP.conference.isLocalId(id)) {
  671. Profile.changeEmail(email);
  672. }
  673. };
  674. /**
  675. * Update user avtar id.
  676. * @param {string} id user id
  677. * @param {string} avatarId user's avatar id
  678. */
  679. UI.setUserAvatarID = function (id, avatarId) {
  680. // update avatar
  681. Avatar.setUserAvatarID(id, avatarId);
  682. changeAvatar(id, Avatar.getAvatarUrl(id));
  683. };
  684. /**
  685. * Update user avatar URL.
  686. * @param {string} id user id
  687. * @param {string} url user avatar url
  688. */
  689. UI.setUserAvatarUrl = function (id, url) {
  690. // update avatar
  691. Avatar.setUserAvatarUrl(id, url);
  692. changeAvatar(id, Avatar.getAvatarUrl(id));
  693. };
  694. /**
  695. * Notify user that connection failed.
  696. * @param {string} stropheErrorMsg raw Strophe error message
  697. */
  698. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  699. var message;
  700. if (stropheErrorMsg) {
  701. message = APP.translation.generateTranslationHTML(
  702. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  703. } else {
  704. message = APP.translation.generateTranslationHTML(
  705. "dialog.connectError");
  706. }
  707. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  708. };
  709. /**
  710. * Notify user that maximum users limit has been reached.
  711. */
  712. UI.notifyMaxUsersLimitReached = function () {
  713. var message = APP.translation.generateTranslationHTML(
  714. "dialog.maxUsersLimitReached");
  715. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  716. };
  717. /**
  718. * Notify user that he was automatically muted when joned the conference.
  719. */
  720. UI.notifyInitiallyMuted = function () {
  721. messageHandler.participantNotification(
  722. null,
  723. "notify.mutedTitle",
  724. "connected",
  725. "notify.muted",
  726. null,
  727. 120000);
  728. };
  729. /**
  730. * Mark user as dominant speaker.
  731. * @param {string} id user id
  732. */
  733. UI.markDominantSpeaker = function (id) {
  734. VideoLayout.onDominantSpeakerChanged(id);
  735. };
  736. UI.handleLastNEndpoints = function (leavingIds, enteringIds) {
  737. VideoLayout.onLastNEndpointsChanged(leavingIds, enteringIds);
  738. };
  739. /**
  740. * Will handle notification about participant's connectivity status change.
  741. *
  742. * @param {string} id the id of remote participant(MUC jid)
  743. */
  744. UI.participantConnectionStatusChanged = function (id) {
  745. VideoLayout.onParticipantConnectionStatusChanged(id);
  746. };
  747. /**
  748. * Prompt user for nickname.
  749. */
  750. UI.promptDisplayName = () => {
  751. const labelKey = 'dialog.enterDisplayName';
  752. const message = (
  753. `<div class="form-control">
  754. <label data-i18n="${labelKey}" class="form-control__label"></label>
  755. <input name="displayName" type="text"
  756. data-i18n="[placeholder]defaultNickname"
  757. class="input-control" autofocus>
  758. </div>`
  759. );
  760. // Don't use a translation string, because we're too early in the call and
  761. // the translation may not be initialised.
  762. const buttons = { Ok: true };
  763. const dialog = messageHandler.openDialog(
  764. 'dialog.displayNameRequired',
  765. message,
  766. true,
  767. buttons,
  768. (e, v, m, f) => {
  769. e.preventDefault();
  770. if (v) {
  771. const displayName = f.displayName;
  772. if (displayName) {
  773. UI.inputDisplayNameHandler(displayName);
  774. dialog.close();
  775. return;
  776. }
  777. }
  778. },
  779. () => {
  780. const form = $.prompt.getPrompt();
  781. const input = form.find("input[name='displayName']");
  782. const button = form.find("button");
  783. input.focus();
  784. button.attr("disabled", "disabled");
  785. input.keyup(() => {
  786. if (input.val()) {
  787. button.removeAttr("disabled");
  788. } else {
  789. button.attr("disabled", "disabled");
  790. }
  791. });
  792. }
  793. );
  794. };
  795. /**
  796. * Update audio level visualization for specified user.
  797. * @param {string} id user id
  798. * @param {number} lvl audio level
  799. */
  800. UI.setAudioLevel = (id, lvl) => VideoLayout.setAudioLevel(id, lvl);
  801. /**
  802. * Update state of desktop sharing buttons.
  803. *
  804. * @returns {void}
  805. */
  806. UI.updateDesktopSharingButtons
  807. = () =>
  808. APP.store.dispatch(setToolbarButton('desktop', {
  809. toggled: APP.conference.isSharingScreen
  810. }));
  811. /**
  812. * Hide connection quality statistics from UI.
  813. */
  814. UI.hideStats = function () {
  815. VideoLayout.hideStats();
  816. };
  817. /**
  818. * Mark video as interrupted or not.
  819. * @param {boolean} interrupted if video is interrupted
  820. */
  821. UI.markVideoInterrupted = function (interrupted) {
  822. if (interrupted) {
  823. VideoLayout.onVideoInterrupted();
  824. } else {
  825. VideoLayout.onVideoRestored();
  826. }
  827. };
  828. /**
  829. * Add chat message.
  830. * @param {string} from user id
  831. * @param {string} displayName user nickname
  832. * @param {string} message message text
  833. * @param {number} stamp timestamp when message was created
  834. */
  835. UI.addMessage = function (from, displayName, message, stamp) {
  836. Chat.updateChatConversation(from, displayName, message, stamp);
  837. };
  838. UI.updateDTMFSupport
  839. = isDTMFSupported => APP.store.dispatch(showDialPadButton(isDTMFSupported));
  840. /**
  841. * Show user feedback dialog if its required and enabled after pressing the
  842. * hangup button.
  843. * @returns {Promise} Resolved with value - false if the dialog is enabled and
  844. * resolved with true if the dialog is disabled or the feedback was already
  845. * submitted. Rejected if another dialog is already displayed. This values are
  846. * used to display or not display the thank you dialog from
  847. * conference.maybeRedirectToWelcomePage method.
  848. */
  849. UI.requestFeedbackOnHangup = function () {
  850. if (Feedback.isVisible())
  851. return Promise.reject(FEEDBACK_REQUEST_IN_PROGRESS);
  852. // Feedback has been submitted already.
  853. else if (Feedback.isEnabled() && Feedback.isSubmitted()) {
  854. return Promise.resolve({
  855. thankYouDialogVisible : true,
  856. feedbackSubmitted: true
  857. });
  858. }
  859. else
  860. return new Promise(function (resolve) {
  861. if (Feedback.isEnabled()) {
  862. Feedback.openFeedbackWindow(
  863. (options) => {
  864. options.thankYouDialogVisible = false;
  865. resolve(options);
  866. });
  867. } else {
  868. // If the feedback functionality isn't enabled we show a thank
  869. // you dialog. Signaling it (true), so the caller
  870. // of requestFeedback can act on it
  871. resolve(
  872. {thankYouDialogVisible : true, feedbackSubmitted: false});
  873. }
  874. });
  875. };
  876. UI.updateRecordingState = function (state) {
  877. Recording.updateRecordingState(state);
  878. };
  879. UI.notifyTokenAuthFailed = function () {
  880. messageHandler.showError( "dialog.tokenAuthFailedTitle",
  881. "dialog.tokenAuthFailed");
  882. };
  883. UI.notifyInternalError = function () {
  884. messageHandler.showError( "dialog.internalErrorTitle",
  885. "dialog.internalError");
  886. };
  887. UI.notifyFocusDisconnected = function (focus, retrySec) {
  888. messageHandler.participantNotification(
  889. null, "notify.focus",
  890. 'disconnected', "notify.focusFail",
  891. {component: focus, ms: retrySec}
  892. );
  893. };
  894. /**
  895. * Updates auth info on the UI.
  896. * @param {boolean} isAuthEnabled if authentication is enabled
  897. * @param {string} [login] current login
  898. */
  899. UI.updateAuthInfo = function (isAuthEnabled, login) {
  900. let showAuth = isAuthEnabled && UIUtil.isAuthenticationEnabled();
  901. let loggedIn = !!login;
  902. Profile.showAuthenticationButtons(showAuth);
  903. if (showAuth) {
  904. Profile.setAuthenticatedIdentity(login);
  905. Profile.showLoginButton(!loggedIn);
  906. Profile.showLogoutButton(loggedIn);
  907. }
  908. };
  909. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  910. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  911. };
  912. /**
  913. * Notifies interested listeners that the raise hand property has changed.
  914. *
  915. * @param {boolean} isRaisedHand indicates the current state of the
  916. * "raised hand"
  917. */
  918. UI.onLocalRaiseHandChanged = function (isRaisedHand) {
  919. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  920. };
  921. /**
  922. * Update list of available physical devices.
  923. * @param {object[]} devices new list of available devices
  924. */
  925. UI.onAvailableDevicesChanged = function (devices) {
  926. APP.store.dispatch(updateDeviceList(devices));
  927. APP.conference.updateAudioIconEnabled();
  928. APP.conference.updateVideoIconEnabled();
  929. };
  930. /**
  931. * Returns the id of the current video shown on large.
  932. * Currently used by tests (torture).
  933. */
  934. UI.getLargeVideoID = function () {
  935. return VideoLayout.getLargeVideoID();
  936. };
  937. /**
  938. * Returns the current video shown on large.
  939. * Currently used by tests (torture).
  940. */
  941. UI.getLargeVideo = function () {
  942. return VideoLayout.getLargeVideo();
  943. };
  944. /**
  945. * Returns whether or not the passed in user id is currently pinned to the large
  946. * video.
  947. *
  948. * @param {string} userId - The id of the user to check is pinned or not.
  949. * @returns {boolean} True if the user is currently pinned to the large video.
  950. */
  951. UI.isPinned = userId => VideoLayout.getPinnedId() === userId;
  952. /**
  953. * Shows dialog with a link to FF extension.
  954. */
  955. UI.showExtensionRequiredDialog = function (url) {
  956. messageHandler.openMessageDialog(
  957. "dialog.extensionRequired",
  958. "[html]dialog.firefoxExtensionPrompt",
  959. {url: url});
  960. };
  961. /**
  962. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  963. * 2 button dialog with buttons - cancel and go to web store.
  964. * @param url {string} the url of the extension.
  965. */
  966. UI.showExtensionExternalInstallationDialog = function (url) {
  967. let openedWindow = null;
  968. let submitFunction = function(e,v){
  969. if (v) {
  970. e.preventDefault();
  971. if (openedWindow === null || openedWindow.closed) {
  972. openedWindow
  973. = window.open(
  974. url,
  975. "extension_store_window",
  976. "resizable,scrollbars=yes,status=1");
  977. } else {
  978. openedWindow.focus();
  979. }
  980. }
  981. };
  982. let closeFunction = function (e, v) {
  983. if (openedWindow) {
  984. // Ideally we would close the popup, but this does not seem to work
  985. // on Chrome. Leaving it uncommented in case it could work
  986. // in some version.
  987. openedWindow.close();
  988. openedWindow = null;
  989. }
  990. if (!v) {
  991. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  992. }
  993. };
  994. messageHandler.openTwoButtonDialog({
  995. titleKey: 'dialog.externalInstallationTitle',
  996. msgKey: 'dialog.externalInstallationMsg',
  997. leftButtonKey: 'dialog.goToStore',
  998. submitFunction,
  999. loadedFunction: $.noop,
  1000. closeFunction
  1001. });
  1002. };
  1003. /**
  1004. * Shows a dialog which asks user to install the extension. This one is
  1005. * displayed after installation is triggered from the script, but fails because
  1006. * it must be initiated by user gesture.
  1007. * @param callback {function} function to be executed after user clicks
  1008. * the install button - it should make another attempt to install the extension.
  1009. */
  1010. UI.showExtensionInlineInstallationDialog = function (callback) {
  1011. let submitFunction = function(e,v){
  1012. if (v) {
  1013. callback();
  1014. }
  1015. };
  1016. let closeFunction = function (e, v) {
  1017. if (!v) {
  1018. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  1019. }
  1020. };
  1021. messageHandler.openTwoButtonDialog({
  1022. titleKey: 'dialog.externalInstallationTitle',
  1023. msgKey: 'dialog.inlineInstallationMsg',
  1024. leftButtonKey: 'dialog.inlineInstallExtension',
  1025. submitFunction,
  1026. loadedFunction: $.noop,
  1027. closeFunction
  1028. });
  1029. };
  1030. /**
  1031. * Shows a notifications about the passed in microphone error.
  1032. *
  1033. * @param {JitsiTrackError} micError - An error object related to using or
  1034. * acquiring an audio stream.
  1035. * @returns {void}
  1036. */
  1037. UI.showMicErrorNotification = function (micError) {
  1038. if (!micError) {
  1039. return;
  1040. }
  1041. const { message, name } = micError;
  1042. const persistenceKey = `doNotShowErrorAgain-mic-${name}`;
  1043. const micJitsiTrackErrorMsg
  1044. = JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[name];
  1045. const micErrorMsg = micJitsiTrackErrorMsg
  1046. || JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL];
  1047. const additionalMicErrorMsg = micJitsiTrackErrorMsg ? null : message;
  1048. APP.store.dispatch(maybeShowNotificationWithDoNotDisplay(
  1049. persistenceKey,
  1050. {
  1051. additionalMessage: additionalMicErrorMsg,
  1052. messageKey: micErrorMsg,
  1053. showToggle: Boolean(micJitsiTrackErrorMsg),
  1054. subtitleKey: 'dialog.micErrorPresent',
  1055. titleKey: name === TrackErrors.PERMISSION_DENIED
  1056. ? 'deviceError.microphonePermission' : 'dialog.error',
  1057. toggleLabelKey: 'dialog.doNotShowWarningAgain'
  1058. }));
  1059. };
  1060. /**
  1061. * Shows a notifications about the passed in camera error.
  1062. *
  1063. * @param {JitsiTrackError} cameraError - An error object related to using or
  1064. * acquiring a video stream.
  1065. * @returns {void}
  1066. */
  1067. UI.showCameraErrorNotification = function (cameraError) {
  1068. if (!cameraError) {
  1069. return;
  1070. }
  1071. const { message, name } = cameraError;
  1072. const persistenceKey = `doNotShowErrorAgain-camera-${name}`;
  1073. const cameraJitsiTrackErrorMsg =
  1074. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[name];
  1075. const cameraErrorMsg = cameraJitsiTrackErrorMsg
  1076. || JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL];
  1077. const additionalCameraErrorMsg = cameraJitsiTrackErrorMsg ? null : message;
  1078. APP.store.dispatch(maybeShowNotificationWithDoNotDisplay(
  1079. persistenceKey,
  1080. {
  1081. additionalMessage: additionalCameraErrorMsg,
  1082. messageKey: cameraErrorMsg,
  1083. showToggle: Boolean(cameraJitsiTrackErrorMsg),
  1084. subtitleKey: 'dialog.cameraErrorPresent',
  1085. titleKey: name === TrackErrors.PERMISSION_DENIED
  1086. ? 'deviceError.cameraPermission' : 'dialog.error',
  1087. toggleLabelKey: 'dialog.doNotShowWarningAgain'
  1088. }));
  1089. };
  1090. /**
  1091. * Shows error dialog that informs the user that no data is received from the
  1092. * device.
  1093. */
  1094. UI.showTrackNotWorkingDialog = function (stream) {
  1095. messageHandler.openMessageDialog(
  1096. "dialog.error",
  1097. stream.isAudioTrack()? "dialog.micNotSendingData" :
  1098. "dialog.cameraNotSendingData");
  1099. };
  1100. UI.updateDevicesAvailability = function (id, devices) {
  1101. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1102. };
  1103. /**
  1104. * Show shared video.
  1105. * @param {string} id the id of the sender of the command
  1106. * @param {string} url video url
  1107. * @param {string} attributes
  1108. */
  1109. UI.onSharedVideoStart = function (id, url, attributes) {
  1110. if (sharedVideoManager)
  1111. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1112. };
  1113. /**
  1114. * Update shared video.
  1115. * @param {string} id the id of the sender of the command
  1116. * @param {string} url video url
  1117. * @param {string} attributes
  1118. */
  1119. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1120. if (sharedVideoManager)
  1121. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1122. };
  1123. /**
  1124. * Stop showing shared video.
  1125. * @param {string} id the id of the sender of the command
  1126. * @param {string} attributes
  1127. */
  1128. UI.onSharedVideoStop = function (id, attributes) {
  1129. if (sharedVideoManager)
  1130. sharedVideoManager.onSharedVideoStop(id, attributes);
  1131. };
  1132. /**
  1133. * Indicates if any the "top" overlays are currently visible. The check includes
  1134. * the call/ring overlay, the suspended overlay, the GUM permissions overlay,
  1135. * and the page-reload overlay.
  1136. *
  1137. * @returns {*|boolean} {true} if an overlay is visible; {false}, otherwise
  1138. */
  1139. UI.isOverlayVisible = function () {
  1140. return (
  1141. this.overlayVisible
  1142. || APP.store.getState()['features/jwt'].callOverlayVisible);
  1143. };
  1144. /**
  1145. * Handles user's features changes.
  1146. */
  1147. UI.onUserFeaturesChanged = user => VideoLayout.onUserFeaturesChanged(user);
  1148. /**
  1149. * Returns the number of known remote videos.
  1150. *
  1151. * @returns {number} The number of remote videos.
  1152. */
  1153. UI.getRemoteVideosCount = () => VideoLayout.getRemoteVideosCount();
  1154. /**
  1155. * Makes remote thumbnail videos visible or not visible.
  1156. *
  1157. * @param {boolean} shouldHide - True if remote thumbnails should be hidden,
  1158. * false f they should be visible.
  1159. * @returns {void}
  1160. */
  1161. UI.setRemoteThumbnailsVisibility
  1162. = shouldHide => Filmstrip.setRemoteVideoVisibility(shouldHide);
  1163. const UIListeners = new Map([
  1164. [
  1165. UIEvents.ETHERPAD_CLICKED,
  1166. () => etherpadManager && etherpadManager.toggleEtherpad()
  1167. ], [
  1168. UIEvents.SHARED_VIDEO_CLICKED,
  1169. () => sharedVideoManager && sharedVideoManager.toggleSharedVideo()
  1170. ], [
  1171. UIEvents.TOGGLE_FULLSCREEN,
  1172. UI.toggleFullScreen
  1173. ], [
  1174. UIEvents.TOGGLE_CHAT,
  1175. UI.toggleChat
  1176. ], [
  1177. UIEvents.TOGGLE_SETTINGS,
  1178. () => {
  1179. // Opening of device selection is special-cased as it is a dialog
  1180. // opened through a button in settings and not directly displayed in
  1181. // settings itself. As it is not useful to only have a settings menu
  1182. // with a button to open a dialog, open the dialog directly instead.
  1183. if (interfaceConfig.SETTINGS_SECTIONS.length === 1
  1184. && UIUtil.isSettingEnabled('devices')) {
  1185. APP.store.dispatch(openDeviceSelectionDialog());
  1186. } else {
  1187. UI.toggleSidePanel("settings_container");
  1188. }
  1189. }
  1190. ], [
  1191. UIEvents.TOGGLE_CONTACT_LIST,
  1192. UI.toggleContactList
  1193. ], [
  1194. UIEvents.TOGGLE_PROFILE,
  1195. () => {
  1196. const {
  1197. isGuest
  1198. } = APP.store.getState()['features/jwt'];
  1199. isGuest && UI.toggleSidePanel('profile_container');
  1200. }
  1201. ], [
  1202. UIEvents.TOGGLE_FILMSTRIP,
  1203. UI.handleToggleFilmstrip
  1204. ], [
  1205. UIEvents.FOLLOW_ME_ENABLED,
  1206. enabled => (followMeHandler && followMeHandler.enableFollowMe(enabled))
  1207. ]
  1208. ]);
  1209. // TODO: Export every function separately. For now there is no point of doing
  1210. // this because we are importing everything.
  1211. export default UI;