{% load i18n %}

<div class="attach fileupload">
  <div class="btn fileinput-button">
    <i class="icon-plus icon-white"></i>
    
    {% if button_label %}
    <span>{{ button_label }}</span>
    {% else %}
    {% if multiple %}
    <span>{% trans "Select files" %}</span>
    {% else %}
    {% if attachments %}
    <span>{% trans "Replace file" %}</span>
    {% else %}
    <span>{% trans "Select file" %}</span>
    {% endif %}
    {% endif %}
    {% endif %}

    <input type="file" 
           {% if multiple %}
           multiple="true"
           {% endif %}
           name="{{ name }}_upload"
           {% if show_progress %}
           data-progress="#progress_{{ name }}"
           {% endif %}
           data-attachmenttype="document"
           data-valuefield="#id_{{ name }}"
           data-uploadurl="{{ upload_url }}"
           data-target="#uploads_{{ name }}" />
    
    <input class="value-list" id="id_{{ name }}" name="{{ name }}" type="hidden" 
           value="{{ value }}" />
    
  </div>
  
  {% if show_progress %}
  <div id="progress_{{ name }}" 
       class="progress progress-info hide">
    <div class="bar"></div>
  </div>
  {% endif %}

  <ul class="unstyled uploaded-files" id="uploads_{{ name }}">
    {% for att in attachments %}
    <li class="editable">
      
      <img src="{{ object.thumbnail_url }}" />
      {{ att.title }}
      
      <span class="controls pull-right">
        <a class="edit-inline"
           href="{% url 'pgcontent_edit_documentattachment' att.id %}">
          {% trans "Edit" %}
        </a>
        <a href="#" data-value="{{ att.id }}" 
           class="delete">
          {% trans "Remove" %}
        </a>
      </span>

    </li>
    {% endfor %}
  </ul>

</div>
