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

functions.web.js 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // @flow
  2. import { getToolbarButtons } from '../base/config';
  3. import { hasAvailableDevices } from '../base/devices';
  4. const WIDTH = {
  5. FIT_9_ICONS: 520,
  6. FIT_8_ICONS: 470,
  7. FIT_7_ICONS: 420,
  8. FIT_6_ICONS: 370,
  9. FIT_5_ICONS: 320,
  10. FIT_4_ICONS: 280
  11. };
  12. /**
  13. * Returns a set of button names to be displayed in the toolbox, based on the screen width and platform.
  14. *
  15. * @param {number} width - The width of the screen.
  16. * @param {number} isMobile - The device is a mobile one.
  17. * @returns {Set} The button set.
  18. */
  19. export function getToolbarAdditionalButtons(width: number, isMobile: boolean): Set<string> {
  20. let buttons = [];
  21. switch (true) {
  22. case width >= WIDTH.FIT_9_ICONS: {
  23. buttons = isMobile
  24. ? [ 'chat', 'raisehand', 'tileview', 'participants-pane', 'overflow' ]
  25. : [ 'desktop', 'chat', 'raisehand', 'tileview', 'participants-pane', 'overflow' ];
  26. break;
  27. }
  28. case width >= WIDTH.FIT_8_ICONS: {
  29. buttons = [ 'desktop', 'chat', 'raisehand', 'participants-pane', 'overflow' ];
  30. break;
  31. }
  32. case width >= WIDTH.FIT_7_ICONS: {
  33. buttons = [ 'desktop', 'chat', 'participants-pane', 'overflow' ];
  34. break;
  35. }
  36. case width >= WIDTH.FIT_6_ICONS: {
  37. buttons = [ 'chat', 'participants-pane', 'overflow' ];
  38. break;
  39. }
  40. case width >= WIDTH.FIT_5_ICONS: {
  41. buttons = [ 'chat', 'overflow' ];
  42. break;
  43. }
  44. case width >= WIDTH.FIT_4_ICONS: {
  45. buttons = isMobile
  46. ? [ 'chat', 'overflow' ]
  47. : [ 'overflow' ];
  48. break;
  49. }
  50. default: {
  51. buttons = isMobile
  52. ? [ 'chat', 'overflow' ]
  53. : [];
  54. }
  55. }
  56. return new Set(buttons);
  57. }
  58. /**
  59. * Helper for getting the height of the toolbox.
  60. *
  61. * @returns {number} The height of the toolbox.
  62. */
  63. export function getToolboxHeight() {
  64. const toolbox = document.getElementById('new-toolbox');
  65. return (toolbox && toolbox.clientHeight) || 0;
  66. }
  67. /**
  68. * Indicates if a toolbar button is enabled.
  69. *
  70. * @param {string} name - The name of the setting section as defined in
  71. * interface_config.js.
  72. * @param {Object} state - The redux state.
  73. * @returns {boolean|undefined} - True to indicate that the given toolbar button
  74. * is enabled, false - otherwise.
  75. */
  76. export function isButtonEnabled(name: string, state: Object) {
  77. const toolbarButtons = getToolbarButtons(state);
  78. return toolbarButtons.indexOf(name) !== -1;
  79. }
  80. /**
  81. * Indicates if the toolbox is visible or not.
  82. *
  83. * @param {string} state - The state from the Redux store.
  84. * @returns {boolean} - True to indicate that the toolbox is visible, false -
  85. * otherwise.
  86. */
  87. export function isToolboxVisible(state: Object) {
  88. const { iAmSipGateway } = state['features/base/config'];
  89. const {
  90. alwaysVisible,
  91. timeoutID,
  92. visible
  93. } = state['features/toolbox'];
  94. const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
  95. return Boolean(!iAmSipGateway && (timeoutID || visible || alwaysVisible
  96. || audioSettingsVisible || videoSettingsVisible));
  97. }
  98. /**
  99. * Indicates if the audio settings button is disabled or not.
  100. *
  101. * @param {string} state - The state from the Redux store.
  102. * @returns {boolean}
  103. */
  104. export function isAudioSettingsButtonDisabled(state: Object) {
  105. return (!hasAvailableDevices(state, 'audioInput')
  106. && !hasAvailableDevices(state, 'audioOutput'))
  107. || state['features/base/config'].startSilent;
  108. }
  109. /**
  110. * Indicates if the video settings button is disabled or not.
  111. *
  112. * @param {string} state - The state from the Redux store.
  113. * @returns {boolean}
  114. */
  115. export function isVideoSettingsButtonDisabled(state: Object) {
  116. return !hasAvailableDevices(state, 'videoInput');
  117. }
  118. /**
  119. * Indicates if the video mute button is disabled or not.
  120. *
  121. * @param {string} state - The state from the Redux store.
  122. * @returns {boolean}
  123. */
  124. export function isVideoMuteButtonDisabled(state: Object) {
  125. return !hasAvailableDevices(state, 'videoInput');
  126. }