'use strict';

import './styles.postcss';
import Modal from '../Modal';
import React from 'react';
import Clipboard from 'clipboard';

class ModalShare extends Modal {

  constructor(props) {
    super(props);

    this.state = {
      open: this.props.visible,
      className: 'modal-share'
    };
  }

  getContent() {
  	const url = window.location.href;
  	const iframeLink = '<iframe width="600" height="600" src="' + url + '" frameborder="0" allowfullscreen></iframe>';
    new Clipboard('.btn-copy');

    return (
    	<div>
    		<h1 className="text text-module-title -dark">Share this view</h1>
    		<p className="text text-highlighted -dark">Click and paste HTML to embed in website</p>
    		<aside className="btn-container">
    			<input id="embed-link" type="text" value={ iframeLink } readOnly="readonly" className="embed-link text text-input -primary" onFocus={ e => e.target.select() }></input>
    			<a className="btn btn-primary btn-copy" data-clipboard-target="#embed-link">Copy</a>
    		</aside>
    		<div className="share-links">
				  <span className="text text-hightlighted -dark">Share on</span>
				  <a href={ "http://www.facebook.com/sharer.php?u=" + url }>
            <svg className="icon icon-facebook -primary">
              <use xlinkHref="#icon-facebook"></use>
            </svg>
          </a>
          <a href={ "http://twitter.com/share?text=CARE&url=" + url + "&hashtags=care" }>
            <svg className="icon icon-twitter -primary">
              <use xlinkHref="#icon-twitter"></use>
            </svg>
          </a>
	    	  <a href={ "https://plus.google.com/share?url=" + url }>
            <svg className="icon icon-googleplus -primary">
              <use xlinkHref="#icon-googleplus"></use>
            </svg>
          </a>
	    	</div>
    	</div>
    );
  }
}

ModalShare.propTypes = {
  visible: React.PropTypes.bool.isRequired,
  onClose: React.PropTypes.func.isRequired
};

export default ModalShare;

@@ -1124,24 +1124,57 @@
 an%3E%0A%09%09%09%09  %3Ca
+ target=%22_blank%22 rel=%22noreferrer%22
  href=%7B %22htt
@@ -1210,32 +1210,32 @@
 hp?u=%22 + url %7D%3E%0A
-
             %3Csvg
@@ -1371,24 +1371,57 @@
           %3Ca
+ target=%22_blank%22 rel=%22noreferrer%22
  href=%7B %22htt
@@ -1625,24 +1625,24 @@
        %3C/a%3E%0A
-
 %09    %09  %3Ca h
@@ -1639,16 +1639,49 @@
    %09  %3Ca
+ target=%22_blank%22 rel=%22noreferrer%22
  href=%7B 

Add security to links