您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.web.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // @flow
  2. import { getToolbarButtons } from '../base/config';
  3. import { hasAvailableDevices } from '../base/devices';
  4. import { TOOLBAR_TIMEOUT } from './constants';
  5. /**
  6. * Helper for getting the height of the toolbox.
  7. *
  8. * @returns {number} The height of the toolbox.
  9. */
  10. export function getToolboxHeight() {
  11. const toolbox = document.getElementById('new-toolbox');
  12. return (toolbox && toolbox.clientHeight) || 0;
  13. }
  14. /**
  15. * Indicates if a toolbar button is enabled.
  16. *
  17. * @param {string} name - The name of the setting section as defined in
  18. * interface_config.js.
  19. * @param {Object} state - The redux state.
  20. * @returns {boolean|undefined} - True to indicate that the given toolbar button
  21. * is enabled, false - otherwise.
  22. */
  23. export function isButtonEnabled(name: string, state: Object) {
  24. const toolbarButtons = getToolbarButtons(state);
  25. return toolbarButtons.indexOf(name) !== -1;
  26. }
  27. /**
  28. * Indicates if the toolbox is visible or not.
  29. *
  30. * @param {Object} state - The state from the Redux store.
  31. * @returns {boolean} - True to indicate that the toolbox is visible, false -
  32. * otherwise.
  33. */
  34. export function isToolboxVisible(state: Object) {
  35. const { iAmSipGateway, toolbarConfig } = state['features/base/config'];
  36. const { alwaysVisible } = toolbarConfig || {};
  37. const {
  38. timeoutID,
  39. visible
  40. } = state['features/toolbox'];
  41. const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
  42. return Boolean(!iAmSipGateway && (timeoutID || visible || alwaysVisible
  43. || audioSettingsVisible || videoSettingsVisible));
  44. }
  45. /**
  46. * Indicates if the audio settings button is disabled or not.
  47. *
  48. * @param {Object} state - The state from the Redux store.
  49. * @returns {boolean}
  50. */
  51. export function isAudioSettingsButtonDisabled(state: Object) {
  52. return (!hasAvailableDevices(state, 'audioInput')
  53. && !hasAvailableDevices(state, 'audioOutput'))
  54. || state['features/base/config'].startSilent;
  55. }
  56. /**
  57. * Indicates if the video settings button is disabled or not.
  58. *
  59. * @param {Object} state - The state from the Redux store.
  60. * @returns {boolean}
  61. */
  62. export function isVideoSettingsButtonDisabled(state: Object) {
  63. return !hasAvailableDevices(state, 'videoInput');
  64. }
  65. /**
  66. * Indicates if the video mute button is disabled or not.
  67. *
  68. * @param {Object} state - The state from the Redux store.
  69. * @returns {boolean}
  70. */
  71. export function isVideoMuteButtonDisabled(state: Object) {
  72. return !hasAvailableDevices(state, 'videoInput');
  73. }
  74. /**
  75. * If an overflow drawer should be displayed or not.
  76. * This is usually done for mobile devices or on narrow screens.
  77. *
  78. * @param {Object} state - The state from the Redux store.
  79. * @returns {boolean}
  80. */
  81. export function showOverflowDrawer(state: Object) {
  82. return state['features/toolbox'].overflowDrawer;
  83. }
  84. /**
  85. * Indicates whether the toolbox is enabled or not.
  86. *
  87. * @param {Object} state - The state from the Redux store.
  88. * @returns {boolean}
  89. */
  90. export function isToolboxEnabled(state: Object) {
  91. return state['features/toolbox'].enabled;
  92. }
  93. /**
  94. * Returns the toolbar timeout from config or the default value.
  95. *
  96. * @param {Object} state - The state from the Redux store.
  97. * @returns {number} - Toolbar timeout in miliseconds.
  98. */
  99. export function getToolbarTimeout(state: Object) {
  100. const { toolbarConfig: { timeout } } = state['features/base/config'];
  101. return timeout || TOOLBAR_TIMEOUT;
  102. }