2012-07-30 10:25:46 +08:00
|
|
|
|
{% extends base_template %}
|
2012-08-26 11:48:43 +08:00
|
|
|
|
{% load seahub_tags avatar_tags%}
|
2012-08-13 15:58:54 +08:00
|
|
|
|
{% load url from future %}
|
2012-07-02 22:45:21 +08:00
|
|
|
|
|
2012-09-13 16:36:23 +08:00
|
|
|
|
{% block extra_style %}
|
|
|
|
|
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}codemirror/codemirror.css" />
|
|
|
|
|
{% endblock %}
|
|
|
|
|
|
2012-08-13 17:40:27 +08:00
|
|
|
|
{% block main_panel %}
|
2012-09-22 11:37:01 +08:00
|
|
|
|
{% if not view_history %}
|
|
|
|
|
<h2>{{ u_filename }}</h2>
|
|
|
|
|
{% else %}
|
|
|
|
|
{% if page_from == 'snapshot' %}
|
|
|
|
|
<h2>
|
|
|
|
|
{{repo.props.name}} 镜像浏览
|
|
|
|
|
<span class="commit-time">({{ current_commit.props.ctime|tsstr_sec }})</span>
|
|
|
|
|
</h2>
|
2012-07-03 21:48:33 +08:00
|
|
|
|
{% endif %}
|
2012-09-22 11:37:01 +08:00
|
|
|
|
{% 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 %}
|
2012-09-30 19:40:35 +08:00
|
|
|
|
{% if page_from == 'recycle' %}
|
|
|
|
|
<div class="w100 ovhd">
|
|
|
|
|
<h2 class="fleft">
|
|
|
|
|
{{repo.props.name}} 的文件回收站
|
|
|
|
|
</h2>
|
|
|
|
|
<button class="fright" data="{% url 'repo' repo.id %}" id="back">返回同步目录</button>
|
|
|
|
|
</div>
|
|
|
|
|
{% endif %}
|
2012-09-22 11:37:01 +08:00
|
|
|
|
{% endif %}
|
2012-07-13 17:26:33 +08:00
|
|
|
|
<div class="w100 ovhd">
|
2012-09-17 12:57:29 +08:00
|
|
|
|
<p class="path fleft">
|
|
|
|
|
当前路径:
|
2012-09-30 19:40:35 +08:00
|
|
|
|
{% if page_from == 'recycle' %}
|
|
|
|
|
|
|
|
|
|
<a href="{% url 'repo_recycle_view' repo.id %}">{{repo.props.name}} 的文件回收站</a>
|
|
|
|
|
{% for name, link in zipped %}
|
|
|
|
|
{% if not forloop.last %}
|
|
|
|
|
/ <a href="{% url 'repo_recycle_view' repo.id %}?commit_id={{ current_commit.id }}&base={{ basedir|urlencode }}&p={{ link|urlencode }}">{{ name }}</a>
|
|
|
|
|
{% else %}
|
|
|
|
|
/ {{ name }}
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
|
|
{% else %}
|
|
|
|
|
|
2012-09-17 12:57:29 +08:00
|
|
|
|
{% for name, link in zipped %}
|
2012-09-21 20:36:53 +08:00
|
|
|
|
{% if not forloop.last %}
|
|
|
|
|
{% if view_history %}
|
|
|
|
|
{% if page_from == 'snapshot' %}
|
|
|
|
|
<a href="{% url 'repo_history_view' repo.id %}?commit_id={{ current_commit.id }}&p={{ link|urlencode }}">{{ name }}</a> /
|
|
|
|
|
{% else %}
|
|
|
|
|
{{ name }} /
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% else %}
|
|
|
|
|
<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/?p={{ link|urlencode }}">{{ name }}</a> /
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% else %}
|
|
|
|
|
{{ name }}
|
|
|
|
|
{% endif %}
|
2012-09-17 12:57:29 +08:00
|
|
|
|
{% endfor %}
|
2012-09-30 19:40:35 +08:00
|
|
|
|
|
|
|
|
|
{% endif %} <!-- if page_from == 'recycle' -->
|
2012-09-17 12:57:29 +08:00
|
|
|
|
</p>
|
|
|
|
|
|
2012-09-19 20:42:55 +08:00
|
|
|
|
{% if not view_history %}
|
2012-09-17 12:57:29 +08:00
|
|
|
|
<div class="file-op fright">
|
|
|
|
|
<input id="shared-link" class="hide" type="text" readonly="readonly" value="{{ file_shared_link }}" />
|
|
|
|
|
<button data="{{ SITE_ROOT }}sharedlink/get/?repo_id={{ repo.id }}&p={{ path|urlencode }}&file_name={{ file_name }}" id="get-shared-link">获取分享地址</button>
|
|
|
|
|
<button id="send-shared-link" class="hide">发送</button>
|
|
|
|
|
<button data="{{ SITE_ROOT }}sharedlink/remove/?t={{ fileshare.token }}" id="rm-shared-link" class="hide">删除</button>
|
|
|
|
|
</div>
|
2012-09-19 20:42:55 +08:00
|
|
|
|
{% endif %}
|
2012-07-13 17:26:33 +08:00
|
|
|
|
</div>
|
2012-09-17 12:57:29 +08:00
|
|
|
|
|
2012-09-19 20:42:55 +08:00
|
|
|
|
{% if not view_history %}
|
2012-09-17 12:57:29 +08:00
|
|
|
|
<div id="file-commit-info">
|
2012-10-17 15:37:15 +08:00
|
|
|
|
<div class="latest-commit ovhd">
|
|
|
|
|
<p class="latest-commit-info fleft">{% avatar latest_contributor 20 %} <a href="{% url 'user_profile' latest_contributor %}" class="name">{{ latest_contributor|email2nickname }}</a> <span class="time">{{ last_modified|translate_commit_time}}</span><span> 做了最新修改</span></p>
|
|
|
|
|
<a href="{{ SITE_ROOT }}repo/file_revisions/{{ repo.id }}/?p={{ path }}" class="more fright">更多历史</a>
|
|
|
|
|
</div>
|
2012-09-17 12:57:29 +08:00
|
|
|
|
<p class="contributors">
|
|
|
|
|
<span>{{ contributors|length }} 个贡献者</span>
|
|
|
|
|
{% for user in contributors %}
|
|
|
|
|
<a href="{% url 'user_profile' user %}" class="name" title="{{ user|email2nickname}}">{% avatar user 20 %}</a>
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</p>
|
2012-07-13 17:26:33 +08:00
|
|
|
|
</div>
|
2012-09-19 20:42:55 +08:00
|
|
|
|
{% endif %}
|
|
|
|
|
|
2012-08-10 21:35:58 +08:00
|
|
|
|
<div id="file">
|
2012-09-24 16:23:00 +08:00
|
|
|
|
{% if filetype == 'PDF' and not pdf_use_flash %}
|
2012-09-24 15:29:24 +08:00
|
|
|
|
<div id="file-op" class="hide">
|
|
|
|
|
{% else %}
|
2012-08-15 10:44:15 +08:00
|
|
|
|
<div id="file-op">
|
2012-09-24 15:29:24 +08:00
|
|
|
|
{% endif %}
|
2012-09-18 12:06:55 +08:00
|
|
|
|
{% if not view_history and request.user.is_authenticated %}
|
2012-08-12 11:22:42 +08:00
|
|
|
|
<button id="open-local" data="{{path}}{{dirent.obj_name}}">打开本地文件</button>
|
2012-10-17 15:37:15 +08:00
|
|
|
|
{% if not read_only %}
|
|
|
|
|
{% if filetype == 'Text' or filetype == 'Markdown' %}
|
2012-09-18 12:06:55 +08:00
|
|
|
|
<button data="{{ SITE_ROOT }}repo/{{ repo.id }}/file/edit/?p={{ path }}" id="edit">编辑</button>
|
2012-10-17 15:37:15 +08:00
|
|
|
|
{% endif %}
|
|
|
|
|
<button data="{{ SITE_ROOT }}repo/update_file/{{ repo.id }}/?p={{ path }}" id="update">更新</button>
|
|
|
|
|
{% endif %}
|
2012-09-19 20:42:55 +08:00
|
|
|
|
{% endif %}
|
2012-08-15 10:44:15 +08:00
|
|
|
|
{% if filetype == 'Text' or filetype == 'Image' or filetype == 'SVG' or filetype == 'Markdown' %}
|
2012-08-11 11:20:26 +08:00
|
|
|
|
<button data="{{ SITE_ROOT }}repo/{{ repo.id }}/{{ obj_id }}/?file_name={{ file_name }}&op=view" id="view-original">原始文件</button>
|
2012-08-15 10:44:15 +08:00
|
|
|
|
{% endif %}
|
2012-08-10 21:35:58 +08:00
|
|
|
|
<button data="{{ SITE_ROOT }}repo/{{ repo.id }}/{{ obj_id }}/?file_name={{ file_name }}&op=download" id="download">下载</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="file-view">
|
2012-09-13 16:36:23 +08:00
|
|
|
|
{% if filetype == 'Text' %}
|
|
|
|
|
{% ifnotequal file_content None %}
|
|
|
|
|
<textarea id="docu-view" class="vh">{{ file_content|escape }}</textarea>
|
|
|
|
|
{% endifnotequal %}
|
|
|
|
|
{% else %}
|
2012-08-10 21:35:58 +08:00
|
|
|
|
<p>文件内容读取中...</p>
|
2012-09-13 16:36:23 +08:00
|
|
|
|
{% endif %}
|
2012-08-10 21:35:58 +08:00
|
|
|
|
</div>
|
2012-07-02 22:45:21 +08:00
|
|
|
|
</div>
|
2012-07-11 22:39:36 +08:00
|
|
|
|
|
2012-09-19 20:42:55 +08:00
|
|
|
|
{% if not view_history %}
|
2012-07-11 22:39:36 +08:00
|
|
|
|
<form id="link-send-form" action="" method="post" name="link-send-form" class="hide">
|
2012-07-13 17:26:33 +08:00
|
|
|
|
<label>邮箱(多个邮箱以,分隔):</label><br />
|
|
|
|
|
<textarea id="email" name="email"></textarea><br />
|
|
|
|
|
<input type="hidden" name="file_shared_link" value="{{ file_shared_link }}" />
|
|
|
|
|
<input type="submit" value="提交" class="submit" />
|
2012-09-15 21:16:34 +08:00
|
|
|
|
<p class="error hide"></p>
|
|
|
|
|
<p id="sending" class="hide">发送中...</p>
|
2012-07-11 22:39:36 +08:00
|
|
|
|
</form>
|
2012-09-14 16:11:53 +08:00
|
|
|
|
|
|
|
|
|
<div id="open-local-feedback" class="hide">
|
|
|
|
|
<p id="open-local-handling-tip">处理中,请稍侯...</p>
|
|
|
|
|
<p id="open-local-error" class="error"></p>
|
|
|
|
|
<div id="redirect-download" class="hide">
|
2012-10-09 14:38:13 +08:00
|
|
|
|
<p class="error">您还没有将资料库 {{repo.name}} 下载到本地</p>
|
2012-09-22 19:50:40 +08:00
|
|
|
|
<button data="{{ SITE_ROOT }}download/repo/?repo_id={{ repo.id }}" id="download-repo">点此下载</button>
|
2012-09-14 16:11:53 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2012-08-13 15:58:54 +08:00
|
|
|
|
|
|
|
|
|
{% with attach_type='file' %}
|
|
|
|
|
{% include "snippets/group_recommend_form.html" %}
|
|
|
|
|
{% endwith %}
|
2012-08-12 11:22:42 +08:00
|
|
|
|
|
2012-09-19 20:42:55 +08:00
|
|
|
|
{% if request.user.is_authenticated %}
|
|
|
|
|
<div id="file-comment" class="hide">
|
|
|
|
|
<form id="file-comment-form" action="" method="post">
|
2012-09-19 21:01:59 +08:00
|
|
|
|
<div class="w100 ovhd">
|
2012-09-19 20:42:55 +08:00
|
|
|
|
<a class="pic fleft" href="{% url 'user_profile' request.user.username %}">{% avatar request.user.username 48 %}</a>
|
|
|
|
|
<div class="txt fright">
|
|
|
|
|
<textarea name="message" id="comment-input">评论一下~</textarea><br />
|
2012-09-19 21:01:59 +08:00
|
|
|
|
<p class="error hide"></p>
|
2012-09-19 20:42:55 +08:00
|
|
|
|
<input type="submit" value="提交" class="submit hide" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
<ul id="comment-list">
|
2012-09-19 21:01:59 +08:00
|
|
|
|
{% if comments %}
|
2012-09-19 20:42:55 +08:00
|
|
|
|
{% for comment in comments %}
|
|
|
|
|
<li class="comment ovhd">
|
|
|
|
|
<a class="pic fleft" href="{% url 'user_profile' comment.from_email %}">{% avatar comment.from_email 48 %}</a>
|
|
|
|
|
<div class="txt fright">
|
|
|
|
|
<div class="comment-hd w100 ovhd">
|
|
|
|
|
<a href="{% url 'user_profile' comment.from_email %}" title="{{ comment.from_email }}" class="fleft">{{ comment.from_email|email2nickname }}</a>
|
|
|
|
|
<span class="time fright">{{ comment.timestamp|translate_commit_time }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<p class="comment-bd">{{ comment.message|seahub_urlize|find_at|linebreaksbr }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</li>
|
|
|
|
|
{% endfor %}
|
|
|
|
|
{% endif %}
|
2012-09-19 21:01:59 +08:00
|
|
|
|
</ul>
|
2012-08-26 11:48:43 +08:00
|
|
|
|
</div>
|
2012-09-19 20:42:55 +08:00
|
|
|
|
<div id="comment-caret" class="hide">
|
|
|
|
|
<div id="comment-outer-caret">
|
|
|
|
|
<div id="comment-inner-caret"></div>
|
|
|
|
|
</div>
|
2012-08-26 11:48:43 +08:00
|
|
|
|
</div>
|
2012-09-19 20:42:55 +08:00
|
|
|
|
{% endif %}
|
|
|
|
|
{% endif %}
|
2012-07-02 22:45:21 +08:00
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
|
|
{% block extra_script %}
|
2012-07-31 16:48:55 +08:00
|
|
|
|
{% include "snippets/file_view_js.html" %}
|
2012-07-02 22:45:21 +08:00
|
|
|
|
<script type="text/javascript">
|
2012-08-08 17:14:04 +08:00
|
|
|
|
{% include "snippets/repo_file_get.html" %}
|
2012-08-10 21:35:58 +08:00
|
|
|
|
$('#view-original, #download').click(function() {
|
|
|
|
|
window.open($(this).attr('data'));
|
|
|
|
|
});
|
2012-08-08 17:14:04 +08:00
|
|
|
|
{% if not view_history %}
|
2012-10-17 15:37:15 +08:00
|
|
|
|
$('#edit, #update').click(function() {
|
2012-08-10 21:35:58 +08:00
|
|
|
|
location.href = $(this).attr('data');
|
|
|
|
|
});
|
2012-07-11 22:39:36 +08:00
|
|
|
|
function showLink() {
|
2012-07-13 17:26:33 +08:00
|
|
|
|
$('#get-shared-link').addClass('hide');
|
|
|
|
|
$('#shared-link, #send-shared-link, #rm-shared-link').removeClass('hide');
|
2012-07-11 22:39:36 +08:00
|
|
|
|
}
|
|
|
|
|
function hideLink() {
|
2012-07-13 17:26:33 +08:00
|
|
|
|
$('#shared-link, #send-shared-link, #rm-shared-link').addClass('hide');
|
|
|
|
|
$('#get-shared-link').removeClass('hide');
|
2012-07-11 22:39:36 +08:00
|
|
|
|
}
|
2012-09-07 19:50:29 +08:00
|
|
|
|
function setLinkWidth() {
|
|
|
|
|
var link = $('#shared-link');
|
|
|
|
|
link.before('<p class="hide">' + link.val() + '</p>');
|
|
|
|
|
link.css('width', link.prev().width() + 2);
|
|
|
|
|
link.prev().remove();
|
|
|
|
|
}
|
|
|
|
|
if ($.trim($('#shared-link').val())) {
|
|
|
|
|
setLinkWidth();
|
|
|
|
|
}
|
2012-07-11 22:39:36 +08:00
|
|
|
|
|
2012-08-06 20:29:14 +08:00
|
|
|
|
{% if fileshare.token %}
|
|
|
|
|
showLink();
|
|
|
|
|
{% else %}
|
|
|
|
|
hideLink();
|
|
|
|
|
{% endif %}
|
2012-07-11 22:39:36 +08:00
|
|
|
|
|
2012-07-13 17:26:33 +08:00
|
|
|
|
$('#get-shared-link').click(function() {
|
2012-07-11 22:39:36 +08:00
|
|
|
|
var url = $(this).attr('data');
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
cache: false,
|
|
|
|
|
contentType: 'application/json; charset=utf-8',
|
|
|
|
|
success: function(data) {
|
|
|
|
|
if (data.length > 0) {
|
2012-07-13 17:26:33 +08:00
|
|
|
|
var t = data[0]['token'],
|
|
|
|
|
shared_link = '{{ protocol }}://{{ domain }}{{ SITE_ROOT }}f/' + t + '/';
|
2012-09-07 19:50:29 +08:00
|
|
|
|
$('#shared-link').val(shared_link);
|
|
|
|
|
setLinkWidth();
|
2012-07-13 17:26:33 +08:00
|
|
|
|
$('#rm-shared-link').attr('data', '{{ SITE_ROOT }}sharedlink/remove/?t='+t);
|
|
|
|
|
$('input[name="file_shared_link"]').val(shared_link);
|
2012-07-11 22:39:36 +08:00
|
|
|
|
showLink();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error: function(xhr, ajaxOptions, thrownError) {
|
|
|
|
|
var jsonVal = jQuery.parseJSON(xhr.responseText);
|
2012-07-13 17:26:33 +08:00
|
|
|
|
$('#get-shared-link').replaceWith('<span class="error">' + jsonVal[0]['error'] + '</span>');
|
2012-07-11 22:39:36 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2012-07-13 17:26:33 +08:00
|
|
|
|
$('#rm-shared-link').click(function() {
|
2012-07-11 22:39:36 +08:00
|
|
|
|
var url = $(this).attr('data');
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
cache: false,
|
|
|
|
|
contentType: 'application/json; charset=utf-8',
|
|
|
|
|
success: function(data) {
|
|
|
|
|
hideLink();
|
2012-09-07 19:50:29 +08:00
|
|
|
|
$('#shared-link').val('');
|
2012-07-11 22:39:36 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2012-07-13 17:26:33 +08:00
|
|
|
|
$('#send-shared-link').click(function() {
|
2012-07-11 22:39:36 +08:00
|
|
|
|
$("#link-send-form").modal({appendTo: "#main"});
|
2012-08-03 14:00:43 +08:00
|
|
|
|
|
|
|
|
|
// link-send-form email autocomplete
|
2012-10-10 10:45:10 +08:00
|
|
|
|
var share_list = [], contact_email;
|
2012-08-03 14:00:43 +08:00
|
|
|
|
{% for contact in contacts %}
|
2012-10-10 10:45:10 +08:00
|
|
|
|
contact_email = '{{ contact.contact_email }}';
|
|
|
|
|
share_list.push({value:contact_email, label:contact_email});
|
2012-08-03 14:00:43 +08:00
|
|
|
|
{% endfor %}
|
|
|
|
|
addAutocomplete('#email', '#link-send-form', share_list);
|
2012-07-11 22:39:36 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#link-send-form").submit(function(event) {
|
2012-09-15 21:16:34 +08:00
|
|
|
|
$('#link-send-form .error').addClass('hide');
|
|
|
|
|
$('#sending').removeClass('hide');
|
|
|
|
|
|
2012-07-11 22:39:36 +08:00
|
|
|
|
var form = $(this),
|
|
|
|
|
file_shared_link = form.children('input[name="file_shared_link"]').val(),
|
2012-07-13 17:26:33 +08:00
|
|
|
|
email = $.trim(form.children('textarea[name="email"]').val());
|
|
|
|
|
|
2012-07-11 22:39:36 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
2012-09-15 21:16:34 +08:00
|
|
|
|
url: "{% url 'seahub.views.send_shared_link' %}",
|
2012-07-11 22:39:36 +08:00
|
|
|
|
dataType: 'json',
|
|
|
|
|
cache: false,
|
|
|
|
|
contentType: 'application/json; charset=utf-8',
|
2012-07-17 17:54:05 +08:00
|
|
|
|
beforeSend: prepareCSRFToken,
|
2012-07-12 16:14:21 +08:00
|
|
|
|
data: {file_shared_link: file_shared_link, email: email},
|
2012-07-11 22:39:36 +08:00
|
|
|
|
success: function(data) {
|
2012-09-15 21:16:34 +08:00
|
|
|
|
location.reload(true);
|
2012-07-11 22:39:36 +08:00
|
|
|
|
},
|
2012-09-15 21:16:34 +08:00
|
|
|
|
error: function(data, textStatus, jqXHR) {
|
|
|
|
|
$('#sending').addClass('hide');
|
|
|
|
|
var errors = $.parseJSON(data.responseText);
|
|
|
|
|
$.each(errors, function(index, value) {
|
|
|
|
|
if (index == 'error') {
|
|
|
|
|
apply_form_error('link-send-form', value);
|
|
|
|
|
} else {
|
|
|
|
|
apply_form_error('link-send-form', value[0]);
|
|
|
|
|
}
|
|
|
|
|
});
|
2012-07-11 22:39:36 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
});
|
2012-08-08 17:14:04 +08:00
|
|
|
|
|
2012-09-07 19:50:29 +08:00
|
|
|
|
$('#shared-link').click(function() {
|
2012-09-14 16:11:53 +08:00
|
|
|
|
$(this).select();
|
2012-09-07 19:50:29 +08:00
|
|
|
|
});
|
|
|
|
|
|
2012-08-08 17:14:04 +08:00
|
|
|
|
{% include "snippets/bottom_bar.html" %}
|
2012-09-19 20:42:55 +08:00
|
|
|
|
{% if request.user.is_authenticated %}
|
|
|
|
|
$('#bottom-bar').append(' <button id="comment">评论</button>');
|
|
|
|
|
$('#file-comment').css('max-height', $(window).height() - parseInt($('#file-comment').css('bottom')));
|
2012-09-20 10:45:09 +08:00
|
|
|
|
{% if comment_open %}
|
|
|
|
|
$('#file-comment, #comment-caret').removeClass('hide');
|
|
|
|
|
{% endif %}
|
2012-09-19 20:42:55 +08:00
|
|
|
|
$('#comment').click(function() {
|
|
|
|
|
if ($('#file-comment').hasClass('hide')) {
|
|
|
|
|
$('#file-comment, #comment-caret').removeClass('hide');
|
|
|
|
|
} else {
|
|
|
|
|
$('#file-comment, #comment-caret').addClass('hide');
|
|
|
|
|
}
|
|
|
|
|
});
|
2012-09-20 11:55:19 +08:00
|
|
|
|
$(document).click(function(e) {
|
|
|
|
|
var target = e.target || event.srcElement;
|
|
|
|
|
if (target != $('#comment')[0] && target != $('#file-comment')[0] && target != $('#comment-caret')[0] && !($('#file-comment, #comment-caret').find('*').is(target))) {
|
|
|
|
|
$('#file-comment, #comment-caret').addClass('hide');
|
|
|
|
|
}
|
|
|
|
|
});
|
2012-09-19 20:42:55 +08:00
|
|
|
|
|
|
|
|
|
var comment_input_pre_text = $('#comment-input').val();
|
|
|
|
|
$('#comment-input').css('color', '#999').click(function() {
|
2012-09-25 10:48:26 +08:00
|
|
|
|
if ($(this).val() == comment_input_pre_text) {
|
|
|
|
|
$(this).val('').css('color', '#000');
|
|
|
|
|
$('#file-comment-form .submit').removeClass('hide');
|
|
|
|
|
}
|
2012-09-19 20:42:55 +08:00
|
|
|
|
});
|
|
|
|
|
$('#file-comment-form .submit').click(function() {
|
|
|
|
|
if (!$.trim($('#comment-input').val())) {
|
|
|
|
|
$('#file-comment-form .error').html('请先输入您的评论').removeClass('hide');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '{% url 'views.file_comment' %}' + '?p={{path}}',
|
|
|
|
|
type: 'POST',
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
contentType: 'application/json; charset=utf-8',
|
|
|
|
|
beforeSend: prepareCSRFToken,
|
|
|
|
|
data: {
|
|
|
|
|
'repo_id': '{{ repo.id }}',
|
|
|
|
|
'file_path': '{{ path|urlencode }}',
|
|
|
|
|
'message': $('#comment-input').val()
|
|
|
|
|
},
|
|
|
|
|
success: function(data) {
|
|
|
|
|
$('#comment-input').val(comment_input_pre_text).css('color', '#999');
|
|
|
|
|
$('#file-comment-form .submit, #file-comment-form .error').addClass('hide');
|
|
|
|
|
$('#comment-list').html(data.html);
|
|
|
|
|
},
|
|
|
|
|
error: function(data, textStatus, jqXHR) {
|
|
|
|
|
var errors = $.parseJSON(data.responseText);
|
|
|
|
|
$.each(errors, function(index, value) {
|
|
|
|
|
$('#file-comment-form .error').html(value[0]).removeClass('hide');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
2012-08-12 11:22:42 +08:00
|
|
|
|
function send_open_local_file_request(path) {
|
|
|
|
|
var callback = 'xx';
|
|
|
|
|
$.ajax({
|
2012-09-14 16:11:53 +08:00
|
|
|
|
url: '{{ applet_root }}/open-local-file/?repo_id={{ repo.id }}&commit_id={{current_commit.id}}&path=' + e(path) + '&callback=' + callback,
|
2012-08-12 11:22:42 +08:00
|
|
|
|
dataType: 'jsonp',
|
|
|
|
|
jsonpCallback: callback,
|
|
|
|
|
crossDomain: true,
|
|
|
|
|
success: function(data) {
|
2012-09-14 16:11:53 +08:00
|
|
|
|
$('#open-local-handling-tip').addClass('hide');
|
2012-08-12 11:22:42 +08:00
|
|
|
|
if (data['exists'] === false) {
|
|
|
|
|
// repo doesn't exist on local machine
|
2012-09-14 16:11:53 +08:00
|
|
|
|
$('#open-local-error').addClass('hide');
|
|
|
|
|
$('#redirect-download').removeClass('hide');
|
2012-08-12 11:22:42 +08:00
|
|
|
|
|
|
|
|
|
} else if (data['no_assoc'] === true) {
|
|
|
|
|
// no application to open the file
|
2012-09-14 16:11:53 +08:00
|
|
|
|
$('#open-local-error').html('找不到打开该类型文件的程序。Seafile 将为你打开该文件所在目录');
|
2012-08-12 11:22:42 +08:00
|
|
|
|
|
2012-09-05 11:40:19 +08:00
|
|
|
|
} else if (data['outdated'] === true) {
|
|
|
|
|
// local repo not in sync yet
|
|
|
|
|
if (data['auto-sync'] === false) {
|
2012-09-14 16:11:53 +08:00
|
|
|
|
$('#open-local-error').html('本地文件尚未与服务器同步。请打开本地目录的自动同步,或者手动进行同步');
|
2012-09-05 11:40:19 +08:00
|
|
|
|
} else {
|
2012-09-14 16:11:53 +08:00
|
|
|
|
$('#open-local-error').html('本地文件尚未与服务器同步,请稍后再试');
|
2012-09-05 11:40:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-12 11:22:42 +08:00
|
|
|
|
} else if (data['error']) {
|
|
|
|
|
// other error
|
2012-09-14 16:11:53 +08:00
|
|
|
|
$('#open-local-error').html('打开本地文件时出错');
|
2012-08-12 11:22:42 +08:00
|
|
|
|
|
|
|
|
|
} else {
|
2012-09-14 16:11:53 +08:00
|
|
|
|
// open file successfully
|
|
|
|
|
$('#open-local-handling-tip').removeClass('hide');
|
2012-09-20 16:45:51 +08:00
|
|
|
|
setTimeout(function() { $.modal.close(); }, 1500);
|
2012-08-12 11:22:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2012-08-21 17:48:49 +08:00
|
|
|
|
$('#download-repo').click(function() {
|
|
|
|
|
location.href = $(this).attr('data');
|
|
|
|
|
});
|
2012-08-12 11:22:42 +08:00
|
|
|
|
|
|
|
|
|
$('#open-local').click(function () {
|
|
|
|
|
var path = $(this).attr('data');
|
|
|
|
|
var local_applet_running = false;
|
2012-09-14 16:11:53 +08:00
|
|
|
|
$('#open-local-feedback').modal({
|
|
|
|
|
appendTo: '#main',
|
2012-09-20 16:45:51 +08:00
|
|
|
|
containerCss: { width: 300, height: 60}
|
2012-09-14 16:11:53 +08:00
|
|
|
|
});
|
2012-08-12 11:22:42 +08:00
|
|
|
|
|
|
|
|
|
$.ajax({
|
2012-08-16 17:37:18 +08:00
|
|
|
|
url: '{{ applet_root }}/seafile_rpc_version/',
|
2012-08-12 11:22:42 +08:00
|
|
|
|
dataType: 'jsonp',
|
|
|
|
|
jsonpCallback: 'xx',
|
|
|
|
|
crossDomain: true,
|
|
|
|
|
success: function(version) {
|
|
|
|
|
local_applet_running = true;
|
2012-08-16 17:37:18 +08:00
|
|
|
|
if (version < 1) {
|
2012-09-14 16:11:53 +08:00
|
|
|
|
$('#open-local-handling-tip').addClass('hide');
|
|
|
|
|
$('#open-local-error').html('您的 Seafile 客户端版本太低,请<a href="http://www.seafile.com/download/">升级</a>到最新版本');
|
2012-08-12 11:22:42 +08:00
|
|
|
|
} else {
|
|
|
|
|
send_open_local_file_request(path);
|
|
|
|
|
}
|
2012-08-23 10:52:53 +08:00
|
|
|
|
}
|
2012-08-12 11:22:42 +08:00
|
|
|
|
});
|
|
|
|
|
|
2012-09-14 16:11:53 +08:00
|
|
|
|
// if jsonp response doesn't arrive in 2 seconds, we can say local client is not running yet.
|
2012-08-12 11:22:42 +08:00
|
|
|
|
setTimeout(function() {
|
|
|
|
|
if (!local_applet_running) {
|
2012-09-14 16:11:53 +08:00
|
|
|
|
$('#open-local-handling-tip').addClass('hide');
|
|
|
|
|
$('#open-local-error').html('Seafile 客户端程序未启动或者版本过低');
|
2012-08-12 11:22:42 +08:00
|
|
|
|
}
|
|
|
|
|
}, 2000);
|
|
|
|
|
});
|
2012-09-22 11:37:01 +08:00
|
|
|
|
//'not view_history' ends here
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
2012-09-30 19:40:35 +08:00
|
|
|
|
{% if view_history %}
|
|
|
|
|
{% if page_from == 'file_history' or page_from == 'recycle' %}
|
2012-09-22 11:37:01 +08:00
|
|
|
|
$('#back').click(function() {
|
|
|
|
|
location.href = $(this).attr('data');
|
|
|
|
|
});
|
2012-09-30 19:40:35 +08:00
|
|
|
|
{% endif %}
|
2012-09-22 11:37:01 +08:00
|
|
|
|
{% endif %}
|
2012-07-02 22:45:21 +08:00
|
|
|
|
</script>
|
|
|
|
|
{% endblock %}
|