{% extends base_template %}
{% load seahub_tags avatar_tags i18n %}
{% load url from future %}

{% block extra_style %}
{% include 'snippets/file_view_style.html' %}
{% endblock %}

{% block main_panel %}
    <div id="view-hd">
      {% block view_hd %}
        <h2>
          {{file_name}}
          <span class="commit-time">({{ current_commit.props.ctime|tsstr_sec }})</span>
        </h2>
      {% endblock %}
    </div>

    <div id="file">
        <div id="file-op">
            <p class="history-file-path fleft">
              {% block file_path %}
                {% trans "Current Path: "%}
                {% for name, link in zipped %}
                    {% if not forloop.last %} {{ name }} / {% else %} {{ name }} {% endif %}
                {% endfor %}
              {% endblock %}
            </p>

            <a class="btn-link" href="{% url 'download_file' repo.id obj_id%}?file_name={{ file_name|urlencode }}&p={{path|urlencode}}" id="download">{% trans "Download"%}</a>
        </div>
        {% include 'snippets/file_content_html.html' %}
    </div>
{% endblock %}

{% block extra_script %}
{% include "snippets/file_view_js.html" %}
<script type="text/javascript">
$(function() {
    var dld_url = $('#download').attr('href');
    $('#file-view-tip').append('<a href="' + dld_url + '" class="big-obv-btn">' + "{% trans "Download" %}" + '</a>');
});

{% if filetype == 'PDF' and use_pdfjs %}
{% else %}
function setFileViewAreaHeight() {
    var file_view = $('#file-view');
    if ($(window).height() > file_view.outerHeight(true) + file_view.offset().top) {
        file_view.outerHeight($(window).height() - file_view.offset().top);
    }
}
$(window).load(setFileViewAreaHeight).resize(setFileViewAreaHeight);
{% endif %}

{% include "snippets/file_content_js.html" %}
</script>
{% endblock %}
