{% import "shelf-library-modal-macros.html" as macros with context %}
<div class="modal-dialog">
    <div class="modal-content modal_file_selector" style='border-radius: 0px'>
        <div class="modal-header">
            <button aria-hidden="true" data-dismiss="modal" class="close" type="button"><i class="fa fa-times fa-lg"></i></button>
            <h1 class="modalBiblio--title">{{ _gettext("Choose") }}</h1>
            <div class="modalBiblio--arborescence">
                <span>{{ _gettext("Root") }}</span><span>{{ dir_path }}</span>
            </div>
        </div>
        {% if dir_path %}
        <a class="modalBiblio--backParent xhr_link" href="{{ get_dir_url('.modal_index', parent_path)|safe }}"><i class="fa fa-arrow-circle-o-left"></i>Dossier parent</a>
        {% endif %}
        <div class="modal-body" style="padding: 0px; overflow: hidden">
            <table class="table table-hover model-list modal-img">
                {% for name, path, is_dir, size, dimensions in items %}
                <tr {% if not is_dir %}class="modal_file_element" data-url="{{ get_file_url(path)|safe }}" data-path="{{ path }}"{% endif %}{% if dimensions[0] %} data-width="{{ dimensions[0] }}" data-height="{{ dimensions[1] }}"{% endif %}>
                    {% if is_dir %}
                        <td>
                            <i style="width: 20px" class="fa fa-folder"></i>
                            <a href="{{ get_dir_url('.modal_index', path)|safe }}" class="xhr_link">
                                <span>{{ name }}</span>
                                <span class="detail"><!--(nombre de sous-éléments)--></span>
                            </a>
                        </td>
                    {% else %}
                        <td>
                            {% set icons_by_mime = {'image': 'fa-picture-o', 'text': 'fa-file-text', 'video': 'fa-film', 'other': 'fa-file', 'archive': 'fa-save'} %}
                            <i style="width: 20px" class="fa {{ icons_by_mime[mimes[path]] }}"></i>
                            <span class="link-file">
                                <span>{{ name }}</span>
                                <span class="detail">({{ size }}{% if dimensions[0] %}, {{ dimensions[0] }}&times;{{ dimensions[1] }}&nbsp;px{% endif %})</span>
                            </span>
                        </td>
                    {% endif %}
                </tr>
                {% endfor %}
            </table>
        </div>
        {{ macros.library_modal_footer(dir_path) }}
    </div>
</div>