Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

reducer.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. // @flow
  2. import { ReducerRegistry } from '../base/redux';
  3. import {
  4. CLEAR_TOOLBOX_TIMEOUT,
  5. FULL_SCREEN_CHANGED,
  6. SET_OVERFLOW_MENU_VISIBLE,
  7. SET_TOOLBAR_HOVERED,
  8. SET_TOOLBOX_ALWAYS_VISIBLE,
  9. SET_TOOLBOX_ENABLED,
  10. SET_TOOLBOX_TIMEOUT,
  11. SET_TOOLBOX_TIMEOUT_MS,
  12. SET_TOOLBOX_VISIBLE
  13. } from './actionTypes';
  14. declare var interfaceConfig: Object;
  15. /**
  16. * Returns initial state for toolbox's part of Redux store.
  17. *
  18. * @private
  19. * @returns {{
  20. * alwaysVisible: boolean,
  21. * enabled: boolean,
  22. * hovered: boolean,
  23. * overflowMenuVisible: boolean,
  24. * timeoutID: number,
  25. * timeoutMS: number,
  26. * visible: boolean
  27. * }}
  28. */
  29. function _getInitialState() {
  30. // Default toolbox timeout for mobile app.
  31. let timeoutMS = 5000;
  32. if (typeof interfaceConfig !== 'undefined'
  33. && interfaceConfig.INITIAL_TOOLBAR_TIMEOUT) {
  34. timeoutMS = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
  35. }
  36. return {
  37. /**
  38. * The indicator which determines whether the Toolbox should always be
  39. * visible.
  40. *
  41. * @type {boolean}
  42. */
  43. alwaysVisible: false,
  44. /**
  45. * The indicator which determines whether the Toolbox is enabled. For
  46. * example, modules/UI/recording/Recording.js disables the Toolbox.
  47. *
  48. * @type {boolean}
  49. */
  50. enabled: true,
  51. /**
  52. * The indicator which determines whether a Toolbar in the Toolbox is
  53. * hovered.
  54. *
  55. * @type {boolean}
  56. */
  57. hovered: false,
  58. /**
  59. * The indicator which determines whether the OverflowMenu is visible.
  60. *
  61. * @type {boolean}
  62. */
  63. overflowMenuVisible: false,
  64. /**
  65. * A number, non-zero value which identifies the timer created by a call
  66. * to setTimeout() with timeoutMS.
  67. *
  68. * @type {number|null}
  69. */
  70. timeoutID: null,
  71. /**
  72. * The delay in milliseconds before timeoutID executes (after its
  73. * initialization).
  74. *
  75. * @type {number}
  76. */
  77. timeoutMS,
  78. /**
  79. * The indicator which determines whether the Toolbox is visible.
  80. *
  81. * @type {boolean}
  82. */
  83. visible: false
  84. };
  85. }
  86. ReducerRegistry.register(
  87. 'features/toolbox',
  88. (state: Object = _getInitialState(), action: Object) => {
  89. switch (action.type) {
  90. case CLEAR_TOOLBOX_TIMEOUT:
  91. return {
  92. ...state,
  93. timeoutID: undefined
  94. };
  95. case FULL_SCREEN_CHANGED:
  96. return {
  97. ...state,
  98. fullScreen: action.fullScreen
  99. };
  100. case SET_OVERFLOW_MENU_VISIBLE:
  101. return {
  102. ...state,
  103. overflowMenuVisible: action.visible
  104. };
  105. case SET_TOOLBAR_HOVERED:
  106. return {
  107. ...state,
  108. hovered: action.hovered
  109. };
  110. case SET_TOOLBOX_ALWAYS_VISIBLE:
  111. return {
  112. ...state,
  113. alwaysVisible: action.alwaysVisible
  114. };
  115. case SET_TOOLBOX_ENABLED:
  116. return {
  117. ...state,
  118. enabled: action.enabled
  119. };
  120. case SET_TOOLBOX_TIMEOUT:
  121. return {
  122. ...state,
  123. timeoutID: action.timeoutID,
  124. timeoutMS: action.timeoutMS
  125. };
  126. case SET_TOOLBOX_TIMEOUT_MS:
  127. return {
  128. ...state,
  129. timeoutMS: action.timeoutMS
  130. };
  131. case SET_TOOLBOX_VISIBLE:
  132. return {
  133. ...state,
  134. visible: action.visible
  135. };
  136. }
  137. return state;
  138. });