mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-17 15:53:28 +00:00
[repo] improvement for 'file upload'
This commit is contained in:
@@ -893,13 +893,44 @@ $('#upload-file').click(function () {
|
|||||||
{% else %}
|
{% else %}
|
||||||
$('#upload-file').click(function () {
|
$('#upload-file').click(function () {
|
||||||
var upload_success = false;
|
var upload_success = false;
|
||||||
|
var uploaded_files = [];
|
||||||
$('#upload-file-dialog').modal({
|
$('#upload-file-dialog').modal({
|
||||||
focus:false,
|
focus:false,
|
||||||
containerCss: {width:600, height:$(window).height()/1.5},
|
containerCss: {width:600, height:$(window).height()/1.5},
|
||||||
onClose: function() {
|
onClose: function() {
|
||||||
$.modal.close();
|
$.modal.close();
|
||||||
if (upload_success) {
|
if (upload_success) {
|
||||||
reqDirData('{% url 'repo_dir_data' repo.id %}?p=' + e(cur_path));
|
if ($('.file-item').length == 0) { // there is no file before this upload
|
||||||
|
reqDirData('{% url 'repo_dir_data' repo.id %}?p=' + e(cur_path));
|
||||||
|
} else {
|
||||||
|
var file_tpl = $($('.file-item')[0]);
|
||||||
|
var path = cur_path;
|
||||||
|
for (var i = 0, len = uploaded_files.length; i < len; i++) { // [{'id':'', 'name':'', 'size':''}]
|
||||||
|
var new_file_data = uploaded_files[i];
|
||||||
|
var new_name = new_file_data.name;
|
||||||
|
var new_file_item = file_tpl.clone(true);
|
||||||
|
new_file_item.attr('data-name', new_file_data.name).data('time', new Date().getTime()/1000);
|
||||||
|
|
||||||
|
$('.file-star', new_file_item).attr('title', "{% trans "unstarred" %}").attr('class', 'icon-star-empty file-star').attr('data-status', 'unstarred');
|
||||||
|
$('.dirent-icon img', new_file_item).attr('src', '{{MEDIA_URL}}img/file/file.png');
|
||||||
|
var name_link = $('.dirent-name a', new_file_item);
|
||||||
|
name_link.html(new_name).attr('href', name_link.attr('href').substr(0, name_link.attr('href').indexOf('?')) + '?p=' + e(path+new_name));
|
||||||
|
var size_ct = $('.dirent-size', new_file_item);
|
||||||
|
if (new_file_data.size != undefined) {
|
||||||
|
size_ct.html(filesizeformat(new_file_data.size, 1));
|
||||||
|
} else { // no 'size' field, for IE
|
||||||
|
size_ct.html('');
|
||||||
|
}
|
||||||
|
$('.dirent-update', new_file_item).html("{% trans "Just now" %}");
|
||||||
|
$('.file-download', new_file_item).attr('href', '{{SITE_ROOT}}repo/{{repo.id}}/' + new_file_data.id + '/?file_name=' + e(new_name) + '&op=download');
|
||||||
|
$('.file-share', new_file_item).data('link', '').data('token', '');
|
||||||
|
|
||||||
|
var file_history = $('.file-history', new_file_item), fh_href = file_history.attr('href');
|
||||||
|
file_history.attr('href', fh_href.substr(0, fh_href.indexOf('?')) + '?p=' + e(path+new_name));
|
||||||
|
file_tpl.before(new_file_item);
|
||||||
|
}
|
||||||
|
updateCmt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -925,6 +956,7 @@ $('#upload-file').click(function () {
|
|||||||
.bind('fileuploaddone', function(e, data) {
|
.bind('fileuploaddone', function(e, data) {
|
||||||
if (data.textStatus == 'success') {
|
if (data.textStatus == 'success') {
|
||||||
upload_success = true;
|
upload_success = true;
|
||||||
|
uploaded_files.push(data.result[0]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user