// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. var UserStore = require('../stores/user_store.jsx'); var ZeroClipboardMixin = require('react-zeroclipboard-mixin'); ZeroClipboardMixin.ZeroClipboard.config({ swfPath: '../../static/flash/ZeroClipboard.swf' }); export default class GetLinkModal extends React.Component { constructor(props) { super(props); this.zeroclipboardElementsSelector = '[data-copy-btn]'; this.mixins = [ZeroClipboardMixin]; this.handleClick = this.handleClick.bind(this); this.state = {copiedLink: false}; } componentDidMount() { var self = this; if (this.refs.modal) { $(this.refs.modal.getDOMNode()).on('show.bs.modal', function show(e) { var button = e.relatedTarget; self.setState({title: $(button).attr('data-title'), value: $(button).attr('data-value')}); }); $(this.refs.modal.getDOMNode()).on('hide.bs.modal', function hide() { self.setState({copiedLink: false}); }); } } 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 (