1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-20 02:48:51 +00:00

[repo_view_file]modified file-view from file_revisions;clean code

This commit is contained in:
llj
2012-09-22 11:37:01 +08:00
parent b8079d6ea5
commit a3e78bcfa4

View File

@@ -7,16 +7,25 @@
{% endblock %} {% endblock %}
{% block main_panel %} {% block main_panel %}
<h2> {% if not view_history %}
{% if not view_history %} <h2>{{ u_filename }}</h2>
{{ u_filename }} {% else %}
{% else %} {% if page_from == 'snapshot' %}
{{repo.props.name}} <h2>
{% if page_from == 'snapshot' %}镜像浏览{% endif %} {{repo.props.name}} 镜像浏览
{% if page_from == 'file_history' %}历史浏览{% endif %} <span class="commit-time">({{ current_commit.props.ctime|tsstr_sec }})</span>
<span class="commit-time">({{ current_commit.props.ctime|tsstr_sec }})</span> </h2>
{% endif %} {% endif %}
</h2> {% if page_from == 'file_history' %}
<div class="w100 ovhd">
<h2 class="fleft">
{{repo.props.name}} 历史浏览
<span class="commit-time">({{ current_commit.props.ctime|tsstr_sec }})</span>
</h2>
<button class="fright" data="{% url 'file_revisions' repo.id %}?p={{ path|urlencode }}" id="back">返回文件版本列表</button>
</div>
{% endif %}
{% endif %}
<div class="w100 ovhd"> <div class="w100 ovhd">
<p class="path fleft"> <p class="path fleft">
当前路径: 当前路径:
@@ -32,11 +41,7 @@
<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/?p={{ link|urlencode }}">{{ name }}</a> / <a href="{{ SITE_ROOT }}repo/{{ repo.id }}/?p={{ link|urlencode }}">{{ name }}</a> /
{% endif %} {% endif %}
{% else %} {% else %}
{% if view_history and page_from == 'file_history' %}
<a href="{% url 'file_revisions' repo.id %}?p={{ link|urlencode }}" title="返回文件历史列表">{{ name }}</a>
{% else %}
{{ name }} {{ name }}
{% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</p> </p>
@@ -160,11 +165,8 @@
$('#view-original, #download').click(function() { $('#view-original, #download').click(function() {
window.open($(this).attr('data')); window.open($(this).attr('data'));
}); });
$('#history').click(function() {
location.href = $(this).attr('data');
});
{% if not view_history %} {% if not view_history %}
$('#edit').click(function() { $('#edit, #history').click(function() {
location.href = $(this).attr('data'); location.href = $(this).attr('data');
}); });
function showLink() { function showLink() {
@@ -337,8 +339,6 @@ $('#file-comment-form .submit').click(function() {
}); });
{% endif %} {% endif %}
{% endif %}
function send_open_local_file_request(path) { function send_open_local_file_request(path) {
var callback = 'xx'; var callback = 'xx';
$.ajax({ $.ajax({
@@ -381,13 +381,6 @@ $('#download-repo').click(function() {
location.href = $(this).attr('data'); location.href = $(this).attr('data');
}); });
// When user clicks 'open local file':
//
// - First, check client version to determine is this operation supported by client
// - second check whether repo exists on local machine, then:
// - if exists, send an open local file requst
// - if not exits, redirect to repo download page
$('#open-local').click(function () { $('#open-local').click(function () {
var path = $(this).attr('data'); var path = $(this).attr('data');
var local_applet_running = false; var local_applet_running = false;
@@ -420,5 +413,13 @@ $('#open-local').click(function () {
} }
}, 2000); }, 2000);
}); });
//'not view_history' ends here
{% endif %}
{% if view_history and page_from == 'file_history' %}
$('#back').click(function() {
location.href = $(this).attr('data');
});
{% endif %}
</script> </script>
{% endblock %} {% endblock %}