summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-08-29 14:49:05 +0200
committerGitHub <noreply@github.com>2017-08-29 14:49:05 +0200
commiteb1a8a1934d0ee1e2d46aa0218092a30a679e853 (patch)
treeba14414e31e1332fe150a72db8458baa668a2641
parent1f7ea1f295ec2158667a85419c66cf1c1065a580 (diff)
parent575f0c842194bb4011ea06a39dd55edcc89e1b50 (diff)
downloadnextcloud-server-eb1a8a1934d0ee1e2d46aa0218092a30a679e853.tar.gz
nextcloud-server-eb1a8a1934d0ee1e2d46aa0218092a30a679e853.zip
Merge pull request #6278 from nextcloud/stable12-6182-fixes-in-files-drop-js
[stable12] Fixes in files_drop.js
-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);