mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 10:50:24 +00:00
Merge branch 'lj_fileop'
This commit is contained in:
@@ -175,6 +175,26 @@ ul.with-bg li {
|
||||
background: #fff url('../img/li.gif') no-repeat scroll left 6px;
|
||||
}
|
||||
#paginator { margin-top:10px; }
|
||||
.tri-bg { /*triangle bg, <span>*/
|
||||
display:inline-block;
|
||||
font-size:0;
|
||||
line-height: 0;
|
||||
width:0;
|
||||
height:0;
|
||||
border-color: transparent;
|
||||
}
|
||||
.tri-down-bg {
|
||||
padding-top: 1px;
|
||||
border-width: 3px 3px 0;
|
||||
border-style: solid dashed dashed;
|
||||
border-top-color: #bbb;
|
||||
}
|
||||
.tri-right-bg {
|
||||
padding-right: 1px;
|
||||
border-width: 3px 0 3px 3px;
|
||||
border-style: dashed dashed dashed solid;
|
||||
border-left-color: #bbb;
|
||||
}
|
||||
|
||||
/* container */
|
||||
#header, #main, #footer { width:950px; }
|
||||
@@ -261,18 +281,8 @@ ul.with-bg li {
|
||||
.top-bar-con a.avatar-link:hover {
|
||||
background:none;
|
||||
}
|
||||
#account-context .bg {
|
||||
display:inline-block;
|
||||
font-size:0;
|
||||
line-height: 0;
|
||||
width:0;
|
||||
#account-context .tri-bg {
|
||||
height:0;
|
||||
padding-top: 1px;
|
||||
border-width: 3px 3px 0;
|
||||
border-style: solid dashed dashed;
|
||||
border-color: transparent;
|
||||
border-top-color: #bbb;
|
||||
margin-left:1px;
|
||||
}
|
||||
#account-context-selector {
|
||||
position:absolute;
|
||||
@@ -431,6 +441,7 @@ ul.with-bg li {
|
||||
font-weight:normal;
|
||||
}
|
||||
#simplemodal-container h3 {
|
||||
word-wrap:break-word;
|
||||
margin:0 0 4px;
|
||||
}
|
||||
.simplemodal-close {
|
||||
@@ -648,12 +659,34 @@ ul.with-bg li {
|
||||
-moz-border-radius:5px;
|
||||
z-index:10;
|
||||
}
|
||||
.op-list li {
|
||||
.op-list li a {
|
||||
display:block;
|
||||
padding:0 12px;
|
||||
}
|
||||
.op-target {
|
||||
color:#c39;
|
||||
}
|
||||
#mv-form {
|
||||
width:500px;
|
||||
padding:10px 20px;
|
||||
}
|
||||
#mv-form .con {
|
||||
padding:5px;
|
||||
height:280px;
|
||||
overflow:auto;
|
||||
border:1px solid #eee;
|
||||
margin:10px 0 20px;
|
||||
}
|
||||
#mv-form h4 span {
|
||||
margin-right:20px;
|
||||
margin-bottom:3px;
|
||||
}
|
||||
#mv-form .tri-right-bg {
|
||||
border-left-color:#333;
|
||||
}
|
||||
#mv-form .tri-down-bg {
|
||||
border-top-color:#333;
|
||||
}
|
||||
#rename-form .new-name {
|
||||
margin-top:8px;
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@
|
||||
{% if cloud_mode %}
|
||||
<a href="#" id="account-context" data="no-popup">
|
||||
{% if org %} {{ org.org_name }} {% else %} 个人帐号 {% endif %}
|
||||
<span class="bg"></span></a>
|
||||
<span class="tri-bg tri-down-bg"></span></a>
|
||||
<ul class="hide" id="account-context-selector">
|
||||
<li><a href="{% url 'myhome' %}">个人帐号</a></li>
|
||||
{% for org in request.user.orgs %}
|
||||
|
@@ -218,8 +218,13 @@
|
||||
</form>
|
||||
|
||||
<form id="mv-form" action="{{ SITE_ROOT }}file/move/" method="post" class="hide">
|
||||
<p id="mv-hd"></p>
|
||||
<div id="dirs"></div>
|
||||
<h3 id="mv-hd"></h3>
|
||||
<div class="con">
|
||||
<h4><span class="tri-bg tri-down-bg"></span>当前同步目录:</h4>
|
||||
<div id="current-repo-dirs"></div>
|
||||
<h4><span class="tri-bg tri-right-bg"></span>其他同步目录:</h4>
|
||||
<div id="other-repos-dirs" class="hide"></div>
|
||||
</div>
|
||||
<input type="hidden" name="operation" id="operation" value="" />
|
||||
<input type="hidden" name="src_repo" value="{{ repo.id }}" />
|
||||
<input type="hidden" name="src_path" value="{{ path }}" />
|
||||
@@ -266,24 +271,26 @@ $("table tr:gt(0)").hover(
|
||||
$('#main-panel').removeClass('ovhd');
|
||||
var clicked_more_op;
|
||||
$('.more-op').click(function(e) {
|
||||
clicked_more_op = $(this);
|
||||
var its_op_list = $(this).next();
|
||||
if ($(this).attr('data')) { // no popup
|
||||
clicked_more_op = $(this);
|
||||
$(this).parent().css('position','relative');
|
||||
if ($(this).offset().top + $(this).next().height() <= $('#main').offset().top + $('#main').height()) {
|
||||
$(this).next().css('top', 6);
|
||||
if ($(this).offset().top + its_op_list.height() <= $('#main').offset().top + $('#main').height()) {
|
||||
its_op_list.css('top', 6);
|
||||
} else {
|
||||
$(this).next().css('bottom', 2);
|
||||
its_op_list.css('bottom', 2);
|
||||
}
|
||||
$(this).next().removeClass('hide');
|
||||
$('.op-list').addClass('hide');
|
||||
its_op_list.removeClass('hide');
|
||||
$(this).attr('data','');
|
||||
} else {
|
||||
$(this).next().addClass('hide');
|
||||
its_op_list.addClass('hide');
|
||||
$(this).attr('data','no-popup');
|
||||
}
|
||||
});
|
||||
$(document).click(function(e) {
|
||||
var target = e.target || event.srcElement;
|
||||
if (target != clicked_more_op[0]) {
|
||||
if (clicked_more_op && target != clicked_more_op[0]) {
|
||||
clicked_more_op.next().addClass('hide');
|
||||
clicked_more_op.attr('data','no-popup');
|
||||
}
|
||||
@@ -308,19 +315,35 @@ $('.file-rename, .dir-rename').click(function () {
|
||||
return false;
|
||||
});
|
||||
|
||||
var accessible_repos = [];
|
||||
{% for repo in accessible_repos %}
|
||||
{% if repo.props.has_subdir %}
|
||||
accessible_repos.push({
|
||||
'data': '{{ repo.props.name }}',
|
||||
'attr': {'repo_id': '{{ repo.props.id }}'},
|
||||
'state': 'closed'
|
||||
});
|
||||
var current_repo = [],
|
||||
other_repos = [];
|
||||
{% for a_repo in accessible_repos %}
|
||||
{% if a_repo.props.id == repo.props.id %}
|
||||
{% if a_repo.props.has_subdir %}
|
||||
current_repo.push({
|
||||
'data': '{{ a_repo.props.name }}',
|
||||
'attr': {'repo_id': '{{ a_repo.props.id }}'},
|
||||
'state': 'closed'
|
||||
});
|
||||
{% else %}
|
||||
current_repo.push({
|
||||
'data': '{{ a_repo.props.name }}',
|
||||
'attr': {'repo_id': '{{ a_repo.props.id }}'}
|
||||
});
|
||||
{% endif %}
|
||||
{% else %}
|
||||
accessible_repos.push({
|
||||
'data': '{{ repo.props.name }}',
|
||||
'attr': {'repo_id': '{{ repo.props.id }}'}
|
||||
});
|
||||
{% if a_repo.props.has_subdir %}
|
||||
other_repos.push({
|
||||
'data': '{{ a_repo.props.name }}',
|
||||
'attr': {'repo_id': '{{ a_repo.props.id }}'},
|
||||
'state': 'closed'
|
||||
});
|
||||
{% else %}
|
||||
other_repos.push({
|
||||
'data': '{{ a_repo.props.name }}',
|
||||
'attr': {'repo_id': '{{ a_repo.props.id }}'}
|
||||
});
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
@@ -346,21 +369,23 @@ $('.file-cp, .file-mv, .dir-cp, .dir-mv').click(function () {
|
||||
|
||||
$('input[name="obj_name"]').val(obj_name);
|
||||
$('#mv-hd').html('将' + file_type + ' <span class="op-target">' + obj_name + '</span> ' + mv_type + '到:');
|
||||
$('#mv-form').modal({appendTo:'#main', autoResize:true});
|
||||
renderDirTree($('#current-repo-dirs'), current_repo);
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#dirs')
|
||||
.bind('loaded.jstree', function(event,data) {
|
||||
$('#mv-form').modal({appendTo:'#main', maxHeight: window.innerHeight - 57, autoResize:true});
|
||||
function renderDirTree(container, repo_data) {
|
||||
container
|
||||
.delegate('.jstree-closed', 'dblclick', function(e) {
|
||||
container.jstree('open_node', $(this));
|
||||
$(this).find('a').removeClass('jstree-clicked');
|
||||
})
|
||||
.bind('after_open.jstree after_close.jstree set_focus.jstree', function(event, data) {
|
||||
$('#mv-form').css({'max-height': window.innerHeight - parseInt($('#simplemodal-container').css('top')) - 57, 'max-width':window.innerWidth - $('#mv-form').offset().left - 40, 'overflow': 'auto'});
|
||||
$('#simplemodal-container').css('height', $('#mv-form').height());
|
||||
})
|
||||
.bind('after_open.jstree set_focus.jstree', function(event,data) {
|
||||
if ($('#mv-form').width() < $('#mv-form')[0].scrollWidth) {
|
||||
$('#simplemodal-container').css('width', $('#mv-form')[0].scrollWidth + 15);
|
||||
.bind('before.jstree', function(e, data) {
|
||||
if (data.func === 'select_node') { // ensure only one selected dir display in the popup
|
||||
$('#mv-form .jstree-clicked').removeClass('jstree-clicked');
|
||||
}
|
||||
})
|
||||
.bind('select_node.jstree', function(event,data) {
|
||||
.bind('select_node.jstree', function(e, data) {
|
||||
var repo_id = data.rslt.obj.attr('repo_id') || data.inst._get_parent(data.rslt.obj).attr('repo_id');
|
||||
$('input[name="dst_repo"]').attr('value', repo_id);
|
||||
var path = data.inst.get_path(data.rslt.obj);
|
||||
@@ -375,7 +400,7 @@ $('.file-cp, .file-mv, .dir-cp, .dir-mv').click(function () {
|
||||
})
|
||||
.jstree({
|
||||
'json_data': {
|
||||
'data': accessible_repos,
|
||||
'data': repo_data,
|
||||
'ajax': {
|
||||
'url': function(data) {
|
||||
var path = this.get_path(data);
|
||||
@@ -395,7 +420,23 @@ $('.file-cp, .file-mv, .dir-cp, .dir-mv').click(function () {
|
||||
},
|
||||
'plugins': ['themes', 'json_data', 'ui']
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#mv-form h4').click(function() {
|
||||
var span = $(this).children('.tri-bg'),
|
||||
next = $(this).next();
|
||||
if (span.hasClass('tri-right-bg')) {
|
||||
span.attr('class','tri-bg tri-down-bg');
|
||||
if (next.attr('id') == 'current-repo-dirs') {
|
||||
renderDirTree(next, current_repo);
|
||||
} else {
|
||||
renderDirTree(next, other_repos);
|
||||
}
|
||||
next.removeClass('hide');
|
||||
} else {
|
||||
span.attr('class','tri-bg tri-right-bg');
|
||||
next.addClass('hide');
|
||||
}
|
||||
});
|
||||
|
||||
$('#rename-form .submit').click(function() {
|
||||
|
7
views.py
7
views.py
@@ -1212,9 +1212,12 @@ def file_move(request):
|
||||
if obj_type == 'dir':
|
||||
src_dir = os.path.join(src_path, obj_name)
|
||||
if dst_path.startswith(src_dir):
|
||||
error_msg = u"不能把目录 %s %s到它的子目录 %s" \
|
||||
error_msg = u"不能把目录 %s %s到它的子目录 %s中" \
|
||||
% (src_dir, u"复制" if op == 'cp' else u"移动", dst_path)
|
||||
return render_error(request, error_msg)
|
||||
#return render_error(request, error_msg)
|
||||
messages.add_message(request, messages.ERROR, error_msg)
|
||||
url = reverse('repo', args=[src_repo_id]) + ('?p=%s' % urllib2.quote(src_path.encode('utf-8')))
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
new_obj_name = check_filename_with_rename(dst_repo_id, dst_path, obj_name)
|
||||
|
||||
|
Reference in New Issue
Block a user