propTypes: {
src: React.PropTypes.string.isRequired,
+ time: React.PropTypes.number,
controls: React.PropTypes.bool.isRequired,
muted: React.PropTypes.bool.isRequired
},
mixins: [PureRenderMixin],
+ handleLoadedData () {
+ if (this.props.time) {
+ this.video.currentTime = this.props.time;
+ }
+ },
+
+ componentDidMount () {
+ this.video.addEventListener('loadeddata', this.handleLoadedData);
+ },
+
+ componentWillUnmount () {
+ this.video.removeEventListener('loadeddata', this.handleLoadedData);
+ },
+
+ setRef (c) {
+ this.video = c;
+ },
+
render () {
return (
- <div>
- <video src={this.props.src} autoPlay muted={this.props.muted} controls={this.props.controls} loop />
+ <div className='extended-video-player'>
+ <video
+ ref={this.setRef}
+ src={this.props.src}
+ autoPlay
+ muted={this.props.muted}
+ controls={this.props.controls}
+ loop={!this.props.controls}
+ />
</div>
);
},
activeStyle: React.PropTypes.object,
disabled: React.PropTypes.bool,
inverted: React.PropTypes.bool,
- animate: React.PropTypes.bool
+ animate: React.PropTypes.bool,
+ overlay: React.PropTypes.bool
},
getDefaultProps () {
size: 18,
active: false,
disabled: false,
- animate: false
+ animate: false,
+ overlay: false
};
},
let style = {
fontSize: `${this.props.size}px`,
width: `${this.props.size * 1.28571429}px`,
- height: `${this.props.size}px`,
+ height: `${this.props.size * 1.28571429}px`,
lineHeight: `${this.props.size}px`,
...this.props.style
};
style = { ...style, ...this.props.activeStyle };
}
+ const classes = ['icon-button'];
+
+ if (this.props.active) {
+ classes.push('active');
+ }
+
+ if (this.props.disabled) {
+ classes.push('disabled');
+ }
+
+ if (this.props.inverted) {
+ classes.push('inverted');
+ }
+
+ if (this.props.overlay) {
+ classes.push('overlayed');
+ }
+
return (
<Motion defaultStyle={{ rotate: this.props.active ? -360 : 0 }} style={{ rotate: this.props.animate ? spring(this.props.active ? -360 : 0, { stiffness: 120, damping: 7 }) : 0 }}>
{({ rotate }) =>
<button
aria-label={this.props.title}
title={this.props.title}
- className={`icon-button ${this.props.active ? 'active' : ''} ${this.props.disabled ? 'disabled' : ''} ${this.props.inverted ? 'inverted' : ''}`}
+ className={classes.join(' ')}
onClick={this.handleClick}
style={style}>
<i style={{ transform: `rotate(${rotate}deg)` }} className={`fa fa-fw fa-${this.props.icon}`} aria-hidden='true' />
const spoilerButtonStyle = {
position: 'absolute',
- top: '6px',
- left: '8px',
+ top: '4px',
+ left: '4px',
zIndex: '100'
};
return (
<div style={{ ...outerStyle, height: `${this.props.height}px` }}>
- <div style={spoilerButtonStyle}>
- <IconButton title={intl.formatMessage(messages.toggle_visible)} icon={this.state.visible ? 'eye' : 'eye-slash'} onClick={this.handleOpen} />
+ <div style={{ ...spoilerButtonStyle, display: !this.state.visible ? 'none' : 'block' }}>
+ <IconButton title={intl.formatMessage(messages.toggle_visible)} icon={this.state.visible ? 'eye' : 'eye-slash'} overlay onClick={this.handleOpen} />
</div>
{children}
const muteStyle = {
position: 'absolute',
- top: '10px',
- right: '10px',
+ top: '4px',
+ right: '4px',
color: 'white',
textShadow: "0px 1px 1px black, 1px 0px 1px black",
opacity: '0.8',
const spoilerButtonStyle = {
position: 'absolute',
- top: '6px',
- left: '8px',
+ top: '4px',
+ left: '4px',
color: 'white',
textShadow: "0px 1px 1px black, 1px 0px 1px black",
zIndex: '100'
const expandButtonStyle = {
position: 'absolute',
- bottom: '6px',
- right: '8px',
+ bottom: '4px',
+ right: '4px',
color: 'white',
textShadow: "0px 1px 1px black, 1px 0px 1px black",
zIndex: '100'
},
handleExpand () {
- const node = ReactDOM.findDOMNode(this).querySelector('video');
- node.pause();
-
- this.props.onOpenVideo(this.props.media);
+ this.video.pause();
+ this.props.onOpenVideo(this.props.media, this.video.currentTime);
},
setRef (c) {
const { media, intl, width, height, sensitive, autoplay } = this.props;
let spoilerButton = (
- <div style={spoilerButtonStyle} >
- <IconButton title={intl.formatMessage(messages.toggle_visible)} icon={this.state.visible ? 'eye' : 'eye-slash'} onClick={this.handleVisibility} />
+ <div style={{...spoilerButtonStyle, display: !this.state.visible ? 'none' : 'block'}} >
+ <IconButton overlay title={intl.formatMessage(messages.toggle_visible)} icon={this.state.visible ? 'eye' : 'eye-slash'} onClick={this.handleVisibility} />
</div>
);
let expandButton = (
<div style={expandButtonStyle} >
- <IconButton title={intl.formatMessage(messages.expand_video)} icon='expand' onClick={this.handleExpand} />
+ <IconButton overlay title={intl.formatMessage(messages.expand_video)} icon='expand' onClick={this.handleExpand} />
</div>
);
if (this.state.hasAudio) {
muteButton = (
<div style={muteStyle}>
- <IconButton title={intl.formatMessage(messages.toggle_sound)} icon={this.state.muted ? 'volume-off' : 'volume-up'} onClick={this.handleClick} />
+ <IconButton overlay title={intl.formatMessage(messages.toggle_sound)} icon={this.state.muted ? 'volume-off' : 'volume-up'} onClick={this.handleClick} />
</div>
);
}
dispatch(openModal('MEDIA', { media, index }));
},
- onOpenVideo (media) {
- dispatch(openModal('VIDEO', { media }));
+ onOpenVideo (media, time) {
+ dispatch(openModal('VIDEO', { media, time }));
},
onBlock (account) {
this.props.dispatch(openModal('MEDIA', { media, index }));
},
- handleOpenVideo (media) {
- this.props.dispatch(openModal('VIDEO', { media }));
+ handleOpenVideo (media, time) {
+ this.props.dispatch(openModal('VIDEO', { media, time }));
},
handleReport (status) {
propTypes: {
media: ImmutablePropTypes.map.isRequired,
+ time: React.PropTypes.number,
onClose: React.PropTypes.func.isRequired,
intl: React.PropTypes.object.isRequired
},
mixins: [PureRenderMixin],
render () {
- const { media, intl, onClose } = this.props;
+ const { media, intl, time, onClose } = this.props;
const url = media.get('url');
return (
<div className='modal-root__modal media-modal'>
<div>
- <IconButton title={intl.formatMessage(messages.close)} icon='times' onClick={onClose} size={16} style={closeStyle} />
- <ExtendedVideoPlayer src={url} muted={false} controls={true} />
+ <div style={closeStyle}><IconButton title={intl.formatMessage(messages.close)} icon='times' overlay onClick={onClose} /></div>
+ <ExtendedVideoPlayer src={url} muted={false} controls={true} time={time} />
</div>
</div>
);
color: $color3;
}
}
+
+ &.overlayed {
+ box-sizing: content-box;
+ background: rgba($color8, 0.6);
+ color: rgba($color5, 0.7);
+ border-radius: 4px;
+ padding: 2px;
+
+ &:hover {
+ background: rgba($color8, 0.9);
+ }
+ }
}
.text-icon-button {