summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2017-08-26 17:58:30 +0200
committerGitHub <noreply@github.com>2017-08-26 17:58:30 +0200
commit85d5a71258892e53e60135ec0c644eb90eaa7991 (patch)
tree926b2617de4ac690e1caf418c3a7bf7a03869b2c /apps/files_sharing
parent141bee931f0e1f51cd81772c5ac60274bc0df8d7 (diff)
parent4d003c812de88c922ff9835d910e5a01b7bb0d28 (diff)
downloadnextcloud-server-85d5a71258892e53e60135ec0c644eb90eaa7991.tar.gz
nextcloud-server-85d5a71258892e53e60135ec0c644eb90eaa7991.zip
Merge pull request #6182 from nextcloud/fixes-in-files-drop-js
Fixes in files_drop.js
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/js/files_drop.js30
1 files changed, 14 insertions, 16 deletions
diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js
index f1fc71c6ce2..8d1273f1872 100644
--- a/apps/files_sharing/js/files_drop.js
+++ b/apps/files_sharing/js/files_drop.js
@@ -14,7 +14,7 @@
'{{#if isUploading}}' +
'<span class="icon-loading-small"></span> {{name}}' +
'{{else}}' +
- '<img src="' + OC.imagePath('core', 'actions/error.svg') + '"/> {{name}}' +
+ '<img src="{{iconSrc}}"/> {{name}}' +
'{{/if}}' +
'</li>';
var Drop = {
@@ -63,17 +63,16 @@
$('#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)}));
- $('[data-toggle="tooltip"]').tooltip();
- data.submit();
- });
+
+ $('#public-upload ul').append(output({isUploading: true, name: data.files[0].name}));
+ $('[data-toggle="tooltip"]').tooltip();
+ data.submit();
return true;
},
- setFileIcon: function (fileName,fileIcon) {
- $('#public-upload ul li[data-name="' + fileName + '"]').html(fileIcon);
+ updateFileItem: function (fileName, fileItem) {
+ $('#public-upload ul li[data-name="' + fileName + '"]').replaceWith(fileItem);
$('[data-toggle="tooltip"]').tooltip();
},
@@ -83,14 +82,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,17 +95,18 @@
done: function(e, data) {
// Created
var mimeTypeUrl = OC.MimeType.getIconUrl(data.files[0].type);
- var fileIcon = '<img src="' + escapeHTML(mimeTypeUrl) + '"/> ' + fileName;
- Drop.setFileIcon(fileName,fileIcon);
+ var fileItem = output({isUploading: false, iconSrc: mimeTypeUrl, name: data.files[0].name});
+ Drop.updateFileItem(data.files[0].name, fileItem);
},
- fail: function(e, data, errorThrown) {
+ fail: function(e, data) {
OC.Notification.showTemporary(OC.L10N.translate(
'files_sharing',
'Could not upload "{filename}"',
- {filename: fileName}
+ {filename: data.files[0].name}
));
- var fileIcon = output({isUploading: false, name: fileName});
- Drop.setFileIcon(fileName,fileIcon);
+ var errorIconSrc = OC.imagePath('core', 'actions/error.svg');
+ 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);