diff --git a/js/app.js b/js/app.js index c9451e47..520bedbd 100644 --- a/js/app.js +++ b/js/app.js @@ -30,6 +30,7 @@ import GoogleAnalyticsHandler from './third_party/ga'; import RavenHandler from './third_party/raven'; import IntercomHandler from './third_party/intercom'; import NotificationsHandler from './third_party/notifications'; +import FacebookHandler from './third_party/facebook'; /* eslint-enable */ initLogging(); diff --git a/js/components/ascribe_collapsible/collapsible_button.js b/js/components/ascribe_collapsible/collapsible_button.js index 6fb39c71..caf89df3 100644 --- a/js/components/ascribe_collapsible/collapsible_button.js +++ b/js/components/ascribe_collapsible/collapsible_button.js @@ -21,13 +21,13 @@ let CollapsibleButton = React.createClass({ this.setState({expanded: !this.state.expanded}); }, render() { - let isVisible = (this.state.expanded) ? '' : 'invisible'; + let isHidden = (this.state.expanded) ? '' : 'hidden'; return ( {this.props.button} -
+
{this.props.panel}
diff --git a/js/components/ascribe_detail/media_container.js b/js/components/ascribe_detail/media_container.js index d31a205f..c6845a44 100644 --- a/js/components/ascribe_detail/media_container.js +++ b/js/components/ascribe_detail/media_container.js @@ -7,10 +7,18 @@ import Glyphicon from 'react-bootstrap/lib/Glyphicon'; import MediaPlayer from './../ascribe_media/media_player'; +import FacebookShareButton from '../ascribe_social_share/facebook_share_button'; +import TwitterShareButton from '../ascribe_social_share/twitter_share_button'; + import CollapsibleButton from './../ascribe_collapsible/collapsible_button'; import AclProxy from '../acl_proxy'; +import UserActions from '../../actions/user_actions'; +import UserStore from '../../stores/user_store'; + +import { mergeOptions } from '../../utils/general_utils.js'; +import { getLangText } from '../../utils/lang_utils.js'; const EMBED_IFRAME_HEIGHT = { video: 315, @@ -24,10 +32,17 @@ let MediaContainer = React.createClass({ }, getInitialState() { - return {timerId: null}; + return mergeOptions( + UserStore.getState(), + { + timerId: null + }); }, componentDidMount() { + UserStore.listen(this.onChange); + UserActions.fetchCurrentUser(); + if (!this.props.content.digital_work) { return; } @@ -45,19 +60,32 @@ let MediaContainer = React.createClass({ }, componentWillUnmount() { + UserStore.unlisten(this.onChange); + window.clearInterval(this.state.timerId); }, + onChange(state) { + this.setState(state); + }, + render() { - let thumbnail = this.props.content.thumbnail.thumbnail_sizes && this.props.content.thumbnail.thumbnail_sizes['600x600'] ? - this.props.content.thumbnail.thumbnail_sizes['600x600'] : this.props.content.thumbnail.url_safe; - let mimetype = this.props.content.digital_work.mime; + const { content } = this.props; + // Pieces and editions are joined to the user by a foreign key in the database, so + // the information in content will be updated if a user updates their username. + // We also force uniqueness of usernames, so this check is safe to dtermine if the + // content was registered by the current user. + const didUserRegisterContent = this.state.currentUser && (this.state.currentUser.username === content.user_registered); + + let thumbnail = content.thumbnail.thumbnail_sizes && content.thumbnail.thumbnail_sizes['600x600'] ? + content.thumbnail.thumbnail_sizes['600x600'] : content.thumbnail.url_safe; + let mimetype = content.digital_work.mime; let embed = null; let extraData = null; - let isEmbedDisabled = mimetype === 'video' && this.props.content.digital_work.isEncoding !== undefined && this.props.content.digital_work.isEncoding !== 100; + let isEmbedDisabled = mimetype === 'video' && content.digital_work.isEncoding !== undefined && content.digital_work.isEncoding !== 100; - if (this.props.content.digital_work.encoding_urls) { - extraData = this.props.content.digital_work.encoding_urls.map(e => { return { url: e.url, type: e.label }; }); + if (content.digital_work.encoding_urls) { + extraData = content.digital_work.encoding_urls.map(e => { return { url: e.url, type: e.label }; }); } if (['video', 'audio'].indexOf(mimetype) > -1) { @@ -73,7 +101,7 @@ let MediaContainer = React.createClass({ panel={
                             {''}
+                                + content.bitcoin_id + '" frameborder="0" allowfullscreen>'}
                         
}/> ); @@ -83,13 +111,19 @@ let MediaContainer = React.createClass({ + encodingStatus={content.digital_work.isEncoding} />

+ + + + +