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.web.js 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // @flow
  2. import { SET_HORIZONTAL_VIEW_DIMENSIONS, SET_TILE_VIEW_DIMENSIONS } from './actionTypes';
  3. import { calculateThumbnailSizeForHorizontalView, calculateThumbnailSizeForTileView } from './functions';
  4. // dev mod
  5. import { getTileViewGridDimensions } from '../video-layout';
  6. window.glob_react.getTileViewGridDimensions = getTileViewGridDimensions
  7. // clog("window.glob_react",window.glob_react)
  8. // import { getCurrentLayout, getTileViewGridDimensions, shouldDisplayTileView, LAYOUTS } from '../video-layout';
  9. /**
  10. * The size of the side margins for each tile as set in CSS.
  11. */
  12. const TILE_VIEW_SIDE_MARGINS = 10 * 2;
  13. /**
  14. * Sets the dimensions of the tile view grid.
  15. *
  16. * @param {Object} dimensions - Whether the filmstrip is visible.
  17. * @param {Object} windowSize - The size of the window.
  18. * @returns {{
  19. * type: SET_TILE_VIEW_DIMENSIONS,
  20. * dimensions: Object
  21. * }}
  22. */
  23. export function setTileViewDimensions(dimensions: Object, windowSize: Object) {
  24. // dev hook
  25. if (window.glob_dev_fns && window.glob_dev_fns.setTileViewDimensions){
  26. // var ret = window.glob_dev_fns.setTileViewDimensions.apply(this,...arguments)
  27. var ret = window.glob_dev_fns.setTileViewDimensions({that:this,args:arguments})
  28. if (ret){
  29. if (ret.ret){
  30. return ret.ret
  31. } else {
  32. ret.dimensions ? dimensions = ret.dimensions : 0
  33. ret.windowSize ? windowSize = ret.windowSize : 0
  34. // if (ret.dimensions){}
  35. }
  36. }
  37. clog("STV.",SET_TILE_VIEW_DIMENSIONS,TILE_VIEW_SIDE_MARGINS)
  38. }
  39. const thumbnailSize = calculateThumbnailSizeForTileView({
  40. ...dimensions,
  41. ...windowSize
  42. });
  43. var TILE_VIEW_SIDE_MARGINS = 10 * 2;
  44. if (window.TILE_VIEW_SIDE_MARGINS){
  45. TILE_VIEW_SIDE_MARGINS = window.TILE_VIEW_SIDE_MARGINS
  46. }
  47. const filmstripWidth = dimensions.columns * (TILE_VIEW_SIDE_MARGINS + thumbnailSize.width);
  48. return {
  49. type: SET_TILE_VIEW_DIMENSIONS,
  50. dimensions: {
  51. gridDimensions: dimensions,
  52. xtra:"xtra_val",
  53. thumbnailSize,
  54. filmstripWidth
  55. }
  56. };
  57. }
  58. /**
  59. * Sets the dimensions of the thumbnails in horizontal view.
  60. *
  61. * @param {number} clientHeight - The height of the window.
  62. * @returns {{
  63. * type: SET_HORIZONTAL_VIEW_DIMENSIONS,
  64. * dimensions: Object
  65. * }}
  66. */
  67. export function setHorizontalViewDimensions(clientHeight: number = 0) {
  68. return {
  69. type: SET_HORIZONTAL_VIEW_DIMENSIONS,
  70. dimensions: calculateThumbnailSizeForHorizontalView(clientHeight)
  71. };
  72. }
  73. export * from './actions.native';