// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. var UserStore = require('../stores/user_store.jsx'); export default class GetLinkModal extends React.Component { constructor(props) { super(props); this.handleClick = this.handleClick.bind(this); this.state = {copiedLink: false}; } componentDidMount() { if (this.refs.modal) { $(React.findDOMNode(this.refs.modal)).on('show.bs.modal', function show(e) { var button = e.relatedTarget; this.setState({title: $(button).attr('data-title'), value: $(button).attr('data-value')}); }.bind(this)); $(React.findDOMNode(this.refs.modal)).on('hide.bs.modal', function hide() { this.setState({copiedLink: false}); }.bind(this)); } } handleClick() { var copyTextarea = $(React.findDOMNode(this.refs.textarea)); copyTextarea.select(); try { var successful = document.execCommand('copy'); if (successful) { this.setState({copiedLink: true}); } else { this.setState({copiedLink: false}); } } catch (err) { this.setState({copiedLink: false}); } } render() { var currentUser = UserStore.getCurrentUser(); var copyLinkConfirm = null; if (this.state.copiedLink) { copyLinkConfirm =

Link copied to clipboard.

; } if (currentUser != null) { return (