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.

Toolbar.js 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. /* global APP, $, config, interfaceConfig, JitsiMeetJS */
  2. /* jshint -W101 */
  3. import UIUtil from '../util/UIUtil';
  4. import UIEvents from '../../../service/UI/UIEvents';
  5. import SideContainerToggler from "../side_pannels/SideContainerToggler";
  6. let roomUrl = null;
  7. let emitter = null;
  8. /**
  9. * Opens the invite link dialog.
  10. */
  11. function openLinkDialog () {
  12. let inviteAttributes;
  13. if (roomUrl === null) {
  14. inviteAttributes = 'data-i18n="[value]roomUrlDefaultMsg" value="' +
  15. APP.translation.translateString("roomUrlDefaultMsg") + '"';
  16. } else {
  17. inviteAttributes = "value=\"" + encodeURI(roomUrl) + "\"";
  18. }
  19. let title = APP.translation.generateTranslationHTML("dialog.shareLink");
  20. APP.UI.messageHandler.openTwoButtonDialog(
  21. null, null, null,
  22. '<h2>' + title + '</h2>'
  23. + '<input id="inviteLinkRef" type="text" '
  24. + inviteAttributes + ' onclick="this.select();" readonly>',
  25. false, "dialog.Invite",
  26. function (e, v) {
  27. if (v && roomUrl) {
  28. JitsiMeetJS.analytics.sendEvent('toolbar.invite.button');
  29. emitter.emit(UIEvents.USER_INVITED, roomUrl);
  30. }
  31. else {
  32. JitsiMeetJS.analytics.sendEvent('toolbar.invite.cancel');
  33. }
  34. },
  35. function (event) {
  36. if (roomUrl) {
  37. document.getElementById('inviteLinkRef').select();
  38. } else {
  39. if (event && event.target) {
  40. $(event.target).find('button[value=true]')
  41. .prop('disabled', true);
  42. }
  43. }
  44. },
  45. function (e, v, m, f) {
  46. if(!v && !m && !f)
  47. JitsiMeetJS.analytics.sendEvent('toolbar.invite.close');
  48. }
  49. );
  50. }
  51. const buttonHandlers = {
  52. "toolbar_button_profile": function () {
  53. JitsiMeetJS.analytics.sendEvent('toolbar.profile.toggled');
  54. emitter.emit(UIEvents.TOGGLE_PROFILE);
  55. },
  56. "toolbar_button_mute": function () {
  57. let sharedVideoManager = APP.UI.getSharedVideoManager();
  58. if (APP.conference.audioMuted) {
  59. // If there's a shared video with the volume "on" and we aren't
  60. // the video owner, we warn the user
  61. // that currently it's not possible to unmute.
  62. if (sharedVideoManager
  63. && sharedVideoManager.isSharedVideoVolumeOn()
  64. && !sharedVideoManager.isSharedVideoOwner()) {
  65. UIUtil.animateShowElement(
  66. $("#unableToUnmutePopup"), true, 5000);
  67. }
  68. else {
  69. JitsiMeetJS.analytics.sendEvent('toolbar.audio.unmuted');
  70. emitter.emit(UIEvents.AUDIO_MUTED, false, true);
  71. }
  72. } else {
  73. JitsiMeetJS.analytics.sendEvent('toolbar.audio.muted');
  74. emitter.emit(UIEvents.AUDIO_MUTED, true, true);
  75. }
  76. },
  77. "toolbar_button_camera": function () {
  78. if (APP.conference.videoMuted) {
  79. JitsiMeetJS.analytics.sendEvent('toolbar.video.enabled');
  80. emitter.emit(UIEvents.VIDEO_MUTED, false);
  81. } else {
  82. JitsiMeetJS.analytics.sendEvent('toolbar.video.disabled');
  83. emitter.emit(UIEvents.VIDEO_MUTED, true);
  84. }
  85. },
  86. "toolbar_button_security": function () {
  87. JitsiMeetJS.analytics.sendEvent('toolbar.lock.clicked');
  88. emitter.emit(UIEvents.ROOM_LOCK_CLICKED);
  89. },
  90. "toolbar_button_link": function () {
  91. JitsiMeetJS.analytics.sendEvent('toolbar.invite.clicked');
  92. openLinkDialog();
  93. },
  94. "toolbar_button_chat": function () {
  95. JitsiMeetJS.analytics.sendEvent('toolbar.chat.toggled');
  96. emitter.emit(UIEvents.TOGGLE_CHAT);
  97. },
  98. "toolbar_contact_list": function () {
  99. JitsiMeetJS.analytics.sendEvent(
  100. 'toolbar.contacts.toggled');
  101. emitter.emit(UIEvents.TOGGLE_CONTACT_LIST);
  102. },
  103. "toolbar_button_etherpad": function () {
  104. JitsiMeetJS.analytics.sendEvent('toolbar.etherpad.clicked');
  105. emitter.emit(UIEvents.ETHERPAD_CLICKED);
  106. },
  107. "toolbar_button_sharedvideo": function () {
  108. JitsiMeetJS.analytics.sendEvent('toolbar.sharedvideo.clicked');
  109. emitter.emit(UIEvents.SHARED_VIDEO_CLICKED);
  110. },
  111. "toolbar_button_desktopsharing": function () {
  112. if (APP.conference.isSharingScreen) {
  113. JitsiMeetJS.analytics.sendEvent('toolbar.screen.disabled');
  114. } else {
  115. JitsiMeetJS.analytics.sendEvent('toolbar.screen.enabled');
  116. }
  117. emitter.emit(UIEvents.TOGGLE_SCREENSHARING);
  118. },
  119. "toolbar_button_fullScreen": function() {
  120. JitsiMeetJS.analytics.sendEvent('toolbar.fullscreen.enabled');
  121. UIUtil.buttonClick("toolbar_button_fullScreen",
  122. "icon-full-screen icon-exit-full-screen");
  123. emitter.emit(UIEvents.FULLSCREEN_TOGGLE);
  124. },
  125. "toolbar_button_sip": function () {
  126. JitsiMeetJS.analytics.sendEvent('toolbar.sip.clicked');
  127. showSipNumberInput();
  128. },
  129. "toolbar_button_dialpad": function () {
  130. JitsiMeetJS.analytics.sendEvent('toolbar.sip.dialpad.clicked');
  131. dialpadButtonClicked();
  132. },
  133. "toolbar_button_settings": function () {
  134. JitsiMeetJS.analytics.sendEvent('toolbar.settings.toggled');
  135. emitter.emit(UIEvents.TOGGLE_SETTINGS);
  136. },
  137. "toolbar_button_hangup": function () {
  138. JitsiMeetJS.analytics.sendEvent('toolbar.hangup');
  139. emitter.emit(UIEvents.HANGUP);
  140. },
  141. "toolbar_button_login": function () {
  142. JitsiMeetJS.analytics.sendEvent('toolbar.authenticate.login.clicked');
  143. emitter.emit(UIEvents.AUTH_CLICKED);
  144. },
  145. "toolbar_button_logout": function () {
  146. JitsiMeetJS.analytics.sendEvent('toolbar.authenticate.logout.clicked');
  147. // Ask for confirmation
  148. APP.UI.messageHandler.openTwoButtonDialog(
  149. "dialog.logoutTitle",
  150. null,
  151. "dialog.logoutQuestion",
  152. null,
  153. false,
  154. "dialog.Yes",
  155. function (evt, yes) {
  156. if (yes) {
  157. emitter.emit(UIEvents.LOGOUT);
  158. }
  159. }
  160. );
  161. },
  162. "toolbar_film_strip": function () {
  163. JitsiMeetJS.analytics.sendEvent(
  164. 'bottomtoolbar.filmstrip.toggled');
  165. emitter.emit(UIEvents.TOGGLE_FILM_STRIP);
  166. }
  167. };
  168. const defaultToolbarButtons = {
  169. 'microphone': {
  170. id: 'toolbar_button_mute',
  171. className: "button icon-microphone",
  172. shortcut: 'M',
  173. shortcutAttr: 'mutePopover',
  174. shortcutFunc: function() {
  175. JitsiMeetJS.analytics.sendEvent('shortcut.audiomute.toggled');
  176. APP.conference.toggleAudioMuted();
  177. },
  178. shortcutDescription: "keyboardShortcuts.mute",
  179. content: "Mute / Unmute",
  180. i18n: "[content]toolbar.mute"
  181. },
  182. 'camera': {
  183. id: 'toolbar_button_camera',
  184. className: "button icon-camera",
  185. shortcut: 'V',
  186. shortcutAttr: 'toggleVideoPopover',
  187. shortcutFunc: function() {
  188. JitsiMeetJS.analytics.sendEvent('shortcut.videomute.toggled');
  189. APP.conference.toggleVideoMuted();
  190. },
  191. shortcutDescription: "keyboardShortcuts.videoMute",
  192. content: "Start / stop camera",
  193. i18n: "[content]toolbar.videomute"
  194. },
  195. 'desktop': {
  196. id: 'toolbar_button_desktopsharing',
  197. className: "button icon-share-desktop",
  198. shortcut: 'D',
  199. shortcutAttr: 'toggleDesktopSharingPopover',
  200. shortcutFunc: function() {
  201. JitsiMeetJS.analytics.sendEvent('shortcut.screen.toggled');
  202. APP.conference.toggleScreenSharing();
  203. },
  204. shortcutDescription: "keyboardShortcuts.toggleScreensharing",
  205. content: "Share screen",
  206. i18n: "[content]toolbar.sharescreen"
  207. },
  208. 'security': {
  209. id: 'toolbar_button_security'
  210. },
  211. 'invite': {
  212. id: 'toolbar_button_link'
  213. },
  214. 'chat': {
  215. id: 'toolbar_button_chat',
  216. shortcut: 'C',
  217. shortcutAttr: 'toggleChatPopover',
  218. shortcutFunc: function() {
  219. JitsiMeetJS.analytics.sendEvent('shortcut.chat.toggled');
  220. APP.UI.toggleChat();
  221. },
  222. shortcutDescription: "keyboardShortcuts.toggleChat",
  223. sideContainerId: "chat_container"
  224. },
  225. 'contacts': {
  226. id: 'toolbar_contact_list',
  227. sideContainerId: "contacts_container"
  228. },
  229. 'profile': {
  230. id: 'toolbar_button_profile',
  231. sideContainerId: "profile_container"
  232. },
  233. 'etherpad': {
  234. id: 'toolbar_button_etherpad'
  235. },
  236. 'fullscreen': {
  237. id: 'toolbar_button_fullScreen',
  238. className: "button icon-full-screen",
  239. shortcut: 'F',
  240. shortcutAttr: 'toggleFullscreenPopover',
  241. shortcutFunc: function() {
  242. JitsiMeetJS.analytics.sendEvent('shortcut.fullscreen.toggled');
  243. APP.UI.toggleFullScreen();
  244. },
  245. shortcutDescription: "keyboardShortcuts.toggleChat",
  246. content: "Enter / Exit Full Screen",
  247. i18n: "[content]toolbar.fullscreen"
  248. },
  249. 'settings': {
  250. id: 'toolbar_button_settings',
  251. sideContainerId: "settings_container"
  252. },
  253. 'hangup': {
  254. id: 'toolbar_button_hangup',
  255. className: "button icon-hangup",
  256. content: "Hang Up",
  257. i18n: "[content]toolbar.hangup"
  258. },
  259. 'filmstrip': {
  260. id: 'toolbar_film_strip',
  261. shortcut: "F",
  262. shortcutAttr: "filmstripPopover",
  263. shortcutFunc: function() {
  264. JitsiMeetJS.analytics.sendEvent("shortcut.film.toggled");
  265. APP.UI.toggleFilmStrip();
  266. },
  267. shortcutDescription: "keyboardShortcuts.toggleFilmstrip"
  268. }
  269. };
  270. function dialpadButtonClicked() {
  271. //TODO show the dialpad box
  272. }
  273. function showSipNumberInput () {
  274. let defaultNumber = config.defaultSipNumber
  275. ? config.defaultSipNumber
  276. : '';
  277. let sipMsg = APP.translation.generateTranslationHTML("dialog.sipMsg");
  278. APP.UI.messageHandler.openTwoButtonDialog(
  279. null, null, null,
  280. `<h2>${sipMsg}</h2>
  281. <input name="sipNumber" type="text" value="${defaultNumber}" autofocus>`,
  282. false, "dialog.Dial",
  283. function (e, v, m, f) {
  284. if (v && f.sipNumber) {
  285. emitter.emit(UIEvents.SIP_DIAL, f.sipNumber);
  286. }
  287. },
  288. null, null, ':input:first'
  289. );
  290. }
  291. const Toolbar = {
  292. init (eventEmitter) {
  293. emitter = eventEmitter;
  294. // The toolbar is enabled by default.
  295. this.enabled = true;
  296. this.toolbarSelector = $("#mainToolbarContainer");
  297. this.extendedToolbarSelector = $("#extendedToolbar");
  298. this._initMainToolbarButtons();
  299. UIUtil.hideDisabledButtons(defaultToolbarButtons);
  300. Object.keys(defaultToolbarButtons).forEach(
  301. id => {
  302. if (UIUtil.isButtonEnabled(id)) {
  303. var button = defaultToolbarButtons[id];
  304. if (button.shortcut)
  305. APP.keyboardshortcut.registerShortcut(
  306. button.shortcut,
  307. button.shortcutAttr,
  308. button.shortcutFunc,
  309. button.shortcutDescription
  310. );
  311. }
  312. }
  313. );
  314. Object.keys(buttonHandlers).forEach(
  315. buttonId => $(`#${buttonId}`).click(function(event) {
  316. !$(this).prop('disabled') && buttonHandlers[buttonId](event);
  317. })
  318. );
  319. APP.UI.addListener(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
  320. function(containerId, isVisible) {
  321. Toolbar._handleSideToolbarContainerToggled( containerId,
  322. isVisible);
  323. });
  324. },
  325. /**
  326. * Enables / disables the toolbar.
  327. * @param {e} set to {true} to enable the toolbar or {false}
  328. * to disable it
  329. */
  330. enable (e) {
  331. this.enabled = e;
  332. if (!e && this.isVisible())
  333. this.hide(false);
  334. },
  335. /**
  336. * Indicates if the bottom toolbar is currently enabled.
  337. * @return {this.enabled}
  338. */
  339. isEnabled() {
  340. return this.enabled;
  341. },
  342. /**
  343. * Updates the room invite url.
  344. */
  345. updateRoomUrl (newRoomUrl) {
  346. roomUrl = newRoomUrl;
  347. // If the invite dialog has been already opened we update the
  348. // information.
  349. let inviteLink = document.getElementById('inviteLinkRef');
  350. if (inviteLink) {
  351. inviteLink.value = roomUrl;
  352. inviteLink.select();
  353. $('#inviteLinkRef').parent()
  354. .find('button[value=true]').prop('disabled', false);
  355. }
  356. },
  357. /**
  358. * Unlocks the lock button state.
  359. */
  360. unlockLockButton () {
  361. if ($("#toolbar_button_security").hasClass("icon-security-locked"))
  362. UIUtil.buttonClick("toolbar_button_security",
  363. "icon-security icon-security-locked");
  364. },
  365. /**
  366. * Updates the lock button state to locked.
  367. */
  368. lockLockButton () {
  369. if ($("#toolbar_button_security").hasClass("icon-security"))
  370. UIUtil.buttonClick("toolbar_button_security",
  371. "icon-security icon-security-locked");
  372. },
  373. /**
  374. * Shows or hides authentication button
  375. * @param show <tt>true</tt> to show or <tt>false</tt> to hide
  376. */
  377. showAuthenticateButton (show) {
  378. if (UIUtil.isButtonEnabled('authentication') && show) {
  379. $('#authentication').css({display: "inline"});
  380. } else {
  381. $('#authentication').css({display: "none"});
  382. }
  383. },
  384. showEtherpadButton () {
  385. if (!$('#toolbar_button_etherpad').is(":visible")) {
  386. $('#toolbar_button_etherpad').css({display: 'inline-block'});
  387. }
  388. },
  389. // Shows or hides the 'shared video' button.
  390. showSharedVideoButton () {
  391. if (UIUtil.isButtonEnabled('sharedvideo')
  392. && config.disableThirdPartyRequests !== true) {
  393. $('#toolbar_button_sharedvideo').css({display: "inline-block"});
  394. } else {
  395. $('#toolbar_button_sharedvideo').css({display: "none"});
  396. }
  397. },
  398. // checks whether desktop sharing is enabled and whether
  399. // we have params to start automatically sharing
  400. checkAutoEnableDesktopSharing () {
  401. if (UIUtil.isButtonEnabled('desktop')
  402. && config.autoEnableDesktopSharing) {
  403. emitter.emit(UIEvents.TOGGLE_SCREENSHARING);
  404. }
  405. },
  406. // Shows or hides SIP calls button
  407. showSipCallButton (show) {
  408. if (APP.conference.sipGatewayEnabled()
  409. && UIUtil.isButtonEnabled('sip') && show) {
  410. $('#toolbar_button_sip').css({display: "inline-block"});
  411. } else {
  412. $('#toolbar_button_sip').css({display: "none"});
  413. }
  414. },
  415. // Shows or hides the dialpad button
  416. showDialPadButton (show) {
  417. if (UIUtil.isButtonEnabled('dialpad') && show) {
  418. $('#toolbar_button_dialpad').css({display: "inline-block"});
  419. } else {
  420. $('#toolbar_button_dialpad').css({display: "none"});
  421. }
  422. },
  423. /**
  424. * Displays user authenticated identity name(login).
  425. * @param authIdentity identity name to be displayed.
  426. */
  427. setAuthenticatedIdentity (authIdentity) {
  428. if (authIdentity) {
  429. let selector = $('#toolbar_auth_identity');
  430. selector.css({display: "list-item"});
  431. selector.text(authIdentity);
  432. } else {
  433. $('#toolbar_auth_identity').css({display: "none"});
  434. }
  435. },
  436. /**
  437. * Shows/hides login button.
  438. * @param show <tt>true</tt> to show
  439. */
  440. showLoginButton (show) {
  441. if (UIUtil.isButtonEnabled('authentication') && show) {
  442. $('#toolbar_button_login').css({display: "list-item"});
  443. } else {
  444. $('#toolbar_button_login').css({display: "none"});
  445. }
  446. },
  447. /**
  448. * Shows/hides logout button.
  449. * @param show <tt>true</tt> to show
  450. */
  451. showLogoutButton (show) {
  452. if (UIUtil.isButtonEnabled('authentication') && show) {
  453. $('#toolbar_button_logout').css({display: "list-item"});
  454. } else {
  455. $('#toolbar_button_logout').css({display: "none"});
  456. }
  457. },
  458. /**
  459. * Update the state of the button. The button has blue glow if desktop
  460. * streaming is active.
  461. */
  462. updateDesktopSharingButtonState () {
  463. let button = $("#toolbar_button_desktopsharing");
  464. if (APP.conference.isSharingScreen) {
  465. button.addClass("glow");
  466. } else {
  467. button.removeClass("glow");
  468. }
  469. },
  470. /**
  471. * Marks video icon as muted or not.
  472. * @param {boolean} muted if icon should look like muted or not
  473. */
  474. markVideoIconAsMuted (muted) {
  475. $('#toolbar_button_camera').toggleClass("icon-camera-disabled", muted);
  476. },
  477. /**
  478. * Marks video icon as disabled or not.
  479. * @param {boolean} disabled if icon should look like disabled or not
  480. */
  481. markVideoIconAsDisabled (disabled) {
  482. var $btn = $('#toolbar_button_camera');
  483. $btn
  484. .prop("disabled", disabled)
  485. .attr("data-i18n", disabled
  486. ? "[content]toolbar.cameraDisabled"
  487. : "[content]toolbar.videomute")
  488. .attr("shortcut", disabled ? "" : "toggleVideoPopover");
  489. disabled
  490. ? $btn.attr("disabled", "disabled")
  491. : $btn.removeAttr("disabled");
  492. APP.translation.translateElement($btn);
  493. disabled && this.markVideoIconAsMuted(disabled);
  494. },
  495. /**
  496. * Marks audio icon as muted or not.
  497. * @param {boolean} muted if icon should look like muted or not
  498. */
  499. markAudioIconAsMuted (muted) {
  500. $('#toolbar_button_mute').toggleClass("icon-microphone",
  501. !muted).toggleClass("icon-mic-disabled", muted);
  502. },
  503. /**
  504. * Marks audio icon as disabled or not.
  505. * @param {boolean} disabled if icon should look like disabled or not
  506. */
  507. markAudioIconAsDisabled (disabled) {
  508. var $btn = $('#toolbar_button_mute');
  509. $btn
  510. .prop("disabled", disabled)
  511. .attr("data-i18n", disabled
  512. ? "[content]toolbar.micDisabled"
  513. : "[content]toolbar.mute")
  514. .attr("shortcut", disabled ? "" : "mutePopover");
  515. disabled
  516. ? $btn.attr("disabled", "disabled")
  517. : $btn.removeAttr("disabled");
  518. APP.translation.translateElement($btn);
  519. disabled && this.markAudioIconAsMuted(disabled);
  520. },
  521. /**
  522. * Indicates if the toolbar is currently hovered.
  523. * @return {boolean} true if the toolbar is currently hovered,
  524. * false otherwise
  525. */
  526. isHovered() {
  527. var hovered = false;
  528. this.toolbarSelector.find('*').each(function () {
  529. let id = $(this).attr('id');
  530. if ($(`#${id}:hover`).length > 0) {
  531. hovered = true;
  532. // break each
  533. return false;
  534. }
  535. });
  536. if (hovered)
  537. return true;
  538. if ($("#bottomToolbar:hover").length > 0
  539. || $("#extendedToolbar:hover").length > 0
  540. || SideContainerToggler.isHovered()) {
  541. return true;
  542. }
  543. return false;
  544. },
  545. /**
  546. * Returns true if this toolbar is currently visible, or false otherwise.
  547. * @return <tt>true</tt> if currently visible, <tt>false</tt> - otherwise
  548. */
  549. isVisible() {
  550. return this.toolbarSelector.hasClass("slideInY");
  551. },
  552. /**
  553. * Hides the toolbar with animation or not depending on the animate
  554. * parameter.
  555. */
  556. hide() {
  557. this.toolbarSelector.toggleClass("slideInY").toggleClass("slideOutY");
  558. let slideInAnimation = (SideContainerToggler.isVisible)
  559. ? "slideInExtX"
  560. : "slideInX";
  561. let slideOutAnimation = (SideContainerToggler.isVisible)
  562. ? "slideOutExtX"
  563. : "slideOutX";
  564. this.extendedToolbarSelector.toggleClass(slideInAnimation)
  565. .toggleClass(slideOutAnimation);
  566. },
  567. /**
  568. * Shows the toolbar with animation or not depending on the animate
  569. * parameter.
  570. */
  571. show() {
  572. if (this.toolbarSelector.hasClass("slideOutY"))
  573. this.toolbarSelector.toggleClass("slideOutY");
  574. let slideInAnimation = (SideContainerToggler.isVisible)
  575. ? "slideInExtX"
  576. : "slideInX";
  577. let slideOutAnimation = (SideContainerToggler.isVisible)
  578. ? "slideOutExtX"
  579. : "slideOutX";
  580. if (this.extendedToolbarSelector.hasClass(slideOutAnimation))
  581. this.extendedToolbarSelector.toggleClass(slideOutAnimation);
  582. this.toolbarSelector.toggleClass("slideInY");
  583. this.extendedToolbarSelector.toggleClass(slideInAnimation);
  584. },
  585. registerClickListeners(listener) {
  586. $('#mainToolbarContainer').click(listener);
  587. $("#extendedToolbar").click(listener);
  588. },
  589. /**
  590. * Handles the side toolbar toggle.
  591. */
  592. _handleSideToolbarContainerToggled(containerId, isVisible) {
  593. Object.keys(defaultToolbarButtons).forEach(
  594. id => {
  595. if (!UIUtil.isButtonEnabled(id))
  596. return;
  597. var button = defaultToolbarButtons[id];
  598. if (button.sideContainerId
  599. && button.sideContainerId === containerId) {
  600. UIUtil.buttonClick(button.id, "selected");
  601. return;
  602. }
  603. }
  604. );
  605. },
  606. /**
  607. * TODO: Fix mic popups
  608. * <a class="button icon-microphone" id="toolbar_button_mute" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="mutePopover" data-i18n="[content]toolbar.mute" content="Mute / Unmute">
  609. * <ul id="micMutedPopup" class="loginmenu">
  610. * <li data-i18n="[html]toolbar.micMutedPopup"></li>
  611. * </ul>
  612. * <ul id="unableToUnmutePopup" class="loginmenu">
  613. * <li data-i18n="[html]toolbar.unableToUnmutePopup"></li>
  614. * </ul>
  615. * </a>
  616. */
  617. _initMainToolbarButtons() {
  618. interfaceConfig.MAIN_TOOLBAR_BUTTONS.forEach((value, index) => {
  619. if (value && value in defaultToolbarButtons) {
  620. let button = defaultToolbarButtons[value];
  621. this._addMainToolbarButton(
  622. button,
  623. (index === 0),
  624. (index === interfaceConfig.MAIN_TOOLBAR_BUTTONS.length -1));
  625. }
  626. });
  627. },
  628. _addMainToolbarButton(button, isFirst, isLast) {
  629. let buttonElement = document.createElement("a");
  630. if (button.className)
  631. buttonElement.className = button.className
  632. + ((isFirst) ? " first" : "")
  633. + ((isLast) ? " last" : "");
  634. buttonElement.id = button.id;
  635. if (button.shortcutAttr)
  636. buttonElement.setAttribute("shortcut", button.shortcutAttr);
  637. if (button.content)
  638. buttonElement.setAttribute("content", button.content);
  639. if (button.i18n)
  640. buttonElement.setAttribute("data-i18n", button.i18n);
  641. buttonElement.setAttribute("data-container", "body");
  642. buttonElement.setAttribute("data-toggle", "popover");
  643. buttonElement.setAttribute("data-placement", "bottom");
  644. document.getElementById("mainToolbar")
  645. .appendChild(buttonElement);
  646. }
  647. };
  648. export default Toolbar;