You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

actions.native.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* @flow */
  2. import {
  3. CLEAR_TOOLBOX_TIMEOUT,
  4. SET_OVERFLOW_MENU_VISIBLE,
  5. SET_TOOLBAR_HOVERED,
  6. SET_TOOLBOX_ALWAYS_VISIBLE,
  7. SET_TOOLBOX_ENABLED,
  8. SET_TOOLBOX_TIMEOUT,
  9. SET_TOOLBOX_TIMEOUT_MS,
  10. SET_TOOLBOX_VISIBLE
  11. } from './actionTypes';
  12. /**
  13. * Signals that toolbox timeout should be cleared.
  14. *
  15. * @returns {{
  16. * type: CLEAR_TOOLBOX_TIMEOUT
  17. * }}
  18. */
  19. export function clearToolboxTimeout(): Object {
  20. return {
  21. type: CLEAR_TOOLBOX_TIMEOUT
  22. };
  23. }
  24. /**
  25. * Shows/hides the overflow menu.
  26. *
  27. * @param {boolean} visible - True to show it or false to hide it.
  28. * @returns {{
  29. * type: SET_OVERFLOW_MENU_VISIBLE,
  30. * visible: boolean
  31. * }}
  32. */
  33. export function setOverflowMenuVisible(visible: boolean): Object {
  34. return {
  35. type: SET_OVERFLOW_MENU_VISIBLE,
  36. visible
  37. };
  38. }
  39. /**
  40. * Signals that toolbar is hovered value should be changed.
  41. *
  42. * @param {boolean} hovered - Flag showing whether toolbar is hovered.
  43. * @returns {{
  44. * type: SET_TOOLBAR_HOVERED,
  45. * hovered: boolean
  46. * }}
  47. */
  48. export function setToolbarHovered(hovered: boolean): Object {
  49. return {
  50. type: SET_TOOLBAR_HOVERED,
  51. hovered
  52. };
  53. }
  54. /**
  55. * Signals that always visible toolbars value should be changed.
  56. *
  57. * @param {boolean} alwaysVisible - Value to be set in redux store.
  58. * @returns {{
  59. * type: SET_TOOLBOX_ALWAYS_VISIBLE,
  60. * alwaysVisible: boolean
  61. * }}
  62. */
  63. export function setToolboxAlwaysVisible(alwaysVisible: boolean): Object {
  64. return {
  65. type: SET_TOOLBOX_ALWAYS_VISIBLE,
  66. alwaysVisible
  67. };
  68. }
  69. /* eslint-disable flowtype/space-before-type-colon */
  70. /**
  71. * Enables/disables the toolbox.
  72. *
  73. * @param {boolean} enabled - True to enable the toolbox or false to disable it.
  74. * @returns {{
  75. * type: SET_TOOLBOX_ENABLED,
  76. * enabled: boolean
  77. * }}
  78. */
  79. export function setToolboxEnabled(enabled: boolean): Object {
  80. return {
  81. type: SET_TOOLBOX_ENABLED,
  82. enabled
  83. };
  84. }
  85. /**
  86. * Dispatches an action which sets new timeout and clears the previous one.
  87. *
  88. * @param {Function} handler - Function to be invoked after the timeout.
  89. * @param {number} timeoutMS - Delay.
  90. * @returns {{
  91. * type: SET_TOOLBOX_TIMEOUT,
  92. * handler: Function,
  93. * timeoutMS: number
  94. * }}
  95. */
  96. export function setToolboxTimeout(handler: Function, timeoutMS: number)
  97. : Object {
  98. return {
  99. type: SET_TOOLBOX_TIMEOUT,
  100. handler,
  101. timeoutMS
  102. };
  103. }
  104. /* eslint-enable flowtype/space-before-type-colon */
  105. /**
  106. * Dispatches an action which sets new toolbox timeout value.
  107. *
  108. * @param {number} timeoutMS - Delay.
  109. * @returns {{
  110. * type: SET_TOOLBOX_TIMEOUT_MS,
  111. * timeoutMS: number
  112. * }}
  113. */
  114. export function setToolboxTimeoutMS(timeoutMS: number): Object {
  115. return {
  116. type: SET_TOOLBOX_TIMEOUT_MS,
  117. timeoutMS
  118. };
  119. }
  120. /**
  121. * Shows/hides the toolbox.
  122. *
  123. * @param {boolean} visible - True to show the toolbox or false to hide it.
  124. * @returns {{
  125. * type: SET_TOOLBOX_VISIBLE,
  126. * visible: boolean
  127. * }}
  128. */
  129. export function setToolboxVisible(visible: boolean): Object {
  130. return {
  131. type: SET_TOOLBOX_VISIBLE,
  132. visible
  133. };
  134. }