{% load static i18n %}
{% templatetag openbrace %}% for (var i=0, file; file=o.files[i]; i++) { %{% templatetag closebrace %}

    <tr class="template-download fade">

        {% block JS_DOWNLOAD_TEMPLATE_PREVIEW %}
        {% templatetag openbrace %}% if (file.thumbnailUrl) { %{% templatetag closebrace %}
        <td>
            <span class="preview" data-pk="{% templatetag openbrace %}%=file.pk%{% templatetag closebrace %}">
                    <a href="{% templatetag openbrace %}%=file.url%{% templatetag closebrace %}"
                     title="{% templatetag openbrace %}%=file.name%{% templatetag closebrace %}"
                     data-gallery>
                        <img src="{% templatetag openbrace %}%=file.thumbnailUrl%{% templatetag closebrace %}">
                    </a>
            </span>
        </td>
        {% templatetag openbrace %}% } %{% templatetag closebrace %}
        {% endblock %}

        {% block JS_DOWNLOAD_TEMPLATE_DOWNLOAD %}
        <td>
            <p class="name">
                {% templatetag openbrace %}% if (file.url) { %{% templatetag closebrace %}
                    <a href="{% templatetag openbrace %}%=file.url%{% templatetag closebrace %}"
                     download="{% templatetag openbrace %}%=file.name%{% templatetag closebrace %}"
                     {% templatetag openbrace %}%=file.thumbnailUrl?'data-gallery':''%{% templatetag closebrace %}>
                     {% templatetag openbrace %}%=file.name%{% templatetag closebrace %}
                    </a>
                {% templatetag openbrace %}% } else { %{% templatetag closebrace %}
                    <span>{% templatetag openbrace %}%=file.name%{% templatetag closebrace %}</span>
                {% templatetag openbrace %}% } %{% templatetag closebrace %}
            </p>

            {% block JS_DOWNLOAD_TEMPLATE_ERROR %}
                {% templatetag openbrace %}% if (file.error) { %{% templatetag closebrace %}
                    <div><span class="label label-danger">Error</span> {% templatetag openbrace %}%=file.error%{% templatetag closebrace %}</div>
                {% templatetag openbrace %}% } %{% templatetag closebrace %}
            {% endblock %}

        </td>
        {% endblock %}

        {% templatetag openbrace %}% if (!file.error) { %{% templatetag closebrace %}

            {% block JS_DOWNLOAD_TEMPLATE_FSIZE %}
            <td>
                <span class="size">{% templatetag openbrace %}%=o.formatFileSize(Number(file.size))%{% templatetag closebrace %}</span>
            </td>
            {% endblock %}
        {% templatetag openbrace %}% } %{% templatetag closebrace %}

            {% block JS_DOWNLOAD_TEMPLATE_DELETE %}
            {% if not uploader_disabled %}
            <td>

        {% templatetag openbrace %}% if (!file.error) { %{% templatetag closebrace %}
                {% if not disable_server_side_crop %}
                {% templatetag openbrace %}% if (file.cropUrl) { %{% templatetag closebrace %}
                <a type="button"
                        class="btn btn-info btn-control edit"
                        data-toggle="modal"
                        data-action="{% templatetag openbrace %}%=file.cropUrl%{% templatetag closebrace %}"
                >
                    <i class="glyphicon glyphicon-edit"></i>
                        <span>{% trans "Edit" %}</span>
                </a>
                {% templatetag openbrace %}% } %{% templatetag closebrace %}
                {% endif %}
                    <a type="button" class="btn btn-danger delete fileinput-button input {% if uploader_disabled %} hidden disabled {% endif %}"
                            href="javascript(void(0))">
                        <i class="glyphicon glyphicon-trash"></i>
                        <span>{% trans "Delete" %}</span>
                    </a>
                    {% if upload_handler_url %}
                    <input type="checkbox" value="1" class="toggle fileinput-button input {% if uploader_disabled %} hidden disabled {% endif %}">
                    {% endif %}
            </td>
            <td class="sortableHandle hidden col-lg-1 col-md-1 col-sm-1 col-xs-1"
                 style="vertical-align: middle; text-align: center">
                    <span title="{% trans 'Drag to order' %}">
                        <i class="fa fa-sort fa-3" aria-hidden="true"></i>
                    </span>
            </td>
            {% endif %}
            {% endblock %}
        {% templatetag openbrace %}% } %{% templatetag closebrace %}
    </tr>
{% templatetag openbrace %}% } %{% templatetag closebrace %}
