1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-21 19:37:28 +00:00

[fileupload] some small fix

This commit is contained in:
llj
2014-12-19 11:57:10 +08:00
parent ad80242566
commit 1ed6d71293
2 changed files with 15 additions and 10 deletions

View File

@@ -290,7 +290,7 @@ $(function() {
'failed': "{% trans "File Upload failed" %}" 'failed': "{% trans "File Upload failed" %}"
}; };
var update_dir_names = []; // dirs with 'time' to be updated var dirs_to_update = []; // dirs with 'time' to be updated
var new_dir_names = []; var new_dir_names = [];
popup.fileupload({ popup.fileupload({
formData: {'parent_dir': cur_path}, formData: {'parent_dir': cur_path},
@@ -378,7 +378,9 @@ $(function() {
// for 'template_download' render // for 'template_download' render
file_uploaded.uploaded = true; file_uploaded.uploaded = true;
file_uploaded.relative_path = file_path; if (file_path) {
file_uploaded.relative_path = file_path.substring(0, file_path.lastIndexOf('/') + 1) + file_uploaded.name;
}
if (data.formData.parent_dir != cur_path) { if (data.formData.parent_dir != cur_path) {
return; return;
@@ -402,8 +404,8 @@ $(function() {
new_dir_names.push(new_dir_name); new_dir_names.push(new_dir_name);
} }
} else { } else {
if (update_dir_names.indexOf(new_dir_name) == -1) { if (dirs_to_update.indexOf(new_dir_name) == -1) {
update_dir_names.push(new_dir_name); dirs_to_update.push(new_dir_name);
} }
} }
{% endif %} {% endif %}
@@ -443,10 +445,10 @@ $(function() {
updateCmt(); updateCmt();
} }
} }
if (update_dir_names.length > 0) { if (dirs_to_update.length > 0) {
cur_dirs.each(function() { cur_dirs.each(function() {
var dir = $(this); var dir = $(this);
if (update_dir_names.indexOf(dir.attr('data-name')) != -1) { if (dirs_to_update.indexOf(dir.attr('data-name')) != -1) {
dir.attr('data-time', now); dir.attr('data-time', now);
$('.dirent-update', dir).html("{% trans "Just now" %}"); $('.dirent-update', dir).html("{% trans "Just now" %}");
} }
@@ -455,7 +457,7 @@ $(function() {
} }
// empty the arrays // empty the arrays
new_dir_names = []; new_dir_names = [];
update_dir_names = []; dirs_to_update = [];
}) })
// after tpl has rendered // after tpl has rendered
.bind('fileuploadcompleted', function() { // 'done' .bind('fileuploadcompleted', function() { // 'done'
@@ -470,6 +472,7 @@ $(function() {
cancel_all_btn.addClass('hide'); cancel_all_btn.addClass('hide');
close_icon.removeClass('hide'); close_icon.removeClass('hide');
total_progress.addClass('hide'); total_progress.addClass('hide');
saving_tip.hide();
if (data.errorThrown == 'abort') { // 'cancel' if (data.errorThrown == 'abort') { // 'cancel'
fu_status.html(fu_status_.canceled); fu_status.html(fu_status_.canceled);
} else { // 'error' } else { // 'error'

View File

@@ -97,7 +97,7 @@ var saving_tip = $('.saving-tip', form);
// Initialize the jQuery File Upload widget: // Initialize the jQuery File Upload widget:
form.fileupload({ form.fileupload({
formData: {'parent_dir': {{path}} }, formData: {'parent_dir': "{{path}}"},
// customize it for 'done' // customize it for 'done'
getFilesFromResponse: function (data) { getFilesFromResponse: function (data) {
if (data.result) { if (data.result) {
@@ -167,7 +167,9 @@ form.fileupload({
var file = data.result[0]; var file = data.result[0];
var file_path = data.files[0].relative_path; var file_path = data.files[0].relative_path;
file.uploaded = true; file.uploaded = true;
file.relative_path = file_path; if (file_path) {
file.relative_path = file_path.substring(0, file_path.lastIndexOf('/') + 1) + file.name;
}
var uploaded_done_link = "{% url "upload_file_done" %}" + "?fn=" + e(file.name) + "&repo_id=" + e("{{repo.id}}"); var uploaded_done_link = "{% url "upload_file_done" %}" + "?fn=" + e(file.name) + "&repo_id=" + e("{{repo.id}}");
if (file_path) { if (file_path) {
@@ -201,7 +203,7 @@ if ('webkitdirectory' in $('input[type="file"]', $('#add-file'))[0]) {
form.fileupload( form.fileupload(
'option', 'option',
'redirect', 'redirect',
window.location.href.replace(/\/repo\/[-a-z0-9]{36}\/.*/, '/media/cors/result.html?%s') window.location.href.replace(/\/repo\/[-a-z0-9]{36}\/.*/, '{{MEDIA_URL}}cors/result.html?%s')
); );
</script> </script>
{% endif %} {% endif %}