diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-12-17 13:12:57 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-12-17 13:12:57 +0100 |
commit | ab35459cacea49eed0f6d9c5469dac75587df210 (patch) | |
tree | f41485448d691b6737f32ba9efc4888a5de8eac3 /apps/files/js | |
parent | 77c4c2856aa4cb27ca6ab77e5bedbaa65300d111 (diff) | |
download | nextcloud-server-ab35459cacea49eed0f6d9c5469dac75587df210.tar.gz nextcloud-server-ab35459cacea49eed0f6d9c5469dac75587df210.zip |
Propertly restore thumbnail on cancel/rename/move
Since the thumbnail is now in a div, the code that tries to change the
thumbnail have been adapted here as well.
Diffstat (limited to 'apps/files/js')
-rw-r--r-- | apps/files/js/filelist.js | 19 | ||||
-rw-r--r-- | apps/files/js/files.js | 11 |
2 files changed, 17 insertions, 13 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index b4702ce4f2b..62892f1b918 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1307,9 +1307,9 @@ } _.each(fileNames, function(fileName) { var $tr = self.findFileEl(fileName); - var $td = $tr.children('td.filename'); - var oldBackgroundImage = $td.css('background-image'); - $td.css('background-image', 'url('+ OC.imagePath('core', 'loading.gif') + ')'); + var $thumbEl = $tr.find('.thumbnail'); + var oldBackgroundImage = $thumbEl.css('background-image'); + $thumbEl.css('background-image', 'url('+ OC.imagePath('core', 'loading.gif') + ')'); // TODO: improve performance by sending all file names in a single call $.post( OC.filePath('files', 'ajax', 'move.php'), @@ -1351,7 +1351,7 @@ } else { OC.dialogs.alert(t('files', 'Error moving file'), t('files', 'Error')); } - $td.css('background-image', oldBackgroundImage); + $thumbEl.css('background-image', oldBackgroundImage); } ); }); @@ -1412,13 +1412,14 @@ try { var newName = input.val(); + var $thumbEl = tr.find('.thumbnail'); input.tipsy('hide'); form.remove(); if (newName !== oldname) { checkInput(); // mark as loading (temp element) - td.css('background-image', 'url('+ OC.imagePath('core', 'loading.gif') + ')'); + $thumbEl.css('background-image', 'url('+ OC.imagePath('core', 'loading.gif') + ')'); tr.attr('data-file', newName); var basename = newName; if (newName.indexOf('.') > 0 && tr.data('type') !== 'dir') { @@ -1841,7 +1842,7 @@ var translatedText = n('files', 'Uploading %n file', 'Uploading %n files', currentUploads); if (currentUploads === 1) { var img = OC.imagePath('core', 'loading.gif'); - data.context.find('td.filename').attr('style','background-image:url('+img+')'); + data.context.find('.thumbnail').css('background-image', 'url(' + img + ')'); uploadText.text(translatedText); uploadText.show(); } else { @@ -1880,7 +1881,7 @@ var translatedText = n('files', 'Uploading %n file', 'Uploading %n files', currentUploads); if (currentUploads === 0) { var img = OC.imagePath('core', 'filetypes/folder'); - data.context.find('td.filename').attr('style','background-image:url('+img+')'); + data.context.find('.thumbnail').css('background-image', 'url(' + img + ')'); uploadText.text(translatedText); uploadText.hide(); } else { @@ -1965,7 +1966,7 @@ //cleanup uploading to a dir var uploadText = $('tr .uploadtext'); var img = OC.imagePath('core', 'filetypes/folder'); - uploadText.parents('td.filename').attr('style','background-image:url('+img+')'); + uploadText.parents('td.filename').find('.thumbnail').css('background-image', 'url(' + img + ')'); uploadText.fadeOut(); uploadText.attr('currentUploads', 0); } @@ -1979,7 +1980,7 @@ //cleanup uploading to a dir var uploadText = $('tr .uploadtext'); var img = OC.imagePath('core', 'filetypes/folder'); - uploadText.parents('td.filename').attr('style','background-image:url('+img+')'); + uploadText.parents('td.filename').find('.thumbnail').css('background-image', 'url(' + img + ')'); uploadText.fadeOut(); uploadText.attr('currentUploads', 0); } diff --git a/apps/files/js/files.js b/apps/files/js/files.js index b11ef03eab2..314b8bf39c6 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -369,19 +369,22 @@ var createDragShadow = function(event) { var dir = FileList.getCurrentDirectory(); $(selectedFiles).each(function(i,elem) { + // TODO: refactor this with the table row creation code var newtr = $('<tr/>') .attr('data-dir', dir) .attr('data-file', elem.name) .attr('data-origin', elem.origin); - newtr.append($('<td/>').addClass('filename').text(elem.name)); - newtr.append($('<td/>').addClass('size').text(OC.Util.humanFileSize(elem.size))); + newtr.append($('<td class="filename" />').text(elem.name).css('background-size', 32)); + newtr.append($('<td class="size" />').text(OC.Util.humanFileSize(elem.size))); tbody.append(newtr); if (elem.type === 'dir') { - newtr.find('td.filename').attr('style','background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')'); + newtr.find('td.filename') + .css('background-image', 'url(' + OC.imagePath('core', 'filetypes/folder.png') + ')'); } else { var path = dir + '/' + elem.name; OCA.Files.App.files.lazyLoadPreview(path, elem.mime, function(previewpath) { - newtr.find('td.filename').attr('style','background-image:url('+previewpath+')'); + newtr.find('td.filename') + .css('background-image', 'url(' + previewpath + ')'); }, null, null, elem.etag); } }); |