{% load i18n filer_admin_tags static %}

{% spaceless %}
    <div class="filer-dropzone filer-dropzone-folder">
        <span class="filerFile">
            <a href="{{ lookup_url }}" class="related-lookup{% if object %} hidden{% endif %}" id="{{ lookup_name }}" title="{% trans 'Lookup' %}">
                <span class="fa fa-search cms-icon cms-icon-search"></span>&nbsp;
                {% trans "Choose Folder" %}
            </a>
            <img src="{% static "filer/icons/folder.svg" %}" class="thumbnail_img{% if not object %} hidden{% endif %}"/>
            <span id="{{ span_id }}" style="margin-left: 15px;">
                <span class="description_text">
                    {% if object %}
                        {{ object.pretty_logical_path }}
                    {% endif %}
                </span>
            </span>
            <a class="filerClearer {% if not object %}hidden{% endif %}" id="{{ clear_id }}" title="{% translate 'Clear' %}" href="#">
                <span class="fa fa-close filer-icon filer-icon-remove-selection"></span>
            </a>
            <div class="hidden">{{ hidden_input }}</div>
        </span>
    </div>
    <script type="text/javascript">
        'use strict';
        /* globals django */

        (function ($) {
            var clearButton = $('#{{ clear_id }}');
            var input = $('#{{ id }}');
            var folderName = $('#{{ descid }} .description_text');
            var addFolderButton = $('#{{ lookup_name }}');

            clearButton.on('click', function () {
                folderName.text('');
                input.removeAttr('value');
                folderName.closest('.filerFile').find('img').addClass('hidden');
                clearButton.addClass('hidden');
                addFolderButton.removeClass('hidden');
            });
        }(django.jQuery));
    </script>
{% endspaceless %}
