import React from 'react'; import styles from '../styles'; import cx from 'classnames'; import BaseMenu from '../base/component'; import Toggle from '/imports/ui/components/switch/component'; import Checkbox from '/imports/ui/components/checkbox/component'; import { GithubPicker } from 'react-color'; import { defineMessages, injectIntl } from 'react-intl'; // an array of font-families const FONT_FAMILIES = ['Arial', 'Calibri', 'Time New Roman', 'Sans-serif']; // an array of different font-sizes const FONT_SIZES = ['12px', '14px', '18px', '24px', '32px', '42px']; // an array of colors for both background and text const COLORS = [ '#000000', '#7A7A7A', '#FF0000', '#FF8800', '#88FF00', '#FFFFFF', '#00FFFF', '#0000FF', '#8800FF', '#FF00FF', ]; const intlMessages = defineMessages({ closedCaptionsLabel: { id: 'app.submenu.closedCaptions.closedCaptionsLabel', description: 'Closed Captions label', }, takeOwnershipLabel: { id: 'app.submenu.closedCaptions.takeOwnershipLabel', description: 'Take ownership label', }, languageLabel: { id: 'app.submenu.closedCaptions.languageLabel', description: 'Language label', }, localeOptionLabel: { id: 'app.submenu.closedCaptions.localeOptionLabel', description: 'Label for active locales', }, noLocaleOptionLabel: { id: 'app.submenu.closedCaptions.noLocaleOptionLabel', description: 'Label for no active locales', }, fontFamilyLabel: { id: 'app.submenu.closedCaptions.fontFamilyLabel', description: 'Label for type of Font family', }, fontFamilyOptionLabel: { id: 'app.submenu.closedCaptions.fontFamilyOptionLabel', description: 'Font-family default choice option', }, fontSizeLabel: { id: 'app.submenu.closedCaptions.fontSizeLabel', description: 'Font size label', }, fontSizeOptionLabel: { id: 'app.submenu.closedCaptions.fontSizeOptionLabel', description: 'Choose Font size default option label', }, backgroundColorLabel: { id: 'app.submenu.closedCaptions.backgroundColorLabel', description: 'Background color label', }, fontColorLabel: { id: 'app.submenu.closedCaptions.fontColorLabel', description: 'Font color label', }, }); class ClosedCaptionsMenu extends BaseMenu { constructor(props) { super(props); this.state = { settingsName: 'cc', settings: { backgroundColor: props.settings ? props.settings.backgroundColor : '#f3f6f9', fontColor: props.settings ? props.settings.fontColor : '#000000', enabled: props.settings ? props.settings.enabled : false, fontFamily: props.settings ? props.settings.fontFamily : 'Calibri', fontSize: props.settings ? props.settings.fontSize : -1, locale: props.settings ? props.settings.locale : -1, takeOwnership: props.settings ? props.settings.takeOwnership : false, }, }; } getPreviewStyle() { return { fontFamily: this.state.settings.fontFamily, fontSize: this.state.settings.fontSize, color: this.state.settings.fontColor, }; } // clickhandler, opens a selected color picker (supports both of them) handleColorPickerClick(fieldname) { const obj = {}; obj[fieldname] = !this.state[fieldname]; this.setState(obj); } // closes color pickers handleCloseColorPicker() { this.setState({ displayBackgroundColorPicker: false, displayFontColorPicker: false, }); } handleSelectChange(fieldname, options, e) { const obj = this.state; obj.settings[fieldname] = options[e.target.value]; this.setState(obj); this.handleUpdateSettings('cc', obj.settings); } handleColorChange(fieldname, color) { const obj = this.state; obj.settings[fieldname] = color.hex; this.setState(obj); this.handleUpdateSettings('cc', obj.settings); this.handleCloseColorPicker(); } render() { const { locales, intl, isModerator, } = this.props; return (

{intl.formatMessage(intlMessages.closedCaptionsLabel)}

this.handleToggle('enabled')} ariaLabelledBy={'closedCaptions'} ariaLabel={intl.formatMessage(intlMessages.closedCaptionsLabel)} />
{ this.state.settings.enabled ?
{ isModerator ?
this.handleToggle('takeOwnership')} checked={this.state.settings.takeOwnership} ariaLabelledBy={'takeOwnership'} ariaLabel={intl.formatMessage(intlMessages.takeOwnershipLabel)} />
: null }
{ this.state.displayBackgroundColorPicker ?
: null }
{ this.state.displayFontColorPicker ?
: null }
Etiam porta sem malesuada magna mollis euis-mod. Donec ullamcorper nulla non metus auctor fringilla.
: null }
); } } export default injectIntl(ClosedCaptionsMenu);