diff options
Diffstat (limited to 'web/react/components/post_attachment_oembed.jsx')
-rw-r--r-- | web/react/components/post_attachment_oembed.jsx | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/web/react/components/post_attachment_oembed.jsx b/web/react/components/post_attachment_oembed.jsx deleted file mode 100644 index d76e5f02e..000000000 --- a/web/react/components/post_attachment_oembed.jsx +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -export default class PostAttachmentOEmbed extends React.Component { - constructor(props) { - super(props); - this.fetchData = this.fetchData.bind(this); - - this.isLoading = false; - } - - componentWillMount() { - this.setState({data: {}}); - } - - componentWillReceiveProps(nextProps) { - if (nextProps.link !== this.props.link) { - this.isLoading = false; - this.fetchData(nextProps.link); - } - } - - componentDidMount() { - this.fetchData(this.props.link); - } - - fetchData(link) { - if (!this.isLoading) { - this.isLoading = true; - let url = 'https://noembed.com/embed?nowrap=on'; - url += '&url=' + encodeURIComponent(link); - url += '&maxheight=' + this.props.provider.height; - return $.ajax({ - url, - dataType: 'jsonp', - success: (result) => { - this.isLoading = false; - if (result.error) { - this.setState({data: {}}); - } else { - this.setState({data: result}); - } - }, - error: () => { - this.setState({data: {}}); - } - }); - } - return null; - } - - render() { - let data = {}; - let content; - if ($.isEmptyObject(this.state.data)) { - content = <div style={{height: this.props.provider.height}}/>; - } else { - data = this.state.data; - content = ( - <div - style={{height: this.props.provider.height}} - dangerouslySetInnerHTML={{__html: data.html}} - /> - ); - } - - return ( - <div - className='attachment attachment--oembed' - ref='attachment' - > - <div className='attachment__content'> - <div - className={'clearfix attachment__container'} - > - <h1 - className='attachment__title' - > - <a - className='attachment__title-link' - href={data.url} - target='_blank' - > - {data.title} - </a> - </h1> - <div > - <div - className={'attachment__body attachment__body--no_thumb'} - > - {content} - </div> - </div> - </div> - </div> - </div> - ); - } -} - -PostAttachmentOEmbed.propTypes = { - link: React.PropTypes.string.isRequired, - provider: React.PropTypes.object.isRequired -}; |