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.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // @flow
  2. import { getToolbarButtons } from '../base/config';
  3. import { hasAvailableDevices } from '../base/devices';
  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. * @param {Object} state - The redux state.
  19. * @returns {boolean|undefined} - True to indicate that the given toolbar button
  20. * is enabled, false - otherwise.
  21. */
  22. export function isButtonEnabled(name: string, state: Object) {
  23. const toolbarButtons = getToolbarButtons(state);
  24. return toolbarButtons.indexOf(name) !== -1;
  25. }
  26. /**
  27. * Indicates if the toolbox is visible or not.
  28. *
  29. * @param {string} state - The state from the Redux store.
  30. * @returns {boolean} - True to indicate that the toolbox is visible, false -
  31. * otherwise.
  32. */
  33. export function isToolboxVisible(state: Object) {
  34. const { iAmSipGateway } = state['features/base/config'];
  35. const {
  36. alwaysVisible,
  37. timeoutID,
  38. visible
  39. } = state['features/toolbox'];
  40. const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
  41. return Boolean(!iAmSipGateway && (timeoutID || visible || alwaysVisible
  42. || audioSettingsVisible || videoSettingsVisible));
  43. }
  44. /**
  45. * Indicates if the audio settings button is disabled or not.
  46. *
  47. * @param {string} state - The state from the Redux store.
  48. * @returns {boolean}
  49. */
  50. export function isAudioSettingsButtonDisabled(state: Object) {
  51. return (!hasAvailableDevices(state, 'audioInput')
  52. && !hasAvailableDevices(state, 'audioOutput'))
  53. || state['features/base/config'].startSilent;
  54. }
  55. /**
  56. * Indicates if the video settings button is disabled or not.
  57. *
  58. * @param {string} state - The state from the Redux store.
  59. * @returns {boolean}
  60. */
  61. export function isVideoSettingsButtonDisabled(state: Object) {
  62. return !hasAvailableDevices(state, 'videoInput');
  63. }
  64. /**
  65. * Indicates if the video mute button is disabled or not.
  66. *
  67. * @param {string} state - The state from the Redux store.
  68. * @returns {boolean}
  69. */
  70. export function isVideoMuteButtonDisabled(state: Object) {
  71. return !hasAvailableDevices(state, 'videoInput');
  72. }