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.

functions.web.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // @flow
  2. import { hasAvailableDevices } from '../base/devices';
  3. declare var interfaceConfig: Object;
  4. /**
  5. * Helper for getting the height of the toolbox.
  6. *
  7. * @returns {number} The height of the toolbox.
  8. */
  9. export function getToolboxHeight() {
  10. const toolbox = document.getElementById('new-toolbox');
  11. return (toolbox && toolbox.clientHeight) || 0;
  12. }
  13. /**
  14. * Indicates if a toolbar button is enabled.
  15. *
  16. * @param {string} name - The name of the setting section as defined in
  17. * interface_config.js.
  18. * @returns {boolean|undefined} - True to indicate that the given toolbar button
  19. * is enabled, false - otherwise. In cases where interfaceConfig is not available
  20. * undefined is returned.
  21. */
  22. export function isButtonEnabled(name: string) {
  23. if (typeof interfaceConfig === 'object' && Array.isArray(interfaceConfig.TOOLBAR_BUTTONS)) {
  24. return interfaceConfig.TOOLBAR_BUTTONS.indexOf(name) !== -1;
  25. }
  26. return undefined;
  27. }
  28. /**
  29. * Indicates if the toolbox is visible or not.
  30. *
  31. * @param {string} state - The state from the Redux store.
  32. * @returns {boolean} - True to indicate that the toolbox is visible, false -
  33. * otherwise.
  34. */
  35. export function isToolboxVisible(state: Object) {
  36. const { iAmSipGateway } = state['features/base/config'];
  37. const {
  38. alwaysVisible,
  39. timeoutID,
  40. visible
  41. } = state['features/toolbox'];
  42. const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
  43. return Boolean(!iAmSipGateway && (timeoutID || visible || alwaysVisible
  44. || audioSettingsVisible || videoSettingsVisible));
  45. }
  46. /**
  47. * Indicates if the audio settings button is disabled or not.
  48. *
  49. * @param {string} state - The state from the Redux store.
  50. * @returns {boolean}
  51. */
  52. export function isAudioSettingsButtonDisabled(state: Object) {
  53. return (!hasAvailableDevices(state, 'audioInput')
  54. && !hasAvailableDevices(state, 'audioOutput'))
  55. || state['features/base/config'].startSilent;
  56. }
  57. /**
  58. * Indicates if the video settings button is disabled or not.
  59. *
  60. * @param {string} state - The state from the Redux store.
  61. * @returns {boolean}
  62. */
  63. export function isVideoSettingsButtonDisabled(state: Object) {
  64. return !hasAvailableDevices(state, 'videoInput');
  65. }
  66. /**
  67. * Indicates if the video mute button is disabled or not.
  68. *
  69. * @param {string} state - The state from the Redux store.
  70. * @returns {boolean}
  71. */
  72. export function isVideoMuteButtonDisabled(state: Object) {
  73. return !hasAvailableDevices(state, 'videoInput');
  74. }