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 2.7KB

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