Skip to content
Snippets Groups Projects
Select Git revision
  • f101adcb2f977251fff01fe7b6e01bdbbf942562
  • mui5-annotation-on-video-stable default
  • get_setter_canvasSizeInformations
  • fix-error-div-into-p
  • annotation-on-video-v2
  • detached
  • annotation-on-video-r17
  • mui5
  • mui5-react-18
  • jacob-test
  • annotation-on-video protected
  • master
  • test-antoinev1
  • 20-fetch-thumbnail-on-annotation
  • add-research-field
  • Save
  • add-plugin
  • 14-wip-no-seek-to
  • 14-bug-on-video-time-control
  • 9_wip_videotests
  • _upgrade_material_ui
  • latest-tetras-16
  • v3.3.0
  • v3.2.0
  • v3.1.1
  • v3.1.0
  • v3.0.0
  • v3.0.0-rc.7
  • v3.0.0-rc.6
  • v3.0.0-rc.5
  • v3.0.0-rc.4
  • v3.0.0-rc.3
  • v3.0.0-rc.2
  • v3.0.0-rc.1
  • v3.0.0-beta.10
  • v3.0.0-beta.9
  • v3.0.0-beta.8
  • v3.0.0-beta.7
  • v3.0.0-beta.6
  • v3.0.0-beta.5
  • v3.0.0-beta.3
41 results

window.js

Blame
  • window.js 4.03 KiB
    import uuid from 'uuid/v4';
    import ActionTypes from './action-types';
    import { addCompanionWindow, removeCompanionWindow } from './companionWindow';
    
    /**
     * focusWindow - action creator
     *
     * @param  {String} windowId
     * @memberof ActionCreators
     */
    export function focusWindow(windowId) {
      return { type: ActionTypes.FOCUS_WINDOW, windowId };
    }
    
    /**
     * addWindow - action creator
     *
     * @param  {Object} options
     * @memberof ActionCreators
     */
    export function addWindow(options) {
      const defaultOptions = {
        id: `window-${uuid()}`,
        canvasIndex: 0,
        collectionIndex: 0,
        manifestId: null,
        rangeId: null,
        thumbnailNavigationPosition: 'bottom', // bottom by default in settings.js
        xywh: [0, 0, 400, 400],
        companionWindowIds: [],
        rotation: null,
        view: 'single',
        displayable: true,
      };
      return { type: ActionTypes.ADD_WINDOW, window: { ...defaultOptions, ...options } };
    }
    
    /**
     * maximizeWindow
     * @param  {String} windowId
     * @memberof ActionCreators
     */
    export function maximizeWindow(windowId) {
      return { type: ActionTypes.MAXIMIZE_WINDOW, windowId };
    }
    
    /** */
    export function updateWindow(id, payload) {
      return { type: ActionTypes.UPDATE_WINDOW, id, payload };
    }
    
    /**
     * removeWindow - action creator
     *
     * @param  {String} windowId
     * @memberof ActionCreators
     */
    export function removeWindow(windowId) {
      return { type: ActionTypes.REMOVE_WINDOW, windowId };
    }
    
    /**
     * toggleWindowSideBar - action creator
     *
     * @param  {String} windowId
     * @memberof ActionCreators
     */
    export function toggleWindowSideBar(windowId) {
      return { type: ActionTypes.TOGGLE_WINDOW_SIDE_BAR, windowId };
    }
    
    /**
     * toggleWindowSideBarPanel - action creator
     *
     * @param  {String} windowId
     * @param  {String} panelType
     * @memberof ActionCreators
     */
    export function toggleWindowSideBarPanel(windowId, panelType) {
      return { type: ActionTypes.TOGGLE_WINDOW_SIDE_BAR_PANEL, windowId, panelType };
    }
    
    /**
     * popOutCompanionWindow - action creator
     *
     * @param  {String} windowId
     * @param  {String} panelType The type of panel content to be rendered
     *                            in the companion window (e.g. info, canvas_navigation)
     * @param  {String} position The position of the companion window to
     *                           set content for (e.g. right, bottom)
     * @memberof ActionCreators
     */
    export function popOutCompanionWindow(windowId, panelType, position) {
      return (dispatch, getState) => {
        const { companionWindowIds } = getState().windows[windowId];
        companionWindowIds.map(id => dispatch(removeCompanionWindow(id)));
    
        const action = dispatch(addCompanionWindow({ content: panelType, position }));
    
        const companionWindowId = action.id;
        dispatch(updateWindow(windowId, { companionWindowIds: [companionWindowId] }));
    
        dispatch(toggleWindowSideBarPanel(windowId, 'closed'));
      };
    }
    
    /**
    * Clean up state and remove window
    */
    export function closeWindow(windowId) {
      return (dispatch, getState) => {
        const { companionWindowIds } = getState().windows[windowId];
        companionWindowIds.map(id => dispatch(removeCompanionWindow(id)));
        dispatch(removeWindow(windowId));
      };
    }
    
    /**
    * Close companion window and remove reference from window
    */
    export function closeCompanionWindow(windowId, companionWindowId) {
      return (dispatch, getState) => {
        dispatch(removeCompanionWindow(companionWindowId));
        const companionWindowIds = getState().windows[windowId].companionWindowIds
          .filter(id => id !== companionWindowId);
        dispatch(updateWindow(windowId, { companionWindowIds }));
      };
    }
    
    /**
     * setWindowThumbnailPosition - action creator
     *
     * @param  {String} windowId
     * @param  {String} position
     * @memberof ActionCreators
     */
    export function setWindowThumbnailPosition(windowId, position) {
      return { type: ActionTypes.SET_WINDOW_THUMBNAIL_POSITION, windowId, position };
    }
    
    /**
     * setWindowViewType - action creator
     *
     * @param  {String} windowId
     * @param  {String} viewType
     * @memberof ActionCreators
     */
    export function setWindowViewType(windowId, viewType) {
      return { type: ActionTypes.SET_WINDOW_VIEW_TYPE, windowId, viewType };
    }