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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  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. popups: [
  180. {
  181. id: "micMutedPopup",
  182. className: "loginmenu",
  183. dataAttr: "[html]toolbar.micMutedPopup"
  184. },
  185. {
  186. id: "unableToUnmutePopup",
  187. className: "loginmenu",
  188. dataAttr: "[html]toolbar.unableToUnmutePopup"
  189. }
  190. ],
  191. content: "Mute / Unmute",
  192. i18n: "[content]toolbar.mute"
  193. },
  194. 'camera': {
  195. id: 'toolbar_button_camera',
  196. className: "button icon-camera",
  197. shortcut: 'V',
  198. shortcutAttr: 'toggleVideoPopover',
  199. shortcutFunc: function() {
  200. JitsiMeetJS.analytics.sendEvent('shortcut.videomute.toggled');
  201. APP.conference.toggleVideoMuted();
  202. },
  203. shortcutDescription: "keyboardShortcuts.videoMute",
  204. content: "Start / stop camera",
  205. i18n: "[content]toolbar.videomute"
  206. },
  207. 'desktop': {
  208. id: 'toolbar_button_desktopsharing',
  209. className: "button icon-share-desktop",
  210. shortcut: 'D',
  211. shortcutAttr: 'toggleDesktopSharingPopover',
  212. shortcutFunc: function() {
  213. JitsiMeetJS.analytics.sendEvent('shortcut.screen.toggled');
  214. APP.conference.toggleScreenSharing();
  215. },
  216. shortcutDescription: "keyboardShortcuts.toggleScreensharing",
  217. content: "Share screen",
  218. i18n: "[content]toolbar.sharescreen"
  219. },
  220. 'security': {
  221. id: 'toolbar_button_security'
  222. },
  223. 'invite': {
  224. id: 'toolbar_button_link'
  225. },
  226. 'chat': {
  227. id: 'toolbar_button_chat',
  228. shortcut: 'C',
  229. shortcutAttr: 'toggleChatPopover',
  230. shortcutFunc: function() {
  231. JitsiMeetJS.analytics.sendEvent('shortcut.chat.toggled');
  232. APP.UI.toggleChat();
  233. },
  234. shortcutDescription: "keyboardShortcuts.toggleChat",
  235. sideContainerId: "chat_container"
  236. },
  237. 'contacts': {
  238. id: 'toolbar_contact_list',
  239. sideContainerId: "contacts_container"
  240. },
  241. 'profile': {
  242. id: 'toolbar_button_profile',
  243. sideContainerId: "profile_container"
  244. },
  245. 'etherpad': {
  246. id: 'toolbar_button_etherpad'
  247. },
  248. 'fullscreen': {
  249. id: 'toolbar_button_fullScreen',
  250. className: "button icon-full-screen",
  251. shortcut: 'F',
  252. shortcutAttr: 'toggleFullscreenPopover',
  253. shortcutFunc: function() {
  254. JitsiMeetJS.analytics.sendEvent('shortcut.fullscreen.toggled');
  255. APP.UI.toggleFullScreen();
  256. },
  257. shortcutDescription: "keyboardShortcuts.toggleChat",
  258. content: "Enter / Exit Full Screen",
  259. i18n: "[content]toolbar.fullscreen"
  260. },
  261. 'settings': {
  262. id: 'toolbar_button_settings',
  263. sideContainerId: "settings_container"
  264. },
  265. 'hangup': {
  266. id: 'toolbar_button_hangup',
  267. className: "button icon-hangup",
  268. content: "Hang Up",
  269. i18n: "[content]toolbar.hangup"
  270. },
  271. 'filmstrip': {
  272. id: 'toolbar_film_strip',
  273. shortcut: "F",
  274. shortcutAttr: "filmstripPopover",
  275. shortcutFunc: function() {
  276. JitsiMeetJS.analytics.sendEvent("shortcut.film.toggled");
  277. APP.UI.toggleFilmStrip();
  278. },
  279. shortcutDescription: "keyboardShortcuts.toggleFilmstrip"
  280. }
  281. };
  282. function dialpadButtonClicked() {
  283. //TODO show the dialpad box
  284. }
  285. function showSipNumberInput () {
  286. let defaultNumber = config.defaultSipNumber
  287. ? config.defaultSipNumber
  288. : '';
  289. let sipMsg = APP.translation.generateTranslationHTML("dialog.sipMsg");
  290. APP.UI.messageHandler.openTwoButtonDialog(
  291. null, null, null,
  292. `<h2>${sipMsg}</h2>
  293. <input name="sipNumber" type="text" value="${defaultNumber}" autofocus>`,
  294. false, "dialog.Dial",
  295. function (e, v, m, f) {
  296. if (v && f.sipNumber) {
  297. emitter.emit(UIEvents.SIP_DIAL, f.sipNumber);
  298. }
  299. },
  300. null, null, ':input:first'
  301. );
  302. }
  303. const Toolbar = {
  304. init (eventEmitter) {
  305. emitter = eventEmitter;
  306. // The toolbar is enabled by default.
  307. this.enabled = true;
  308. this.toolbarSelector = $("#mainToolbarContainer");
  309. this.extendedToolbarSelector = $("#extendedToolbar");
  310. this._initMainToolbarButtons();
  311. UIUtil.hideDisabledButtons(defaultToolbarButtons);
  312. Object.keys(defaultToolbarButtons).forEach(
  313. id => {
  314. if (UIUtil.isButtonEnabled(id)) {
  315. var button = defaultToolbarButtons[id];
  316. if (button.shortcut)
  317. APP.keyboardshortcut.registerShortcut(
  318. button.shortcut,
  319. button.shortcutAttr,
  320. button.shortcutFunc,
  321. button.shortcutDescription
  322. );
  323. }
  324. }
  325. );
  326. Object.keys(buttonHandlers).forEach(
  327. buttonId => $(`#${buttonId}`).click(function(event) {
  328. !$(this).prop('disabled') && buttonHandlers[buttonId](event);
  329. })
  330. );
  331. APP.UI.addListener(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
  332. function(containerId, isVisible) {
  333. Toolbar._handleSideToolbarContainerToggled( containerId,
  334. isVisible);
  335. });
  336. },
  337. /**
  338. * Enables / disables the toolbar.
  339. * @param {e} set to {true} to enable the toolbar or {false}
  340. * to disable it
  341. */
  342. enable (e) {
  343. this.enabled = e;
  344. if (!e && this.isVisible())
  345. this.hide(false);
  346. },
  347. /**
  348. * Indicates if the bottom toolbar is currently enabled.
  349. * @return {this.enabled}
  350. */
  351. isEnabled() {
  352. return this.enabled;
  353. },
  354. /**
  355. * Updates the room invite url.
  356. */
  357. updateRoomUrl (newRoomUrl) {
  358. roomUrl = newRoomUrl;
  359. // If the invite dialog has been already opened we update the
  360. // information.
  361. let inviteLink = document.getElementById('inviteLinkRef');
  362. if (inviteLink) {
  363. inviteLink.value = roomUrl;
  364. inviteLink.select();
  365. $('#inviteLinkRef').parent()
  366. .find('button[value=true]').prop('disabled', false);
  367. }
  368. },
  369. /**
  370. * Unlocks the lock button state.
  371. */
  372. unlockLockButton () {
  373. if ($("#toolbar_button_security").hasClass("icon-security-locked"))
  374. UIUtil.buttonClick("toolbar_button_security",
  375. "icon-security icon-security-locked");
  376. },
  377. /**
  378. * Updates the lock button state to locked.
  379. */
  380. lockLockButton () {
  381. if ($("#toolbar_button_security").hasClass("icon-security"))
  382. UIUtil.buttonClick("toolbar_button_security",
  383. "icon-security icon-security-locked");
  384. },
  385. /**
  386. * Shows or hides authentication button
  387. * @param show <tt>true</tt> to show or <tt>false</tt> to hide
  388. */
  389. showAuthenticateButton (show) {
  390. if (UIUtil.isButtonEnabled('authentication') && show) {
  391. $('#authentication').css({display: "inline"});
  392. } else {
  393. $('#authentication').css({display: "none"});
  394. }
  395. },
  396. showEtherpadButton () {
  397. if (!$('#toolbar_button_etherpad').is(":visible")) {
  398. $('#toolbar_button_etherpad').css({display: 'inline-block'});
  399. }
  400. },
  401. // Shows or hides the 'shared video' button.
  402. showSharedVideoButton () {
  403. if (UIUtil.isButtonEnabled('sharedvideo')
  404. && config.disableThirdPartyRequests !== true) {
  405. $('#toolbar_button_sharedvideo').css({display: "inline-block"});
  406. } else {
  407. $('#toolbar_button_sharedvideo').css({display: "none"});
  408. }
  409. },
  410. // checks whether desktop sharing is enabled and whether
  411. // we have params to start automatically sharing
  412. checkAutoEnableDesktopSharing () {
  413. if (UIUtil.isButtonEnabled('desktop')
  414. && config.autoEnableDesktopSharing) {
  415. emitter.emit(UIEvents.TOGGLE_SCREENSHARING);
  416. }
  417. },
  418. // Shows or hides SIP calls button
  419. showSipCallButton (show) {
  420. if (APP.conference.sipGatewayEnabled()
  421. && UIUtil.isButtonEnabled('sip') && show) {
  422. $('#toolbar_button_sip').css({display: "inline-block"});
  423. } else {
  424. $('#toolbar_button_sip').css({display: "none"});
  425. }
  426. },
  427. // Shows or hides the dialpad button
  428. showDialPadButton (show) {
  429. if (UIUtil.isButtonEnabled('dialpad') && show) {
  430. $('#toolbar_button_dialpad').css({display: "inline-block"});
  431. } else {
  432. $('#toolbar_button_dialpad').css({display: "none"});
  433. }
  434. },
  435. /**
  436. * Displays user authenticated identity name(login).
  437. * @param authIdentity identity name to be displayed.
  438. */
  439. setAuthenticatedIdentity (authIdentity) {
  440. if (authIdentity) {
  441. let selector = $('#toolbar_auth_identity');
  442. selector.css({display: "list-item"});
  443. selector.text(authIdentity);
  444. } else {
  445. $('#toolbar_auth_identity').css({display: "none"});
  446. }
  447. },
  448. /**
  449. * Shows/hides login button.
  450. * @param show <tt>true</tt> to show
  451. */
  452. showLoginButton (show) {
  453. if (UIUtil.isButtonEnabled('authentication') && show) {
  454. $('#toolbar_button_login').css({display: "list-item"});
  455. } else {
  456. $('#toolbar_button_login').css({display: "none"});
  457. }
  458. },
  459. /**
  460. * Shows/hides logout button.
  461. * @param show <tt>true</tt> to show
  462. */
  463. showLogoutButton (show) {
  464. if (UIUtil.isButtonEnabled('authentication') && show) {
  465. $('#toolbar_button_logout').css({display: "list-item"});
  466. } else {
  467. $('#toolbar_button_logout').css({display: "none"});
  468. }
  469. },
  470. /**
  471. * Update the state of the button. The button has blue glow if desktop
  472. * streaming is active.
  473. */
  474. updateDesktopSharingButtonState () {
  475. let button = $("#toolbar_button_desktopsharing");
  476. if (APP.conference.isSharingScreen) {
  477. button.addClass("glow");
  478. } else {
  479. button.removeClass("glow");
  480. }
  481. },
  482. /**
  483. * Marks video icon as muted or not.
  484. * @param {boolean} muted if icon should look like muted or not
  485. */
  486. markVideoIconAsMuted (muted) {
  487. $('#toolbar_button_camera').toggleClass("icon-camera-disabled", muted);
  488. },
  489. /**
  490. * Marks video icon as disabled or not.
  491. * @param {boolean} disabled if icon should look like disabled or not
  492. */
  493. markVideoIconAsDisabled (disabled) {
  494. var $btn = $('#toolbar_button_camera');
  495. $btn
  496. .prop("disabled", disabled)
  497. .attr("data-i18n", disabled
  498. ? "[content]toolbar.cameraDisabled"
  499. : "[content]toolbar.videomute")
  500. .attr("shortcut", disabled ? "" : "toggleVideoPopover");
  501. disabled
  502. ? $btn.attr("disabled", "disabled")
  503. : $btn.removeAttr("disabled");
  504. APP.translation.translateElement($btn);
  505. disabled && this.markVideoIconAsMuted(disabled);
  506. },
  507. /**
  508. * Marks audio icon as muted or not.
  509. * @param {boolean} muted if icon should look like muted or not
  510. */
  511. markAudioIconAsMuted (muted) {
  512. $('#toolbar_button_mute').toggleClass("icon-microphone",
  513. !muted).toggleClass("icon-mic-disabled", muted);
  514. },
  515. /**
  516. * Marks audio icon as disabled or not.
  517. * @param {boolean} disabled if icon should look like disabled or not
  518. */
  519. markAudioIconAsDisabled (disabled) {
  520. var $btn = $('#toolbar_button_mute');
  521. $btn
  522. .prop("disabled", disabled)
  523. .attr("data-i18n", disabled
  524. ? "[content]toolbar.micDisabled"
  525. : "[content]toolbar.mute")
  526. .attr("shortcut", disabled ? "" : "mutePopover");
  527. disabled
  528. ? $btn.attr("disabled", "disabled")
  529. : $btn.removeAttr("disabled");
  530. APP.translation.translateElement($btn);
  531. disabled && this.markAudioIconAsMuted(disabled);
  532. },
  533. /**
  534. * Indicates if the toolbar is currently hovered.
  535. * @return {boolean} true if the toolbar is currently hovered,
  536. * false otherwise
  537. */
  538. isHovered() {
  539. var hovered = false;
  540. this.toolbarSelector.find('*').each(function () {
  541. let id = $(this).attr('id');
  542. if ($(`#${id}:hover`).length > 0) {
  543. hovered = true;
  544. // break each
  545. return false;
  546. }
  547. });
  548. if (hovered)
  549. return true;
  550. if ($("#bottomToolbar:hover").length > 0
  551. || $("#extendedToolbar:hover").length > 0
  552. || SideContainerToggler.isHovered()) {
  553. return true;
  554. }
  555. return false;
  556. },
  557. /**
  558. * Returns true if this toolbar is currently visible, or false otherwise.
  559. * @return <tt>true</tt> if currently visible, <tt>false</tt> - otherwise
  560. */
  561. isVisible() {
  562. return this.toolbarSelector.hasClass("slideInY");
  563. },
  564. /**
  565. * Hides the toolbar with animation or not depending on the animate
  566. * parameter.
  567. */
  568. hide() {
  569. this.toolbarSelector.toggleClass("slideInY").toggleClass("slideOutY");
  570. let slideInAnimation = (SideContainerToggler.isVisible)
  571. ? "slideInExtX"
  572. : "slideInX";
  573. let slideOutAnimation = (SideContainerToggler.isVisible)
  574. ? "slideOutExtX"
  575. : "slideOutX";
  576. this.extendedToolbarSelector.toggleClass(slideInAnimation)
  577. .toggleClass(slideOutAnimation);
  578. },
  579. /**
  580. * Shows the toolbar with animation or not depending on the animate
  581. * parameter.
  582. */
  583. show() {
  584. if (this.toolbarSelector.hasClass("slideOutY"))
  585. this.toolbarSelector.toggleClass("slideOutY");
  586. let slideInAnimation = (SideContainerToggler.isVisible)
  587. ? "slideInExtX"
  588. : "slideInX";
  589. let slideOutAnimation = (SideContainerToggler.isVisible)
  590. ? "slideOutExtX"
  591. : "slideOutX";
  592. if (this.extendedToolbarSelector.hasClass(slideOutAnimation))
  593. this.extendedToolbarSelector.toggleClass(slideOutAnimation);
  594. this.toolbarSelector.toggleClass("slideInY");
  595. this.extendedToolbarSelector.toggleClass(slideInAnimation);
  596. },
  597. registerClickListeners(listener) {
  598. $('#mainToolbarContainer').click(listener);
  599. $("#extendedToolbar").click(listener);
  600. },
  601. /**
  602. * Handles the side toolbar toggle.
  603. */
  604. _handleSideToolbarContainerToggled(containerId, isVisible) {
  605. Object.keys(defaultToolbarButtons).forEach(
  606. id => {
  607. if (!UIUtil.isButtonEnabled(id))
  608. return;
  609. var button = defaultToolbarButtons[id];
  610. if (button.sideContainerId
  611. && button.sideContainerId === containerId) {
  612. UIUtil.buttonClick(button.id, "selected");
  613. return;
  614. }
  615. }
  616. );
  617. },
  618. /**
  619. * TODO: Fix mic popups
  620. * <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">
  621. * <ul id="micMutedPopup" class="loginmenu">
  622. * <li data-i18n="[html]toolbar.micMutedPopup"></li>
  623. * </ul>
  624. * <ul id="unableToUnmutePopup" class="loginmenu">
  625. * <li data-i18n="[html]toolbar.unableToUnmutePopup"></li>
  626. * </ul>
  627. * </a>
  628. */
  629. _initMainToolbarButtons() {
  630. interfaceConfig.MAIN_TOOLBAR_BUTTONS.forEach((value, index) => {
  631. if (value && value in defaultToolbarButtons) {
  632. let button = defaultToolbarButtons[value];
  633. this._addMainToolbarButton(
  634. button,
  635. (index === 0),
  636. (index === interfaceConfig.MAIN_TOOLBAR_BUTTONS.length -1));
  637. }
  638. });
  639. },
  640. _addMainToolbarButton(button, isFirst, isLast) {
  641. let buttonElement = document.createElement("a");
  642. if (button.className)
  643. buttonElement.className = button.className
  644. + ((isFirst) ? " first" : "")
  645. + ((isLast) ? " last" : "");
  646. buttonElement.id = button.id;
  647. if (button.shortcutAttr)
  648. buttonElement.setAttribute("shortcut", button.shortcutAttr);
  649. if (button.content)
  650. buttonElement.setAttribute("content", button.content);
  651. if (button.i18n)
  652. buttonElement.setAttribute("data-i18n", button.i18n);
  653. buttonElement.setAttribute("data-container", "body");
  654. buttonElement.setAttribute("data-toggle", "popover");
  655. buttonElement.setAttribute("data-placement", "bottom");
  656. this._addPopups(buttonElement, button.popups);
  657. document.getElementById("mainToolbar")
  658. .appendChild(buttonElement);
  659. },
  660. _addPopups(buttonElement, popups = []) {
  661. popups.forEach((popup) => {
  662. let popupElement = document.createElement("ul");
  663. popupElement.id = popup.id;
  664. popupElement.className = popup.className;
  665. let liElement = document.createElement("li");
  666. liElement.setAttribute("data-i18n", popup.dataAttr);
  667. popupElement.appendChild(liElement);
  668. buttonElement.appendChild(popupElement);
  669. });
  670. }
  671. };
  672. export default Toolbar;