import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { defineMessages, injectIntl } from 'react-intl'; import browser from 'browser-detect'; import injectWbResizeEvent from '/imports/ui/components/presentation/resize-wrapper/component'; import Button from '/imports/ui/components/button/component'; import { HUNDRED_PERCENT, MAX_PERCENT, STEP } from '/imports/utils/slideCalcUtils'; import cx from 'classnames'; import { styles } from './styles.scss'; import ZoomTool from './zoom-tool/component'; import FullscreenButtonContainer from '../../video-provider/fullscreen-button/container'; import Tooltip from '/imports/ui/components/tooltip/component'; import KEY_CODES from '/imports/utils/keyCodes'; const intlMessages = defineMessages({ previousSlideLabel: { id: 'app.presentation.presentationToolbar.prevSlideLabel', description: 'Previous slide button label', }, previousSlideDesc: { id: 'app.presentation.presentationToolbar.prevSlideDesc', description: 'Aria description for when switching to previous slide', }, nextSlideLabel: { id: 'app.presentation.presentationToolbar.nextSlideLabel', description: 'Next slide button label', }, nextSlideDesc: { id: 'app.presentation.presentationToolbar.nextSlideDesc', description: 'Aria description for when switching to next slide', }, noNextSlideDesc: { id: 'app.presentation.presentationToolbar.noNextSlideDesc', description: '', }, noPrevSlideDesc: { id: 'app.presentation.presentationToolbar.noPrevSlideDesc', description: '', }, skipSlideLabel: { id: 'app.presentation.presentationToolbar.skipSlideLabel', description: 'Aria label for when switching to a specific slide', }, skipSlideDesc: { id: 'app.presentation.presentationToolbar.skipSlideDesc', description: 'Aria description for when switching to a specific slide', }, goToSlide: { id: 'app.presentation.presentationToolbar.goToSlide', description: 'button for slide select', }, selectLabel: { id: 'app.presentation.presentationToolbar.selectLabel', description: 'slide select label', }, fitToWidth: { id: 'app.presentation.presentationToolbar.fitToWidth', description: 'button for fit to width', }, fitToWidthDesc: { id: 'app.presentation.presentationToolbar.fitWidthDesc', description: 'Aria description to display the whole width of the slide', }, fitToPage: { id: 'app.presentation.presentationToolbar.fitToPage', description: 'button label for fit to width', }, fitToPageDesc: { id: 'app.presentation.presentationToolbar.fitScreenDesc', description: 'Aria description to display the whole slide', }, presentationLabel: { id: 'app.presentationUploder.title', description: 'presentation area element label', }, }); class PresentationToolbar extends Component { constructor(props) { super(props); this.state = { sliderValue: 100, }; this.handleValuesChange = this.handleValuesChange.bind(this); this.handleSkipToSlideChange = this.handleSkipToSlideChange.bind(this); this.change = this.change.bind(this); this.renderAriaDescs = this.renderAriaDescs.bind(this); this.switchSlide = this.switchSlide.bind(this); this.setInt = 0; } componentDidMount() { document.addEventListener('keydown', this.switchSlide); } componentWillUnmount() { document.removeEventListener('keydown', this.switchSlide); } switchSlide(event) { const { target, which } = event; const isBody = target.nodeName === 'BODY'; const { actions } = this.props; if (isBody) { if ([KEY_CODES.ARROW_LEFT].includes(which)) { actions.previousSlideHandler(); } if ([KEY_CODES.ARROW_RIGHT].includes(which)) { actions.nextSlideHandler(); } } } handleSkipToSlideChange(event) { const { actions } = this.props; const requestedSlideNum = Number.parseInt(event.target.value, 10); actions.skipToSlideHandler(requestedSlideNum); } handleValuesChange(event) { const { sliderValue } = this.state; this.setState( { sliderValue: event.target.value }, () => this.handleZoom(sliderValue), ); } change(value) { const { zoomChanger } = this.props; zoomChanger(value); } renderAriaDescs() { const { intl } = this.props; return (