summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-08-18 15:14:32 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-08-18 15:14:32 +0200
commit313b824dd73648e3f86c1547a811c857bebb5a6d (patch)
treef5c060a7d22e94be56ca3aa39c684dff911a1def /apps/files_sharing
parentc70688e5d0c9f6dc4e56b5111b8f4a21a09e64a4 (diff)
downloadnextcloud-server-313b824dd73648e3f86c1547a811c857bebb5a6d.tar.gz
nextcloud-server-313b824dd73648e3f86c1547a811c857bebb5a6d.zip
Replace fileName variable with data.files[0].name
There is no need to store the file name, as the "data" parameter given to all the callbacks provides a "files" attribute with all the files that the callback refers to; moreover, it will always be a single file due to the use of "singleFileUploads" in the jQuery File Upload plugin. This also fixes the loading icon not disappearing when several files were uploaded at once. "singleFileUploads" causes the "add" callback to be called once for each file to be uploaded, so "fileName" was overwritten with the name of each new file in the upload set; when "fileName" was later used in the "done" callback to find the file in the list whose loading icon replace with the MIME type icon "fileName" always had the name of the last file, and thus its icon was the only one replaced. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/js/files_drop.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js
index edd7cc90827..67c1bfb3b4a 100644
--- a/apps/files_sharing/js/files_drop.js
+++ b/apps/files_sharing/js/files_drop.js
@@ -64,7 +64,7 @@
$('#drop-upload-done-indicator').addClass('hidden');
$('#drop-upload-progress-indicator').removeClass('hidden');
_.each(data['files'], function(file) {
- $('#public-upload ul').append(output({isUploading: true, name: escapeHTML(file.name)}));
+ $('#public-upload ul').append(output({isUploading: true, name: file.name}));
$('[data-toggle="tooltip"]').tooltip();
data.submit();
});
@@ -83,14 +83,12 @@
e.preventDefault();
});
var output = this.template();
- var fileName = undefined;
$('#public-upload').fileupload({
type: 'PUT',
dropZone: $('#public-upload'),
sequentialUploads: true,
add: function(e, data) {
Drop.addFileToUpload(e, data);
- fileName = escapeHTML(data.files[0].name);
//we return true to keep trying to upload next file even
//if addFileToUpload did not like the privious one
return true;
@@ -98,18 +96,18 @@
done: function(e, data) {
// Created
var mimeTypeUrl = OC.MimeType.getIconUrl(data.files[0].type);
- var fileItem = output({isUploading: false, iconSrc: mimeTypeUrl, name: fileName});
- Drop.updateFileItem(fileName, fileItem);
+ var fileItem = output({isUploading: false, iconSrc: mimeTypeUrl, name: data.files[0].name});
+ Drop.updateFileItem(data.files[0].name, fileItem);
},
fail: function(e, data) {
OC.Notification.showTemporary(OC.L10N.translate(
'files_sharing',
'Could not upload "{filename}"',
- {filename: fileName}
+ {filename: data.files[0].name}
));
var errorIconSrc = OC.imagePath('core', 'actions/error.svg');
- var fileItem = output({isUploading: false, iconSrc: errorIconSrc, name: fileName});
- Drop.updateFileItem(fileName, fileItem);
+ var fileItem = output({isUploading: false, iconSrc: errorIconSrc, name: data.files[0].name});
+ Drop.updateFileItem(data.files[0].name, fileItem);
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);