@bigfishtv/cockpit
Version:
70 lines (62 loc) • 1.66 kB
JavaScript
/**
* @module Actions/preview
*/
import * as ActionTypes from '../constants/ActionTypes';
import { openPreviewWindow, closePreviewWindow } from '../utils/previewUtils';
export function togglePreview() {
return function (dispatch, getState) {
if (getState().preview.enabled) {
closePreviewWindow();
dispatch(disablePreview());
} else {
openPreviewWindow();
dispatch(enablePreview());
}
};
}
/**
* Action for enabling preview
* @return {Object} returns action
*/
export function enablePreview() {
return { type: ActionTypes.PREVIEW_ENABLED };
}
/**
* Action for disabling preview
* @return {Object} returns action
*/
export function disablePreview() {
return { type: ActionTypes.PREVIEW_DISABLED };
}
/**
* Action for updating preview data
* @param {Object} data
* @return {Object} returns action
*/
export function updatePreviewData(data) {
return { type: ActionTypes.PREVIEW_DATA_UPDATED, data: data };
}
/**
* Action for updating preview url
* @param {String} url
* @return {Object} returns action
*/
export function updatePreviewUrl(url) {
return { type: ActionTypes.PREVIEW_URL_UPDATED, url: url };
}
/**
* Action for updating preview device width
* @param {Number} deviceWidth
* @return {Object} returns action
*/
export function deviceWidthChanged(deviceWidth) {
return { type: ActionTypes.PREVIEW_DEVICE_WIDTH_CHANGED, deviceWidth: deviceWidth };
}
/**
* Action for updating preview device width
* @param {Number} deviceWidth
* @return {Object} returns action
*/
export function previewDateChanged(date) {
return { type: ActionTypes.PREVIEW_DATE_UPDATED, date: date };
}