
{% if has_absolute_url %}
  <div class="sharing-links">
    <h3>Sharing links:</h3>
    <input class="copy-link" type="submit" value="Copy link">

    <input class="external-link" type="submit" value="Facebook" name="https://www.facebook.com/sharer.php?u={% if request.is_secure %}https{% else %}http{% endif %}%3A%2F%2F{{ request.META.HTTP_HOST }}{{ original.get_absolute_url|urlencode }}">
    <input class="external-link" type="submit" value="Twitter" name="https://twitter.com/share?url={% if request.is_secure %}https{% else %}http{% endif %}%3A%2F%2F{{ request.META.HTTP_HOST }}{{ original.get_absolute_url|urlencode }}&amp;text={{ original.title|urlencode }}">
    <input class="external-link" type="submit" value="LinkedIn" name="https://www.linkedin.com/shareArticle?url={% if request.is_secure %}https{% else %}http{% endif %}%3A%2F%2F{{ request.META.HTTP_HOST }}{{ original.get_absolute_url|urlencode }}&amp;title={{ original.title|urlencode }} ">
  </div>
  <script>
    jQuery('.sharing-links .external-link').each(function() {
      var $ = jQuery
      $(this).click(function(e) {
        e.preventDefault()
        var url = $(this).attr('name')
        window.open(url, '_blank', 'height=400,width=600,menubar=no,status=no,toolbar=no')
      })
    });

    var copyButton = document.querySelector('.copy-link')
    copyButton.addEventListener('click', function (e) {
      e.preventDefault()

      var tempInput = document.createElement('input')
      tempInput.style = "position: absolute; left: -1000px; top: -1000px"
      tempInput.value = 'http{% if request.is_secure %}s{% endif %}://{{ settings.SITE_DOMAIN }}{{ original.get_absolute_url|urlencode }}'
      document.body.appendChild(tempInput)

      tempInput.select()
      tempInput.setSelectionRange(0, 99999) /*For mobile devices*/

      document.execCommand('copy')

      document.body.removeChild(tempInput)
    })
  </script>
{% endif %}
