{% extends "admin/change_form.html" %}
{% load i18n admin_static admin_modify admin_urls %}

{% block extrahead %}
  {{ block.super }}
  {% url 'admin:jsi18n' as jsi18nurl %}
  <script type="text/javascript" src="{{ jsi18nurl|default:"../../../jsi18n/" }}"></script>
{% endblock %}

{% block object-tools-items %}
  {{ block.super }}

  {% if change and has_add_permission and not is_popup %}
    <li>
      <a href="../add/">
        {% blocktrans with opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
      </a>
    </li>
  {% endif %}
{% endblock %}

{% block footer %}
  {% if has_absolute_url %}
    <div class="submit-row sharing-links">
      <h3>Share this on:</h3>
      <input 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 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 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 input').each(function() {
      var $ = jQuery;
      $(this).click(function(ev) {
        ev.preventDefault();
        var url = $(this).attr('name');
        window.open(url, '_blank', 'height=400,width=600,menubar=no,status=no,toolbar=no');
      })
    });
    </script>
    <style>
      .sharing-links {
        padding: 20px;
      }

      .sharing-links input {
        cursor: pointer;
      }
    </style>
  {% endif %}
{% endblock %}
