{% extends "documents/base.html" %}
{% load i18n %}

{% block add_css %}
    <link rel="stylesheet" href="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/css/jquery.fileupload.css" />
    <link rel="stylesheet" href="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/css/jquery.fileupload-ui.css" />
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
    <!-- CSS adjustments for browsers with JavaScript disabled -->
    <noscript
      ><link rel="stylesheet" href="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/css/jquery.fileupload-noscript.css"
    /></noscript>
    <noscript
      ><link rel="stylesheet" href="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/css/jquery.fileupload-ui-noscript.css"
             /></noscript>
{% endblock %}


{% block content %}
<h1>
{% trans "Browse:" %}
{% for crumb in view.breadcrumbs %}
    {% if crumb.1 %}
        <a href="{{ crumb.1 }}">{{ crumb.0 }}</a>
    {% else %}
        {{ crumb.0 }}
    {% endif %}
    {% if not forloop.last %}/{% endif %}
{% endfor %}
</h1>

{% block note %}{% endblock %}


    <form id="fileupload" method="post" action="." enctype="multipart/form-data">{% csrf_token %}
        <div class="row fileupload-buttonbar">
            <div class="col-lg-7">
            <!-- The fileinput-button span is used to style the file input field as button -->
                <span class="btn btn-success fileinput-button">
                    <i class="fas fa-plus"></i>
                    <span>{% trans "Add files..." %}</span>
                    <input type="file" name="files[]" multiple />
                </span>
                <button class="btn btn-primary start" type="submit">
                    <i class="fas fa-upload"></i>
                    <span>{% trans "Start upload" %}</span>
                </button>
                <button class="btn btn-warning cancel" type="reset">
                    <i class="fas fa-ban"></i>
                    <span>{% trans "Cancel upload" %}</span>
                </button>
                <button class="btn btn-danger delete" type="button">
                    <i class="fas fa-trash"></i>
                    <span>{% trans "Delete" %}</span>
                </button>
                <input type="checkbox" class="toggle" />
                <!-- The global file processing state -->
                <span class="fileupload-process"></span>
            </div>
            <!-- The global progress state -->
            <div class="col-lg-5 fileupload-progress fade">
                <!-- The global progress bar -->
                <div
                  class="progress progress-striped active"
                  role="progressbar"
                  aria-valuemin="0"
                  aria-valuemax="100"
                >
                  <div
                    class="progress-bar progress-bar-success"
                    style="width: 0%;"
                  ></div>
                </div>
                <!-- The extended global progress state -->
                <div class="progress-extended">&nbsp;</div>
              </div>
            </div>
            <!-- The table listing the files available for upload/download -->
            <table role="presentation" class="table table-striped">
              <tbody class="files"></tbody>
            </table>
        </div>
    </form>

{% endblock %}


{% block add_js %}

{% verbatim %}
    <script id="template-upload" type="text/x-tmpl">
      {% for (var i=0, file; file=o.files[i]; i++) { %}
          <tr class="template-upload fades{%=o.options.loadImageFileTypes.test(file.type)?' image':''%}">
              <td>
                  <span class="preview"></span>
              </td>
              <td>
                  <p class="name">{%=file.name%}</p>
                  <strong class="error text-danger"></strong>
              </td>
              <td>
                  <p class="size">{%=o.options.messages.processing%}</p>
                  <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div>
              </td>
              <td>
                  {% if (!i && !o.options.autoUpload) { %}
                      <button class="btn btn-primary start" disabled>
                          <i class="fas fa-upload"></i>
                          <span>{%=o.options.messages.start%}</span>
                      </button>
                  {% } %}
                  {% if (!i) { %}
                      <button class="btn btn-warning cancel">
                          <i class="fas fa-ban"></i>
                          <span>{%=o.options.messages.cancel%}</span>
                      </button>
                  {% } %}
              </td>
          </tr>
      {% } %}
    </script>
    <!-- The template to display files available for download -->
    <script id="template-download" type="text/x-tmpl">
      {% for (var i=0, file; file=o.files[i]; i++) { %}
          <tr class="template-download fade{%=file.thumbnail_url?' image':''%}">
              <td>
                  <span class="preview">
                      {% if (file.thumbnail_url) { %}
                          <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery><img src="{%=file.thumbnail_url%}"></a>
                      {% } %}
                  </span>
              </td>
              <td>
                  <p class="name">
                      {% if (file.url) { %}
                          <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnail_url?'data-gallery':''%}>{%=file.name%}</a>
                      {% } else { %}
                          <span>{%=file.name%}</span>
                      {% } %}
                  </p>
                  {% if (file.error) { %}
                      <div><span class="label label-danger">{%=o.options.messages.error%}</span> {%=file.error%}</div>
                  {% } %}
              </td>
              <td>
                  <span class="size">{%=o.formatFileSize(file.size)%}</span>
              </td>
              <td>
                  {% if (file.delete_url) { %}
                      <button class="btn btn-danger delete" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
                          <i class="fas fa-trash"></i>
                          <span>{%=o.options.messages.delete%}</span>
                      </button>
                      <input type="checkbox" name="delete" value="1" class="toggle">
                  {% } else { %}
                      <button class="btn btn-warning cancel">
                          <i class="fas fa-ban"></i>
                          <span>{%=o.options.messages.cancel%}</span>
                      </button>
                  {% } %}
              </td>
          </tr>
      {% } %}
    </script>
{% endverbatim %}


    <!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
    <script src="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/js/vendor/jquery.ui.widget.js"></script>
    <!-- The Templates plugin is included to render the upload/download listings -->
    <script src="{{ STATIC_URL }}lib/JavaScript-Templates/tmpl.min.js"></script>
    <!-- The Load Image plugin is included for the preview images and image resizing functionality -->

    <script src="{{ STATIC_URL }}lib/JavaScript-Load-Image/load-image.all.min.js"></script>
    <!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
    <script src="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/js/jquery.iframe-transport.js"></script>
    <!-- The basic File Upload plugin -->
    <script src="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/js/jquery.fileupload.js"></script>
    <!-- The File Upload processing plugin -->
    <script src="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/js/jquery.fileupload-process.js"></script>
    <!-- The File Upload image preview & resize plugin -->
    <script src="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/js/jquery.fileupload-image.js"></script>
    <!-- The File Upload audio preview plugin -->
    <script src="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/js/jquery.fileupload-audio.js"></script>
    <!-- The File Upload video preview plugin -->
    <script src="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/js/jquery.fileupload-video.js"></script>
    <!-- The File Upload validation plugin -->
    <script src="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/js/jquery.fileupload-validate.js"></script>
    <!-- The File Upload user interface plugin -->
    <script src="{{ STATIC_URL }}lib/jQuery-File-Upload-10.32.0/js/jquery.fileupload-ui.js"></script>
    <!-- The main application script -->
    <script src="{{ STATIC_URL }}fileupload/js/main.js"></script>
    <script src="{{ STATIC_URL }}fileupload/js/csrf.js"></script>
{% endblock %}
