2016-04-29 03:02:51 +08:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
import { createContainer } from 'meteor/react-meteor-data';
|
2016-05-20 21:46:30 +08:00
|
|
|
import Media from './component';
|
2016-05-28 09:10:34 +08:00
|
|
|
import MediaService from './service';
|
2016-05-20 21:37:19 +08:00
|
|
|
import Button from '../button/component';
|
2016-05-20 21:44:27 +08:00
|
|
|
import WhiteboardContainer from '../whiteboard/container';
|
|
|
|
import VideoDockContainer from '../video-dock/container';
|
2016-05-28 09:10:34 +08:00
|
|
|
import DefaultContent from '../whiteboard/default-content/component';
|
2016-05-04 04:40:46 +08:00
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
overlay: <VideoDockContainer/>,
|
|
|
|
content: <WhiteboardContainer/>,
|
2016-05-28 09:10:34 +08:00
|
|
|
defaultContent: <DefaultContent />,
|
2016-05-04 04:40:46 +08:00
|
|
|
};
|
|
|
|
|
2016-05-03 06:42:54 +08:00
|
|
|
class MediaContainer extends Component {
|
2016-04-29 03:02:51 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2016-05-28 09:10:34 +08:00
|
|
|
const { overlay, content, defaultContent } = this.props;
|
2016-05-04 04:40:46 +08:00
|
|
|
this.state = {
|
|
|
|
overlay: overlay,
|
2016-05-31 01:33:35 +08:00
|
|
|
content: this.props.current_presentation ? content : defaultContent,
|
2016-05-04 04:40:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
this.handleToggleLayout = this.handleToggleLayout.bind(this);
|
|
|
|
}
|
2016-05-31 01:33:35 +08:00
|
|
|
|
2016-05-28 09:10:34 +08:00
|
|
|
componentWillReceiveProps(nextProps) {
|
2016-05-31 06:07:02 +08:00
|
|
|
if (nextProps.current_presentation != this.props.current_presentation) {
|
|
|
|
if (nextProps.current_presentation) {
|
2016-05-28 09:10:34 +08:00
|
|
|
this.setState({ content: this.props.content });
|
2016-05-31 06:07:02 +08:00
|
|
|
} else {
|
2016-05-28 09:10:34 +08:00
|
|
|
this.setState({ content: this.props.defaultContent });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
handleToggleLayout() {
|
|
|
|
const { overlay, content } = this.state;
|
|
|
|
this.setState({ overlay: content, content: overlay });
|
2016-04-29 03:02:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2016-06-02 07:37:51 +08:00
|
|
|
/* an example of toggleLayout button
|
2016-05-20 21:37:19 +08:00
|
|
|
<Button
|
|
|
|
label="Toggle Layout"
|
|
|
|
style={{ position: 'absolute', top: '10px', left: '10px' }}
|
|
|
|
onClick={this.handleToggleLayout} />
|
2016-06-02 07:37:51 +08:00
|
|
|
*/
|
|
|
|
return (
|
|
|
|
<Media overlay={this.state.overlay} content={this.state.content}>
|
2016-04-29 03:02:51 +08:00
|
|
|
{this.props.children}
|
2016-05-03 06:42:54 +08:00
|
|
|
</Media>
|
2016-04-29 03:02:51 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
MediaContainer.defaultProps = defaultProps;
|
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
export default createContainer(() => {
|
2016-05-28 09:10:34 +08:00
|
|
|
const data = MediaService.getPresentationInfo();
|
|
|
|
return data;
|
2016-05-03 06:42:54 +08:00
|
|
|
}, MediaContainer);
|