lazy load preview icons

remotes/origin/stable6
Georg Ehrke 12 years ago
parent 4845ef5ac6
commit 4f525c864d
  1. 2
      apps/files/js/filelist.js
  2. 20
      apps/files/js/files.js

@ -186,7 +186,7 @@ var FileList={
tr.attr('data-id', id); tr.attr('data-id', id);
} }
var path = $('#dir').val()+'/'+name; var path = $('#dir').val()+'/'+name;
getPreviewIcon(path, function(previewpath){ lazyLoadPreview(path, mime, function(previewpath){
tr.find('td.filename').attr('style','background-image:url('+previewpath+')'); tr.find('td.filename').attr('style','background-image:url('+previewpath+')');
}); });
tr.find('td.filename').draggable(dragOptions); tr.find('td.filename').draggable(dragOptions);

@ -366,8 +366,8 @@ $(document).ready(function() {
var tr=$('tr').filterAttr('data-file',name); var tr=$('tr').filterAttr('data-file',name);
tr.attr('data-mime',result.data.mime); tr.attr('data-mime',result.data.mime);
tr.attr('data-id', result.data.id); tr.attr('data-id', result.data.id);
var path = $('#dir').val()+'/'+name; var path = $('#dir').val() + '/' + name;
getPreviewIcon(path, function(previewpath){ lazyLoadPreview(path, result.data.mime, function(previewpath){
tr.find('td.filename').attr('style','background-image:url('+previewpath+')'); tr.find('td.filename').attr('style','background-image:url('+previewpath+')');
}); });
} else { } else {
@ -432,7 +432,7 @@ $(document).ready(function() {
tr.data('mime',mime).data('id',id); tr.data('mime',mime).data('id',id);
tr.attr('data-id', id); tr.attr('data-id', id);
var path = $('#dir').val()+'/'+localName; var path = $('#dir').val()+'/'+localName;
getPreviewIcon(path, function(previewpath){ lazyLoadPreview(path, mime, function(previewpath){
tr.find('td.filename').attr('style','background-image:url('+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')+')'); newtr.find('td.filename').attr('style','background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')');
} else { } else {
var path = $('#dir').val()+'/'+elem.name; 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+')'); newtr.find('td.filename').attr('style','background-image:url('+previewpath+')');
}); });
} }
@ -824,10 +824,18 @@ function getMimeIcon(mime, ready){
} }
getMimeIcon.cache={}; getMimeIcon.cache={};
function getPreviewIcon(path, ready){ function lazyLoadPreview(path, mime, ready) {
getMimeIcon(mime,ready);
var x = $('#filestable').data('preview-x'); var x = $('#filestable').data('preview-x');
var y = $('#filestable').data('preview-y'); 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){ function getUniqueName(name){

Loading…
Cancel
Save