2017-06-04 10:40:14 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-02-17 06:14:10 +08:00
|
|
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
2017-09-26 07:45:44 +08:00
|
|
|
import injectWbResizeEvent from '/imports/ui/components/presentation/resize-wrapper/component';
|
2017-08-21 08:16:39 +08:00
|
|
|
import Button from '/imports/ui/components/button/component';
|
|
|
|
import styles from './styles.scss';
|
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-04-10 23:50:03 +08:00
|
|
|
description: 'Previous slide button label',
|
2017-02-17 06:14:10 +08:00
|
|
|
},
|
|
|
|
nextSlideLabel: {
|
2017-02-24 04:20:21 +08:00
|
|
|
id: 'app.presentation.presentationToolbar.nextSlideLabel',
|
2017-04-26 22:08:47 +08:00
|
|
|
description: 'Next slide button label',
|
2017-02-17 06:14:10 +08:00
|
|
|
},
|
2017-11-17 23:54:23 +08:00
|
|
|
goToSlide: {
|
|
|
|
id: 'app.presentation.presentationToolbar.goToSlide',
|
2017-11-14 18:41:51 +08:00
|
|
|
description: 'button for slide select',
|
|
|
|
},
|
2017-02-17 06:14:10 +08:00
|
|
|
});
|
|
|
|
|
2017-02-24 04:20:21 +08:00
|
|
|
class PresentationToolbar extends Component {
|
2017-08-21 08:16:39 +08:00
|
|
|
static renderAriaLabelsDescs() {
|
|
|
|
return (
|
|
|
|
<div hidden >
|
2017-09-07 03:36:52 +08:00
|
|
|
{/* Previous Slide button aria */}
|
2017-08-21 08:16:39 +08:00
|
|
|
<div id="prevSlideLabel">
|
|
|
|
<FormattedMessage
|
|
|
|
id="app.presentation.presentationToolbar.prevSlideLabel"
|
|
|
|
description="Aria label for when switching to previous slide"
|
|
|
|
defaultMessage="Previous slide"
|
|
|
|
/>
|
|
|
|
</div>
|
2017-09-06 09:53:51 +08:00
|
|
|
<div id="prevSlideDesc">
|
2017-08-21 08:16:39 +08:00
|
|
|
<FormattedMessage
|
2017-09-06 09:53:51 +08:00
|
|
|
id="app.presentation.presentationToolbar.prevSlideDesc"
|
2017-08-21 08:16:39 +08:00
|
|
|
description="Aria description for when switching to previous slide"
|
|
|
|
defaultMessage="Change the presentation to the previous slide"
|
|
|
|
/>
|
|
|
|
</div>
|
2017-09-07 03:36:52 +08:00
|
|
|
{/* Next Slide button aria */}
|
2017-08-21 08:16:39 +08:00
|
|
|
<div id="nextSlideLabel">
|
|
|
|
<FormattedMessage
|
|
|
|
id="app.presentation.presentationToolbar.nextSlideLabel"
|
|
|
|
description="Aria label for when switching to next slide"
|
|
|
|
defaultMessage="Next slide"
|
|
|
|
/>
|
|
|
|
</div>
|
2017-09-06 09:53:51 +08:00
|
|
|
<div id="nextSlideDesc">
|
2017-08-21 08:16:39 +08:00
|
|
|
<FormattedMessage
|
2017-09-06 09:53:51 +08:00
|
|
|
id="app.presentation.presentationToolbar.nextSlideDesc"
|
2017-08-21 08:16:39 +08:00
|
|
|
description="Aria description for when switching to next slide"
|
|
|
|
defaultMessage="Change the presentation to the next slide"
|
|
|
|
/>
|
|
|
|
</div>
|
2017-09-07 03:36:52 +08:00
|
|
|
{/* Skip Slide drop down aria */}
|
2017-08-21 08:16:39 +08:00
|
|
|
<div id="skipSlideLabel">
|
|
|
|
<FormattedMessage
|
|
|
|
id="app.presentation.presentationToolbar.skipSlideLabel"
|
|
|
|
description="Aria label for when switching to a specific slide"
|
|
|
|
defaultMessage="Skip slide"
|
|
|
|
/>
|
|
|
|
</div>
|
2017-09-06 09:53:51 +08:00
|
|
|
<div id="skipSlideDesc">
|
2017-08-21 08:16:39 +08:00
|
|
|
<FormattedMessage
|
2017-09-06 09:53:51 +08:00
|
|
|
id="app.presentation.presentationToolbar.skipSlideDesc"
|
2017-08-21 08:16:39 +08:00
|
|
|
description="Aria description for when switching to a specific slide"
|
|
|
|
defaultMessage="Change the presentation to a specific slide"
|
|
|
|
/>
|
|
|
|
</div>
|
2017-09-07 03:36:52 +08:00
|
|
|
{/* Fit to width button aria */}
|
2017-08-21 08:16:39 +08:00
|
|
|
<div id="fitWidthLabel">
|
|
|
|
<FormattedMessage
|
|
|
|
id="app.presentation.presentationToolbar.fitWidthLabel"
|
|
|
|
description="Aria description to display the whole width of the slide"
|
|
|
|
defaultMessage="Fit to width"
|
|
|
|
/>
|
|
|
|
</div>
|
2017-09-06 09:53:51 +08:00
|
|
|
<div id="fitWidthDesc">
|
2017-08-21 08:16:39 +08:00
|
|
|
<FormattedMessage
|
2017-09-06 09:53:51 +08:00
|
|
|
id="app.presentation.presentationToolbar.fitWidthDesc"
|
2017-08-21 08:16:39 +08:00
|
|
|
description="Aria description to display the whole width of the slide"
|
|
|
|
defaultMessage="Display the whole width of the slide"
|
|
|
|
/>
|
|
|
|
</div>
|
2017-09-07 03:36:52 +08:00
|
|
|
{/* Fit to screen button aria */}
|
2017-08-21 08:16:39 +08:00
|
|
|
<div id="fitScreenLabel">
|
|
|
|
<FormattedMessage
|
|
|
|
id="app.presentation.presentationToolbar.fitScreenLabel"
|
|
|
|
description="Aria label to display the whole slide"
|
|
|
|
defaultMessage="Fit to screen"
|
|
|
|
/>
|
|
|
|
</div>
|
2017-09-06 09:53:51 +08:00
|
|
|
<div id="fitScreenDesc">
|
2017-08-21 08:16:39 +08:00
|
|
|
<FormattedMessage
|
2017-09-06 09:53:51 +08:00
|
|
|
id="app.presentation.presentationToolbar.fitScreenDesc"
|
2017-08-21 08:16:39 +08:00
|
|
|
description="Aria label to display the whole slide"
|
|
|
|
defaultMessage="Display the whole slide"
|
|
|
|
/>
|
|
|
|
</div>
|
2017-09-07 03:36:52 +08:00
|
|
|
{/* Zoom slider aria */}
|
2017-08-21 08:16:39 +08:00
|
|
|
<div id="zoomLabel">
|
|
|
|
<FormattedMessage
|
|
|
|
id="app.presentation.presentationToolbar.zoomLabel"
|
|
|
|
description="Aria label to zoom presentation"
|
|
|
|
defaultMessage="Zoom"
|
|
|
|
/>
|
|
|
|
</div>
|
2017-09-06 09:53:51 +08:00
|
|
|
<div id="zoomDesc">
|
2017-08-21 08:16:39 +08:00
|
|
|
<FormattedMessage
|
2017-09-06 09:53:51 +08:00
|
|
|
id="app.presentation.presentationToolbar.zoomDesc"
|
2017-08-21 08:16:39 +08:00
|
|
|
description="Aria label to zoom presentation"
|
|
|
|
defaultMessage="Change the zoom level of the presentation"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-03 06:55:20 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = { sliderValue: 100 };
|
|
|
|
this.handleValuesChange = this.handleValuesChange.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleValuesChange(event) {
|
|
|
|
this.setState({ sliderValue: event.target.value });
|
|
|
|
}
|
|
|
|
|
2016-08-06 02:39:24 +08:00
|
|
|
fitToWidthClickHandler() {
|
2017-08-21 08:16:39 +08:00
|
|
|
this.setState({
|
|
|
|
fitToWidthValue: 'not_implemented_yet',
|
|
|
|
});
|
2016-08-03 06:55:20 +08:00
|
|
|
}
|
|
|
|
|
2016-08-06 02:39:24 +08:00
|
|
|
fitToScreenClickHandler() {
|
2017-08-21 08:16:39 +08:00
|
|
|
this.setState({
|
|
|
|
fitToScreenValue: 'not_implemented_yet',
|
|
|
|
});
|
2016-08-03 06:55:20 +08:00
|
|
|
}
|
2017-11-14 18:41:51 +08:00
|
|
|
renderSkipSlideOpts(numberOfSlides) {
|
|
|
|
// Fill drop down menu with all the slides in presentation
|
|
|
|
const { intl } = this.props;
|
|
|
|
const optionList = [];
|
|
|
|
for (let i = 1; i <= numberOfSlides; i += 1) {
|
|
|
|
optionList.push((
|
|
|
|
<option
|
|
|
|
value={i}
|
|
|
|
key={i}
|
|
|
|
>
|
|
|
|
{
|
2017-11-17 23:54:23 +08:00
|
|
|
intl.formatMessage(intlMessages.goToSlide, { 0: i })
|
2017-11-14 18:41:51 +08:00
|
|
|
}
|
|
|
|
</option>));
|
|
|
|
}
|
|
|
|
|
|
|
|
return optionList;
|
|
|
|
}
|
2016-08-03 06:55:20 +08:00
|
|
|
|
|
|
|
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}>
|
2017-08-21 08:16:39 +08:00
|
|
|
{PresentationToolbar.renderAriaLabelsDescs()}
|
2016-08-03 06:55:20 +08:00
|
|
|
<Button
|
|
|
|
role="button"
|
|
|
|
aria-labelledby="prevSlideLabel"
|
2017-08-11 00:05:51 +08:00
|
|
|
aria-describedby="prevSlideDesc"
|
2017-06-03 03:25:02 +08:00
|
|
|
disabled={!(currentSlideNum > 1)}
|
2017-11-14 18:41:51 +08:00
|
|
|
color="default"
|
|
|
|
icon="left_arrow"
|
|
|
|
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)}
|
2017-06-03 03:25:02 +08:00
|
|
|
hideLabel
|
2016-08-03 06:55:20 +08:00
|
|
|
className={styles.prevSlide}
|
|
|
|
/>
|
|
|
|
<select
|
2017-08-21 08:16:39 +08:00
|
|
|
// <select> has an implicit role of listbox, no need to define role="listbox" explicitly
|
2016-08-03 06:55:20 +08:00
|
|
|
id="skipSlide"
|
|
|
|
aria-labelledby="skipSlideLabel"
|
2017-08-11 00:05:51 +08:00
|
|
|
aria-describedby="skipSlideDesc"
|
2016-08-03 06:55:20 +08:00
|
|
|
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}
|
|
|
|
>
|
2017-11-14 18:41:51 +08:00
|
|
|
{this.renderSkipSlideOpts(numberOfSlides)}
|
2016-08-03 06:55:20 +08:00
|
|
|
</select>
|
2017-03-03 23:13:46 +08:00
|
|
|
<Button
|
|
|
|
role="button"
|
|
|
|
aria-labelledby="nextSlideLabel"
|
2017-08-11 00:05:51 +08:00
|
|
|
aria-describedby="nextSlideDesc"
|
2017-06-03 03:25:02 +08:00
|
|
|
disabled={!(currentSlideNum < numberOfSlides)}
|
2017-11-14 18:41:51 +08:00
|
|
|
color="default"
|
|
|
|
icon="right_arrow"
|
|
|
|
size="md"
|
2017-03-03 23:13:46 +08:00
|
|
|
onClick={actions.nextSlideHandler}
|
|
|
|
label={intl.formatMessage(intlMessages.nextSlideLabel)}
|
2017-06-03 03:25:02 +08:00
|
|
|
hideLabel
|
2017-03-03 23:13:46 +08:00
|
|
|
/>
|
|
|
|
|
2017-06-03 03:25:02 +08:00
|
|
|
{/* Fit to width button
|
2016-08-03 06:55:20 +08:00
|
|
|
<Button
|
|
|
|
role="button"
|
|
|
|
aria-labelledby="fitWidthLabel"
|
2017-09-06 09:53:51 +08:00
|
|
|
aria-describedby="fitWidthDesc"
|
2016-08-03 06:55:20 +08:00
|
|
|
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}
|
2017-08-21 08:16:39 +08:00
|
|
|
/> */}
|
2017-06-03 03:25:02 +08:00
|
|
|
{/* Fit to screen button
|
2016-08-03 06:55:20 +08:00
|
|
|
<Button
|
|
|
|
role="button"
|
|
|
|
aria-labelledby="fitScreenLabel"
|
2017-09-06 09:53:51 +08:00
|
|
|
aria-describedby="fitScreenDesc"
|
2016-08-03 06:55:20 +08:00
|
|
|
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}
|
2017-08-21 08:16:39 +08:00
|
|
|
/> */}
|
2017-06-03 03:25:02 +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"
|
2017-09-06 09:53:51 +08:00
|
|
|
aria-describedby="zoomDesc"
|
2016-08-03 06:55:20 +08:00
|
|
|
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>
|
2017-09-07 03:36:52 +08:00
|
|
|
</div> */}
|
2016-08-03 06:55:20 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2017-02-17 06:14:10 +08:00
|
|
|
|
2017-08-21 08:16:39 +08:00
|
|
|
PresentationToolbar.propTypes = {
|
|
|
|
// Number of current slide being displayed
|
|
|
|
currentSlideNum: PropTypes.number.isRequired,
|
|
|
|
// Total number of slides in this presentation
|
|
|
|
numberOfSlides: PropTypes.number.isRequired,
|
|
|
|
// Actions required for the presenter toolbar
|
|
|
|
actions: PropTypes.shape({
|
|
|
|
nextSlideHandler: PropTypes.func.isRequired,
|
|
|
|
previousSlideHandler: PropTypes.func.isRequired,
|
|
|
|
skipToSlideHandler: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2017-09-26 07:45:44 +08:00
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2017-08-21 08:16:39 +08:00
|
|
|
};
|
|
|
|
|
2017-09-26 07:45:44 +08:00
|
|
|
export default injectWbResizeEvent(injectIntl(PresentationToolbar));
|