Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

functions.web.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // @flow
  2. import { getToolbarButtons } from '../base/config';
  3. import { hasAvailableDevices } from '../base/devices';
  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. * @param {Object} state - The redux state.
  46. * @returns {boolean|undefined} - True to indicate that the given toolbar button
  47. * is enabled, false - otherwise.
  48. */
  49. export function isButtonEnabled(name: string, state: Object) {
  50. const toolbarButtons = getToolbarButtons(state);
  51. return toolbarButtons.indexOf(name) !== -1;
  52. }
  53. /**
  54. * Indicates if the toolbox is visible or not.
  55. *
  56. * @param {string} state - The state from the Redux store.
  57. * @returns {boolean} - True to indicate that the toolbox is visible, false -
  58. * otherwise.
  59. */
  60. export function isToolboxVisible(state: Object) {
  61. const { iAmSipGateway } = state['features/base/config'];
  62. const {
  63. alwaysVisible,
  64. timeoutID,
  65. visible
  66. } = state['features/toolbox'];
  67. const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
  68. return Boolean(!iAmSipGateway && (timeoutID || visible || alwaysVisible
  69. || audioSettingsVisible || videoSettingsVisible));
  70. }
  71. /**
  72. * Indicates if the audio settings button is disabled or not.
  73. *
  74. * @param {string} state - The state from the Redux store.
  75. * @returns {boolean}
  76. */
  77. export function isAudioSettingsButtonDisabled(state: Object) {
  78. return (!hasAvailableDevices(state, 'audioInput')
  79. && !hasAvailableDevices(state, 'audioOutput'))
  80. || state['features/base/config'].startSilent;
  81. }
  82. /**
  83. * Indicates if the video settings button is disabled or not.
  84. *
  85. * @param {string} state - The state from the Redux store.
  86. * @returns {boolean}
  87. */
  88. export function isVideoSettingsButtonDisabled(state: Object) {
  89. return !hasAvailableDevices(state, 'videoInput');
  90. }
  91. /**
  92. * Indicates if the video mute button is disabled or not.
  93. *
  94. * @param {string} state - The state from the Redux store.
  95. * @returns {boolean}
  96. */
  97. export function isVideoMuteButtonDisabled(state: Object) {
  98. return !hasAvailableDevices(state, 'videoInput');
  99. }