選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

actions.web.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* @flow */
  2. import SideContainerToggler
  3. from '../../../modules/UI/side_pannels/SideContainerToggler';
  4. import {
  5. clearToolboxTimeout,
  6. setSubjectSlideIn,
  7. setToolboxTimeout,
  8. setToolboxTimeoutMS,
  9. setToolboxVisible
  10. } from './actions.native';
  11. import {
  12. FULL_SCREEN_CHANGED,
  13. SET_FULL_SCREEN
  14. } from './actionTypes';
  15. declare var interfaceConfig: Object;
  16. export * from './actions.native';
  17. /**
  18. * Docks/undocks the Toolbox.
  19. *
  20. * @param {boolean} dock - True if dock, false otherwise.
  21. * @returns {Function}
  22. */
  23. export function dockToolbox(dock: boolean): Function {
  24. return (dispatch: Dispatch<*>, getState: Function) => {
  25. if (interfaceConfig.filmStripOnly) {
  26. return;
  27. }
  28. const { timeoutMS, visible } = getState()['features/toolbox'];
  29. if (dock) {
  30. // First make sure the toolbox is shown.
  31. visible || dispatch(showToolbox());
  32. dispatch(clearToolboxTimeout());
  33. } else if (visible) {
  34. dispatch(
  35. setToolboxTimeout(
  36. () => dispatch(hideToolbox()),
  37. timeoutMS));
  38. } else {
  39. dispatch(showToolbox());
  40. }
  41. };
  42. }
  43. /**
  44. * Signals that full screen mode has been entered or exited.
  45. *
  46. * @param {boolean} fullScreen - Whether or not full screen mode is currently
  47. * enabled.
  48. * @returns {{
  49. * type: FULL_SCREEN_CHANGED,
  50. * fullScreen: boolean
  51. * }}
  52. */
  53. export function fullScreenChanged(fullScreen: boolean) {
  54. return {
  55. type: FULL_SCREEN_CHANGED,
  56. fullScreen
  57. };
  58. }
  59. /**
  60. * Hides the toolbox.
  61. *
  62. * @param {boolean} force - True to force the hiding of the toolbox without
  63. * caring about the extended toolbar side panels.
  64. * @returns {Function}
  65. */
  66. export function hideToolbox(force: boolean = false): Function {
  67. return (dispatch: Dispatch<*>, getState: Function) => {
  68. const state = getState();
  69. const {
  70. alwaysVisible,
  71. hovered,
  72. timeoutMS
  73. } = state['features/toolbox'];
  74. if (alwaysVisible) {
  75. return;
  76. }
  77. dispatch(clearToolboxTimeout());
  78. if (!force
  79. && (hovered
  80. || state['features/base/jwt'].calleeInfoVisible
  81. || SideContainerToggler.isVisible())) {
  82. dispatch(
  83. setToolboxTimeout(
  84. () => dispatch(hideToolbox()),
  85. timeoutMS));
  86. } else {
  87. dispatch(setToolboxVisible(false));
  88. dispatch(setSubjectSlideIn(false));
  89. }
  90. };
  91. }
  92. /**
  93. * Signals a request to enter or exit full screen mode.
  94. *
  95. * @param {boolean} fullScreen - True to enter full screen mode, false to exit.
  96. * @returns {{
  97. * type: SET_FULL_SCREEN,
  98. * fullScreen: boolean
  99. * }}
  100. */
  101. export function setFullScreen(fullScreen: boolean) {
  102. return {
  103. type: SET_FULL_SCREEN,
  104. fullScreen
  105. };
  106. }
  107. /**
  108. * Shows the toolbox for specified timeout.
  109. *
  110. * @param {number} timeout - Timeout for showing the toolbox.
  111. * @returns {Function}
  112. */
  113. export function showToolbox(timeout: number = 0): Object {
  114. return (dispatch: Dispatch<*>, getState: Function) => {
  115. const state = getState();
  116. const {
  117. alwaysVisible,
  118. enabled,
  119. timeoutMS,
  120. visible
  121. } = state['features/toolbox'];
  122. if (enabled && !visible) {
  123. dispatch(setToolboxVisible(true));
  124. dispatch(setSubjectSlideIn(true));
  125. // If the Toolbox is always visible, there's no need for a timeout
  126. // to toggle its visibility.
  127. if (!alwaysVisible) {
  128. dispatch(
  129. setToolboxTimeout(
  130. () => dispatch(hideToolbox()),
  131. timeout || timeoutMS));
  132. dispatch(setToolboxTimeoutMS(interfaceConfig.TOOLBAR_TIMEOUT));
  133. }
  134. }
  135. };
  136. }