1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-18 00:00:00 +00:00
Files
seahub/templates/repo_edit_file.html

77 lines
3.0 KiB
HTML
Raw Normal View History

2012-08-06 20:29:14 +08:00
{% extends base_template %}
{% load seahub_tags %}
{% block main_panel %}
2012-08-07 11:47:10 +08:00
<h2>编辑 {{ u_filename }}</h2>
2012-08-06 20:29:14 +08:00
<div class="w100 ovhd">
<p class="path fleft">
当前路径:
{% for name, link in zipped %}
{% if not forloop.last %}
<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/?p={{ link|urlencode }}">{{ name }}</a> /
{% else %}
{{ name }}
{% endif %}
{% endfor %}
</p>
<div class="file-op fright">
<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/files/?p={{ path }}">返回</a>
</div>
</div>
<div id="file-view">
<p>文件内容读取中...</p>
</div>
2012-08-07 11:47:10 +08:00
<form action="post" method="post" id="file-edit-form" class="hide">
2012-08-06 20:29:14 +08:00
<input type="hidden" name="modified-file" />
<label>修改信息:</label><br />
2012-08-07 11:47:10 +08:00
<input type="text" name="commit-msg" id="file-edit-commit-msg" value="修改了 {{ u_filename }}" /><br />
2012-08-06 20:29:14 +08:00
<label>更多描述:</label><br />
<textarea name="commit-details" id="file-edit-commit-details"></textarea><br />
<input type="submit" class="submit" value="提交" />
</form>
{% endblock %}
{% block extra_script %}
<script type="text/javascript" src="{{MEDIA_URL}}ace/ace.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}ace/theme-twilight.js"></script>
{% include "snippets/file_view_js.html" %}
<script type="text/javascript">
var url = "{{ SITE_ROOT }}repo/{{ repo.id }}/file/get/?p={{ path|urlencode }}&t={{ token }}&u={{ request.user.username }}";
$.ajax({
url: url,
dataType: 'json',
cache: false,
success: function(data) {
$('#file-view').html('<div id="docu-view" class="vh">' + '</div>');
editor = ace.edit("docu-view");
$('#docu-view').removeClass('vh');
editor.setShowPrintMargin(false); // rm the vertical line in the center
editor.renderer.scrollBar.element.style.display = "none"; // hide right scrollbar
editor.renderer.scrollBar.width = 0; // enlarge ace_content width
editor.setTheme("ace/theme/twilight");
{% include "snippets/editor_set_mode.html" %}
editor.session.getDocument().setValue(data['content']);
$('#docu-view').css({'position': 'relative', 'height': editor.session.getScreenLength() * parseInt($('#docu-view').css('line-height'))});
editor.session.setScrollLeft(0); // make bottom scrollbar start from the left-most
editor.resize(); // fix some problem for showing some file in ie8
2012-08-07 11:47:10 +08:00
$('#file-edit-form').removeClass('hide');
2012-08-06 20:29:14 +08:00
},
error: function(xhr, ajaxOptions, thrownError) {
var jsonVal = jQuery.parseJSON(xhr.responseText);
$('#file-view').html('<p class="error">' + jsonVal['error'] + '</p>');
}
});
2012-08-07 11:47:10 +08:00
$('#file-edit-commit-msg').css('color', '#666').click(function() {
$(this).val('').css('color', '#000');
});
2012-08-06 20:29:14 +08:00
$('#file-edit-form').submit(function() {
$(this).find('[name="modified-file"]').val(editor.session.getValue());
});
</script>
{% endblock %}