|
|
@ -225,21 +225,35 @@ export default class MediaGallery extends React.PureComponent { |
|
|
|
this.props.onOpenMedia(this.props.media, index); |
|
|
|
this.props.onOpenMedia(this.props.media, index); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isStandaloneEligible() { |
|
|
|
|
|
|
|
const { media, standalone } = this.props; |
|
|
|
|
|
|
|
return standalone && media.size === 1 && media.getIn([0, 'meta', 'small', 'aspect']); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
render () { |
|
|
|
const { |
|
|
|
const { media, intl, sensitive, letterbox, fullwidth } = this.props; |
|
|
|
handleClick, |
|
|
|
|
|
|
|
handleOpen, |
|
|
|
|
|
|
|
} = this; |
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
fullwidth, |
|
|
|
|
|
|
|
intl, |
|
|
|
|
|
|
|
letterbox, |
|
|
|
|
|
|
|
media, |
|
|
|
|
|
|
|
sensitive, |
|
|
|
|
|
|
|
standalone, |
|
|
|
|
|
|
|
} = this.props; |
|
|
|
|
|
|
|
const { visible } = this.state; |
|
|
|
const { visible } = this.state; |
|
|
|
const size = media.take(4).size; |
|
|
|
const size = media.take(4).size; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let children; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!visible) { |
|
|
|
|
|
|
|
let warning = <FormattedMessage {...(sensitive ? messages.warning : messages.hidden)} />; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
children = ( |
|
|
|
|
|
|
|
<button className='media-spoiler' type='button' onClick={this.handleOpen}> |
|
|
|
|
|
|
|
<span className='media-spoiler__warning'>{warning}</span> |
|
|
|
|
|
|
|
<span className='media-spoiler__trigger'><FormattedMessage {...messages.toggle} /></span> |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (this.isStandaloneEligible()) { |
|
|
|
|
|
|
|
children = <Item standalone attachment={media.get(0)} onClick={this.handleClick} />; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
children = media.take(4).map((attachment, i) => <Item key={attachment.get('id')} onClick={this.handleClick} attachment={attachment} index={i} size={size} letterbox={letterbox} />); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const computedClass = classNames('media-gallery', `size-${size}`, { 'full-width': fullwidth }); |
|
|
|
const computedClass = classNames('media-gallery', `size-${size}`, { 'full-width': fullwidth }); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
@ -248,7 +262,7 @@ export default class MediaGallery extends React.PureComponent { |
|
|
|
<div className='sensitive-info'> |
|
|
|
<div className='sensitive-info'> |
|
|
|
<IconButton |
|
|
|
<IconButton |
|
|
|
icon='eye' |
|
|
|
icon='eye' |
|
|
|
onClick={handleOpen} |
|
|
|
onClick={this.handleOpen} |
|
|
|
overlay |
|
|
|
overlay |
|
|
|
title={intl.formatMessage(messages.toggle_visible)} |
|
|
|
title={intl.formatMessage(messages.toggle_visible)} |
|
|
|
/> |
|
|
|
/> |
|
|
@ -259,46 +273,8 @@ export default class MediaGallery extends React.PureComponent { |
|
|
|
) : null} |
|
|
|
) : null} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) : null} |
|
|
|
) : null} |
|
|
|
{function () { |
|
|
|
|
|
|
|
switch (true) { |
|
|
|
{children} |
|
|
|
case !visible: |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<button |
|
|
|
|
|
|
|
className='media-spoiler' |
|
|
|
|
|
|
|
type='button' |
|
|
|
|
|
|
|
onClick={handleOpen} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<span className='media-spoiler__warning'> |
|
|
|
|
|
|
|
<FormattedMessage {...(sensitive ? messages.warning : messages.hidden)} /> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
<span className='media-spoiler__trigger'> |
|
|
|
|
|
|
|
<FormattedMessage {...messages.toggle} /> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
case standalone && media.size === 1 && !!media.getIn([0, 'meta', 'small', 'aspect']): |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<Item |
|
|
|
|
|
|
|
attachment={media.get(0)} |
|
|
|
|
|
|
|
onClick={handleClick} |
|
|
|
|
|
|
|
standalone |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return media.take(4).map( |
|
|
|
|
|
|
|
(attachment, i) => ( |
|
|
|
|
|
|
|
<Item |
|
|
|
|
|
|
|
attachment={attachment} |
|
|
|
|
|
|
|
index={i} |
|
|
|
|
|
|
|
key={attachment.get('id')} |
|
|
|
|
|
|
|
letterbox={letterbox} |
|
|
|
|
|
|
|
onClick={handleClick} |
|
|
|
|
|
|
|
size={size} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}()} |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|