about summary refs log tree commit diff
path: root/app/assets
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-01-16 11:36:02 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-01-16 11:36:02 +0100
commit2ae0fb44192d9ef00037814cfa58ef5ee6685a3f (patch)
treed8fdddda4a11cb2d7955661bbea5d7e213472dc3 /app/assets
parent0439c7d58bcdf0a7d48b95e3ae72e6df270c49af (diff)
parent144402ec7ef4d6609b3e8de5e81a63e0d8800692 (diff)
Merge branch 'sensitive' of https://github.com/blackle/mastodon into blackle-sensitive
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/components/components/media_gallery.jsx34
1 files changed, 29 insertions, 5 deletions
diff --git a/app/assets/javascripts/components/components/media_gallery.jsx b/app/assets/javascripts/components/components/media_gallery.jsx
index 9aafd8181..73adb0de9 100644
--- a/app/assets/javascripts/components/components/media_gallery.jsx
+++ b/app/assets/javascripts/components/components/media_gallery.jsx
@@ -1,12 +1,18 @@
 import ImmutablePropTypes from 'react-immutable-proptypes';
 import PureRenderMixin from 'react-addons-pure-render-mixin';
-import { FormattedMessage } from 'react-intl';
+import IconButton from './icon_button';
+import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
+
+const messages = defineMessages({
+  toggle_visible: { id: 'media_gallery.toggle_visible', defaultMessage: 'Toggle visibility' }
+});
 
 const outerStyle = {
   marginTop: '8px',
   overflow: 'hidden',
   width: '100%',
-  boxSizing: 'border-box'
+  boxSizing: 'border-box',
+  position: 'relative'
 };
 
 const spoilerStyle = {
@@ -32,6 +38,13 @@ const spoilerSubSpanStyle = {
   fontWeight: '500'
 };
 
+const spoilerButtonStyle = {
+  position: 'absolute',
+  top: '6px',
+  left: '8px',
+  zIndex: '100'
+};
+
 const MediaGallery = React.createClass({
 
   getInitialState () {
@@ -59,11 +72,11 @@ const MediaGallery = React.createClass({
   },
 
   handleOpen () {
-    this.setState({ visible: true });
+    this.setState({ visible: !this.state.visible });
   },
 
   render () {
-    const { media, sensitive } = this.props;
+    const { media, intl, sensitive } = this.props;
 
     let children;
 
@@ -135,8 +148,19 @@ const MediaGallery = React.createClass({
       });
     }
 
+    let spoilerButton;
+
+    if (sensitive) {
+      spoilerButton = (
+        <div style={spoilerButtonStyle} >
+          <IconButton title={intl.formatMessage(messages.toggle_visible)} icon={this.state.visible ? 'eye' : 'eye-slash'} onClick={this.handleOpen} />
+        </div>
+      );
+    }
+    
     return (
       <div style={{ ...outerStyle, height: `${this.props.height}px` }}>
+        {spoilerButton}
         {children}
       </div>
     );
@@ -144,4 +168,4 @@ const MediaGallery = React.createClass({
 
 });
 
-export default MediaGallery;
+export default injectIntl(MediaGallery);