summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-08-18 14:26:15 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-08-18 14:26:15 +0200
commitc70688e5d0c9f6dc4e56b5111b8f4a21a09e64a4 (patch)
tree990cb5e9dade80b01c415d4ab2502974ac769501 /apps/files_sharing
parent2860ce027ab0d458bbcc5841d5b7cb8c7eae03e9 (diff)
downloadnextcloud-server-c70688e5d0c9f6dc4e56b5111b8f4a21a09e64a4.tar.gz
nextcloud-server-c70688e5d0c9f6dc4e56b5111b8f4a21a09e64a4.zip
Update the whole file item instead of only its contents
The "done" and "fail" callbacks both update the item for the uploaded file using "setFileIcon". "setFileIcon" updates the contents of the "<li>" element for the file, but the "fail" callback was giving "setFileIcon" an element generated by the template, so the resulting HTML contained a "<li>" element nested in another "<li>" element. However, generating the HTML is better done through a template, so the template now receives the icon to show in order to be used by a successful upload and a failed one, and "setFileIcon" was changed to "updateFileItem". Note that the mimeTypeUrl does no longer need to be escaped, as Handlebars templates escape the needed characters automatically. 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.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js
index b3956948ee4..edd7cc90827 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 = {
@@ -72,8 +72,8 @@
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();
},
@@ -98,8 +98,8 @@
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: fileName});
+ Drop.updateFileItem(fileName, fileItem);
},
fail: function(e, data) {
OC.Notification.showTemporary(OC.L10N.translate(
@@ -107,8 +107,9 @@
'Could not upload "{filename}"',
{filename: fileName}
));
- 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: fileName});
+ Drop.updateFileItem(fileName, fileItem);
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);