{% if sharing_enabled and user.is_authenticated %}
<a class="share-email" data-popup href="." title="Partager"></a>
<div class="share-email-popup" style="display: none">
<p>Faire connaître cette page<br>
   <strong>{{ place.properties.nom }}</strong></p>
<form method="POST" action="/gnm/share/">
{% csrf_token %}
<input type="hidden" name="url" value="{{url}}">
<input type="hidden" name="name" value="{{place.properties.nom}}">
<p>Partager avec :<br>
   <input name="email" type="email" required></p>
</form>
</div>
<script>
$('.share-email').on('click', function() {
  $('.share-email-popup').dialog({
    title: 'Envoyer à un ami',
    modal: true,
    width: 'auto',
    buttons: [{text: 'Envoyer un courriel',
               click: function() {
                 var email = $('.share-email-popup input[name=email]').val();
                 if (email) {
                   $('.share-email-popup form').submit();
                   $(this).dialog('close');
                 } else {
                   $('.share-email-popup input[name=email]').focus();
                 }
               }
             }],
    close: function(event, ui) {
    }
  });
  return false;
});
</script>
{% endif %}
