aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/files.js
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2013-08-14 13:25:07 +0200
committerGeorg Ehrke <developer@georgehrke.com>2013-08-14 13:27:01 +0200
commit4f525c864df7eb6caf1bc945c3c9e48b20bcce5e (patch)
tree41ecbcfd07ea2e127f59b7e2b5f4a6dbb7f49b2b /apps/files/js/files.js
parent4845ef5ac67b7785bf61f80359b1bc57b291c605 (diff)
downloadnextcloud-server-4f525c864df7eb6caf1bc945c3c9e48b20bcce5e.tar.gz
nextcloud-server-4f525c864df7eb6caf1bc945c3c9e48b20bcce5e.zip
lazy load preview icons
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r--apps/files/js/files.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 180c23cbfa4..7b01a5202da 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -366,8 +366,8 @@ $(document).ready(function() {
var tr=$('tr').filterAttr('data-file',name);
tr.attr('data-mime',result.data.mime);
tr.attr('data-id', result.data.id);
- var path = $('#dir').val()+'/'+name;
- getPreviewIcon(path, function(previewpath){
+ var path = $('#dir').val() + '/' + name;
+ lazyLoadPreview(path, result.data.mime, function(previewpath){
tr.find('td.filename').attr('style','background-image:url('+previewpath+')');
});
} else {
@@ -432,7 +432,7 @@ $(document).ready(function() {
tr.data('mime',mime).data('id',id);
tr.attr('data-id', id);
var path = $('#dir').val()+'/'+localName;
- getPreviewIcon(path, function(previewpath){
+ lazyLoadPreview(path, mime, function(previewpath){
tr.find('td.filename').attr('style','background-image:url('+previewpath+')');
});
});
@@ -639,7 +639,7 @@ var createDragShadow = function(event){
newtr.find('td.filename').attr('style','background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')');
} else {
var path = $('#dir').val()+'/'+elem.name;
- getPreviewIcon(path, function(previewpath){
+ lazyLoadPreview(path, elem.mime, function(previewpath){
newtr.find('td.filename').attr('style','background-image:url('+previewpath+')');
});
}
@@ -824,10 +824,18 @@ function getMimeIcon(mime, ready){
}
getMimeIcon.cache={};
-function getPreviewIcon(path, ready){
+function lazyLoadPreview(path, mime, ready) {
+ getMimeIcon(mime,ready);
var x = $('#filestable').data('preview-x');
var y = $('#filestable').data('preview-y');
- ready(OC.Router.generate('core_ajax_preview', {file: encodeURIComponent(path), x:x, y:y}));
+ var previewURL = OC.Router.generate('core_ajax_preview', {file: encodeURIComponent(path), x:x, y:y});
+ $.ajax({
+ url: previewURL,
+ type: 'GET',
+ success: function() {
+ ready(previewURL);
+ }
+ });
}
function getUniqueName(name){