2016-08-03 06:55:20 +08:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
import styles from './styles.scss';
|
|
|
|
import Button from '/imports/ui/components/button/component';
|
|
|
|
import classNames from 'classnames';
|
2017-02-17 06:14:10 +08:00
|
|
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2017-02-17 06:14:10 +08:00
|
|
|
const intlMessages = defineMessages({
|
|
|
|
previousSlideLabel: {
|
2017-02-24 04:20:21 +08:00
|
|
|
id: 'app.presentation.presentationToolbar.prevSlideLabel',
|
2017-02-17 06:14:10 +08:00
|
|
|
},
|
|
|
|
nextSlideLabel: {
|
2017-02-24 04:20:21 +08:00
|
|
|
id: 'app.presentation.presentationToolbar.nextSlideLabel',
|
2017-02-17 06:14:10 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2017-02-24 04:20:21 +08:00
|
|
|
class PresentationToolbar extends Component {
|
2016-08-03 06:55:20 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = { sliderValue: 100 };
|
|
|
|
this.handleValuesChange = this.handleValuesChange.bind(this);
|
|
|
|
}
|
|
|
|
|
2017-03-24 05:52:36 +08:00
|
|
|
componentDidMount() {
|
|
|
|
//to let the whiteboard know that the presentation area's size has changed
|
|
|
|
window.dispatchEvent(new Event('resize'));
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
//to let the whiteboard know that the presentation area's size has changed
|
|
|
|
window.dispatchEvent(new Event('resize'));
|
|
|
|
}
|
|
|
|
|
2016-08-03 06:55:20 +08:00
|
|
|
handleValuesChange(event) {
|
|
|
|
this.setState({ sliderValue: event.target.value });
|
|
|
|
}
|
|
|
|
|
2016-08-06 02:39:24 +08:00
|
|
|
fitToWidthClickHandler() {
|
|
|
|
console.log('Not implemented yet');
|
2016-08-03 06:55:20 +08:00
|
|
|
}
|
|
|
|
|
2016-08-06 02:39:24 +08:00
|
|
|
fitToScreenClickHandler() {
|
|
|
|
console.log('Not implemented yet');
|
2016-08-03 06:55:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
renderSkipSlideOpts(numberOfSlides) {
|
|
|
|
// Fill drop down menu with all the slides in presentation
|
|
|
|
let optionList = [];
|
|
|
|
for (i = 1; i <= numberOfSlides; i++) {
|
|
|
|
optionList.push(
|
|
|
|
<option
|
|
|
|
value={i}
|
|
|
|
key={i}
|
|
|
|
role="option"
|
|
|
|
aria-controls="slideComponent"
|
|
|
|
>
|
|
|
|
Slide {i}
|
|
|
|
</option>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return optionList;
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
currentSlideNum,
|
|
|
|
numberOfSlides,
|
2016-08-06 02:39:24 +08:00
|
|
|
actions,
|
2017-02-17 06:14:10 +08:00
|
|
|
intl,
|
2016-08-03 06:55:20 +08:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
return (
|
2017-02-24 04:20:21 +08:00
|
|
|
<div id="presentationToolbarWrapper" className={styles.presentationToolbarWrapper}>
|
2016-08-03 06:55:20 +08:00
|
|
|
{this.renderAriaLabelsDescs()}
|
|
|
|
|
|
|
|
{/*Previous Slide button*/}
|
|
|
|
<Button
|
|
|
|
role="button"
|
|
|
|
aria-labelledby="prevSlideLabel"
|
|
|
|
aria-describedby="prevSlideDescrip"
|
|
|
|
aria-controls="skipSlide slideComponent"
|
2016-08-06 02:39:24 +08:00
|
|
|
disabled={currentSlideNum > 1 ? false : true}
|
2016-08-03 06:55:20 +08:00
|
|
|
color={'default'}
|
2017-03-02 09:03:02 +08:00
|
|
|
icon={'left_arrow'}
|
2016-08-03 06:55:20 +08:00
|
|
|
size={'md'}
|
2016-08-06 02:39:24 +08:00
|
|
|
onClick={actions.previousSlideHandler}
|
2017-02-17 06:14:10 +08:00
|
|
|
label={intl.formatMessage(intlMessages.previousSlideLabel)}
|
2016-08-03 06:55:20 +08:00
|
|
|
hideLabel={true}
|
|
|
|
className={styles.prevSlide}
|
|
|
|
/>
|
|
|
|
{/*Skip Slide drop down*/}
|
|
|
|
<select
|
|
|
|
id="skipSlide"
|
|
|
|
role="listbox"
|
|
|
|
aria-labelledby="skipSlideLabel"
|
|
|
|
aria-describedby="skipSlideDescrip"
|
|
|
|
aria-controls="slideComponent"
|
|
|
|
aria-live="polite"
|
|
|
|
aria-relevant="all"
|
|
|
|
value={currentSlideNum}
|
2016-08-06 02:39:24 +08:00
|
|
|
onChange={actions.skipToSlideHandler}
|
2016-08-03 06:55:20 +08:00
|
|
|
className={styles.skipSlide}
|
|
|
|
>
|
|
|
|
{this.renderSkipSlideOpts(numberOfSlides)}
|
|
|
|
</select>
|
2017-03-03 23:13:46 +08:00
|
|
|
{/*Next Slide button*/}
|
|
|
|
<Button
|
|
|
|
role="button"
|
|
|
|
aria-labelledby="nextSlideLabel"
|
|
|
|
aria-describedby="nextSlideDescrip"
|
|
|
|
aria-controls="skipSlide slideComponent"
|
|
|
|
disabled={currentSlideNum < numberOfSlides ? false : true}
|
|
|
|
color={'default'}
|
2017-03-07 04:44:19 +08:00
|
|
|
icon={'right_arrow'}
|
2017-03-03 23:13:46 +08:00
|
|
|
size={'md'}
|
|
|
|
onClick={actions.nextSlideHandler}
|
|
|
|
label={intl.formatMessage(intlMessages.nextSlideLabel)}
|
|
|
|
hideLabel={true}
|
|
|
|
/>
|
|
|
|
|
2016-12-21 02:33:14 +08:00
|
|
|
{/*Fit to width button
|
2016-08-03 06:55:20 +08:00
|
|
|
<Button
|
|
|
|
role="button"
|
|
|
|
aria-labelledby="fitWidthLabel"
|
|
|
|
aria-describedby="fitWidthDescrip"
|
|
|
|
color={'default'}
|
2017-03-02 09:03:02 +08:00
|
|
|
icon={'fit_to_width'}
|
2016-08-03 06:55:20 +08:00
|
|
|
size={'md'}
|
|
|
|
circle={false}
|
2016-08-06 02:39:24 +08:00
|
|
|
onClick={this.fitToWidthClickHandler}
|
2016-08-03 06:55:20 +08:00
|
|
|
label={'Fit to Width'}
|
|
|
|
hideLabel={true}
|
2016-12-21 02:33:14 +08:00
|
|
|
/>*/}
|
|
|
|
{/*Fit to screen button
|
2016-08-03 06:55:20 +08:00
|
|
|
<Button
|
|
|
|
role="button"
|
|
|
|
aria-labelledby="fitScreenLabel"
|
|
|
|
aria-describedby="fitScreenDescrip"
|
|
|
|
color={'default'}
|
2017-03-02 09:03:02 +08:00
|
|
|
icon={'fit_to_screen'}
|
2016-08-03 06:55:20 +08:00
|
|
|
size={'md'}
|
|
|
|
circle={false}
|
2016-08-06 02:39:24 +08:00
|
|
|
onClick={this.fitToScreenClickHandler}
|
2016-08-03 06:55:20 +08:00
|
|
|
label={'Fit to Screen'}
|
|
|
|
hideLabel={true}
|
2016-12-21 02:33:14 +08:00
|
|
|
/>*/}
|
|
|
|
{/*Zoom slider
|
2016-08-06 02:39:24 +08:00
|
|
|
<div
|
2016-08-06 04:40:34 +08:00
|
|
|
className={classNames(styles.zoomWrapper, { [styles.zoomWrapperNoBorder]: true })}
|
2016-08-03 06:55:20 +08:00
|
|
|
>
|
|
|
|
<div className={styles.zoomMinMax}> 100% </div>
|
|
|
|
<input
|
|
|
|
role="slider"
|
|
|
|
aria-labelledby="zoomLabel"
|
|
|
|
aria-describedby="zoomDescrip"
|
|
|
|
aria-valuemax="400"
|
|
|
|
aria-valuemin="100"
|
|
|
|
aria-valuenow={this.state.sliderValue}
|
|
|
|
value={this.state.sliderValue}
|
|
|
|
step="5"
|
|
|
|
type="range"
|
|
|
|
min="100"
|
|
|
|
max="400"
|
|
|
|
onChange={this.handleValuesChange}
|
|
|
|
onInput={this.handleValuesChange}
|
|
|
|
className={styles.zoomSlider}
|
|
|
|
/>
|
|
|
|
<div className={styles.zoomMinMax}> 400% </div>
|
2016-12-21 02:33:14 +08:00
|
|
|
</div>*/}
|
2016-08-03 06:55:20 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderAriaLabelsDescs() {
|
|
|
|
return (
|
2016-08-06 02:39:24 +08:00
|
|
|
<div hidden >
|
2016-08-03 06:55:20 +08:00
|
|
|
{/*Previous Slide button aria*/}
|
2016-08-06 02:39:24 +08:00
|
|
|
<div id="prevSlideLabel">
|
2016-08-03 06:55:20 +08:00
|
|
|
<FormattedMessage
|
2017-02-24 04:20:21 +08:00
|
|
|
id="app.presentation.presentationToolbar.prevSlideLabel"
|
2016-08-03 06:55:20 +08:00
|
|
|
description="Aria label for when switching to previous slide"
|
|
|
|
defaultMessage="Previous slide"
|
|
|
|
/>
|
2016-08-06 02:39:24 +08:00
|
|
|
</div>
|
|
|
|
<div id="prevSlideDescrip">
|
2016-08-03 06:55:20 +08:00
|
|
|
<FormattedMessage
|
2017-02-24 04:20:21 +08:00
|
|
|
id="app.presentation.presentationToolbar.prevSlideDescrip"
|
2016-08-03 06:55:20 +08:00
|
|
|
description="Aria description for when switching to previous slide"
|
|
|
|
defaultMessage="Change the presentation to the previous slide"
|
|
|
|
/>
|
2016-08-06 02:39:24 +08:00
|
|
|
</div>
|
2016-08-03 06:55:20 +08:00
|
|
|
{/*Next Slide button aria*/}
|
2016-08-06 02:39:24 +08:00
|
|
|
<div id="nextSlideLabel">
|
2016-08-03 06:55:20 +08:00
|
|
|
<FormattedMessage
|
2017-02-24 04:20:21 +08:00
|
|
|
id="app.presentation.presentationToolbar.nextSlideLabel"
|
2016-08-03 06:55:20 +08:00
|
|
|
description="Aria label for when switching to next slide"
|
|
|
|
defaultMessage="Next slide"
|
|
|
|
/>
|
2016-08-06 02:39:24 +08:00
|
|
|
</div>
|
|
|
|
<div id="nextSlideDescrip">
|
2016-08-03 06:55:20 +08:00
|
|
|
<FormattedMessage
|
2017-02-24 04:20:21 +08:00
|
|
|
id="app.presentation.presentationToolbar.nextSlideDescrip"
|
2016-08-03 06:55:20 +08:00
|
|
|
description="Aria description for when switching to next slide"
|
|
|
|
defaultMessage="Change the presentation to the next slide"
|
|
|
|
/>
|
2016-08-06 02:39:24 +08:00
|
|
|
</div>
|
2016-08-03 06:55:20 +08:00
|
|
|
{/*Skip Slide drop down aria*/}
|
2016-08-06 02:39:24 +08:00
|
|
|
<div id="skipSlideLabel">
|
2016-08-03 06:55:20 +08:00
|
|
|
<FormattedMessage
|
2017-02-24 04:20:21 +08:00
|
|
|
id="app.presentation.presentationToolbar.skipSlideLabel"
|
2016-08-03 06:55:20 +08:00
|
|
|
description="Aria label for when switching to a specific slide"
|
|
|
|
defaultMessage="Skip slide"
|
|
|
|
/>
|
2016-08-06 02:39:24 +08:00
|
|
|
</div>
|
|
|
|
<div id="skipSlideDescrip">
|
2016-08-03 06:55:20 +08:00
|
|
|
<FormattedMessage
|
2017-02-24 04:20:21 +08:00
|
|
|
id="app.presentation.presentationToolbar.skipSlideDescrip"
|
2016-08-03 06:55:20 +08:00
|
|
|
description="Aria description for when switching to a specific slide"
|
|
|
|
defaultMessage="Change the presentation to a specific slide"
|
|
|
|
/>
|
2016-08-06 02:39:24 +08:00
|
|
|
</div>
|
2016-08-03 06:55:20 +08:00
|
|
|
{/*Fit to width button aria*/}
|
2016-08-06 02:39:24 +08:00
|
|
|
<div id="fitWidthLabel">
|
2016-08-03 06:55:20 +08:00
|
|
|
<FormattedMessage
|
2017-02-24 04:20:21 +08:00
|
|
|
id="app.presentation.presentationToolbar.fitWidthLabel"
|
2016-08-03 06:55:20 +08:00
|
|
|
description="Aria description to display the whole width of the slide"
|
|
|
|
defaultMessage="Fit to width"
|
|
|
|
/>
|
2016-08-06 02:39:24 +08:00
|
|
|
</div>
|
|
|
|
<div id="fitWidthDescrip">
|
2016-08-03 06:55:20 +08:00
|
|
|
<FormattedMessage
|
2017-02-24 04:20:21 +08:00
|
|
|
id="app.presentation.presentationToolbar.fitWidthDescrip"
|
2016-08-03 06:55:20 +08:00
|
|
|
description="Aria description to display the whole width of the slide"
|
|
|
|
defaultMessage="Display the whole width of the slide"
|
|
|
|
/>
|
2016-08-06 02:39:24 +08:00
|
|
|
</div>
|
2016-08-03 06:55:20 +08:00
|
|
|
{/*Fit to screen button aria*/}
|
2016-08-06 02:39:24 +08:00
|
|
|
<div id="fitScreenLabel">
|
2016-08-03 06:55:20 +08:00
|
|
|
<FormattedMessage
|
2017-02-24 04:20:21 +08:00
|
|
|
id="app.presentation.presentationToolbar.fitScreenLabel"
|
2016-08-03 06:55:20 +08:00
|
|
|
description="Aria label to display the whole slide"
|
|
|
|
defaultMessage="Fit to screen"
|
|
|
|
/>
|
2016-08-06 02:39:24 +08:00
|
|
|
</div>
|
|
|
|
<div id="fitScreenDescrip">
|
2016-08-03 06:55:20 +08:00
|
|
|
<FormattedMessage
|
2017-02-24 04:20:21 +08:00
|
|
|
id="app.presentation.presentationToolbar.fitScreenDescrip"
|
2016-08-03 06:55:20 +08:00
|
|
|
description="Aria label to display the whole slide"
|
|
|
|
defaultMessage="Display the whole slide"
|
|
|
|
/>
|
2016-08-06 02:39:24 +08:00
|
|
|
</div>
|
2016-08-03 06:55:20 +08:00
|
|
|
{/*Zoom slider aria*/}
|
2016-08-06 02:39:24 +08:00
|
|
|
<div id="zoomLabel">
|
2016-08-03 06:55:20 +08:00
|
|
|
<FormattedMessage
|
2017-02-24 04:20:21 +08:00
|
|
|
id="app.presentation.presentationToolbar.zoomLabel"
|
2016-08-03 06:55:20 +08:00
|
|
|
description="Aria label to zoom presentation"
|
|
|
|
defaultMessage="Zoom"
|
|
|
|
/>
|
2016-08-06 02:39:24 +08:00
|
|
|
</div>
|
|
|
|
<div id="zoomDescrip">
|
2016-08-03 06:55:20 +08:00
|
|
|
<FormattedMessage
|
2017-02-24 04:20:21 +08:00
|
|
|
id="app.presentation.presentationToolbar.zoomDescrip"
|
2016-08-03 06:55:20 +08:00
|
|
|
description="Aria label to zoom presentation"
|
|
|
|
defaultMessage="Change the zoom level of the presentation"
|
|
|
|
/>
|
2016-08-06 02:39:24 +08:00
|
|
|
</div>
|
2016-08-03 06:55:20 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2017-02-17 06:14:10 +08:00
|
|
|
|
2017-02-24 04:20:21 +08:00
|
|
|
export default injectIntl(PresentationToolbar);
|