Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

functions.web.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // @flow
  2. import { hasAvailableDevices } from '../base/devices';
  3. declare var interfaceConfig: Object;
  4. const WIDTH = {
  5. MEDIUM: 500,
  6. SMALL: 390,
  7. VERY_SMALL: 332,
  8. NARROW: 224
  9. };
  10. /**
  11. * Returns a set of button names to be displayed in the toolbox, based on the screen width.
  12. *
  13. * @param {number} width - The width of the screen.
  14. * @returns {Set} The button set.
  15. */
  16. export function getToolbarAdditionalButtons(width: number): Set<string> {
  17. if (width <= WIDTH.MEDIUM) {
  18. if (width <= WIDTH.SMALL) {
  19. if (width <= WIDTH.VERY_SMALL) {
  20. if (width <= WIDTH.NARROW) {
  21. return new Set();
  22. }
  23. return new Set([ 'overflow' ]);
  24. }
  25. return new Set([ 'chat', 'tileview', 'overflow' ]);
  26. }
  27. return new Set([ 'chat', 'raisehand', 'tileview', 'overflow' ]);
  28. }
  29. return new Set([ 'desktop', 'chat', 'raisehand', 'tileview', 'invite', 'overflow' ]);
  30. }
  31. /**
  32. * Helper for getting the height of the toolbox.
  33. *
  34. * @returns {number} The height of the toolbox.
  35. */
  36. export function getToolboxHeight() {
  37. const toolbox = document.getElementById('new-toolbox');
  38. return (toolbox && toolbox.clientHeight) || 0;
  39. }
  40. /**
  41. * Indicates if a toolbar button is enabled.
  42. *
  43. * @param {string} name - The name of the setting section as defined in
  44. * interface_config.js.
  45. * @returns {boolean|undefined} - True to indicate that the given toolbar button
  46. * is enabled, false - otherwise. In cases where interfaceConfig is not available
  47. * undefined is returned.
  48. */
  49. export function isButtonEnabled(name: string) {
  50. if (typeof interfaceConfig === 'object' && Array.isArray(interfaceConfig.TOOLBAR_BUTTONS)) {
  51. return interfaceConfig.TOOLBAR_BUTTONS.indexOf(name) !== -1;
  52. }
  53. return undefined;
  54. }
  55. /**
  56. * Indicates if the toolbox is visible or not.
  57. *
  58. * @param {string} state - The state from the Redux store.
  59. * @returns {boolean} - True to indicate that the toolbox is visible, false -
  60. * otherwise.
  61. */
  62. export function isToolboxVisible(state: Object) {
  63. const { iAmSipGateway } = state['features/base/config'];
  64. const {
  65. alwaysVisible,
  66. timeoutID,
  67. visible
  68. } = state['features/toolbox'];
  69. const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
  70. return Boolean(!iAmSipGateway && (timeoutID || visible || alwaysVisible
  71. || audioSettingsVisible || videoSettingsVisible));
  72. }
  73. /**
  74. * Indicates if the audio settings button is disabled or not.
  75. *
  76. * @param {string} state - The state from the Redux store.
  77. * @returns {boolean}
  78. */
  79. export function isAudioSettingsButtonDisabled(state: Object) {
  80. return (!hasAvailableDevices(state, 'audioInput')
  81. && !hasAvailableDevices(state, 'audioOutput'))
  82. || state['features/base/config'].startSilent;
  83. }
  84. /**
  85. * Indicates if the video settings button is disabled or not.
  86. *
  87. * @param {string} state - The state from the Redux store.
  88. * @returns {boolean}
  89. */
  90. export function isVideoSettingsButtonDisabled(state: Object) {
  91. return !hasAvailableDevices(state, 'videoInput');
  92. }
  93. /**
  94. * Indicates if the video mute button is disabled or not.
  95. *
  96. * @param {string} state - The state from the Redux store.
  97. * @returns {boolean}
  98. */
  99. export function isVideoMuteButtonDisabled(state: Object) {
  100. return !hasAvailableDevices(state, 'videoInput');
  101. }