only load sidebar previews when we know it's available

This commit is contained in:
Robin Appelman 2016-07-26 13:51:18 +02:00
parent 276383ebf5
commit b9dfc1674c
2 changed files with 16 additions and 5 deletions

View File

@ -852,7 +852,8 @@
type: $el.attr('data-type'),
size: parseInt($el.attr('data-size'), 10),
etag: $el.attr('data-etag'),
permissions: parseInt($el.attr('data-permissions'), 10)
permissions: parseInt($el.attr('data-permissions'), 10),
hasPreview: $el.attr('data-has-preview') === 'true'
};
var icon = $el.attr('data-icon');
if (icon) {
@ -1068,7 +1069,8 @@
"data-mime": mime,
"data-mtime": mtime,
"data-etag": fileData.etag,
"data-permissions": fileData.permissions || this.getDirectoryPermissions()
"data-permissions": fileData.permissions || this.getDirectoryPermissions(),
"data-has-preview": fileData.hasPreview !== false
});
if (dataIcon) {

View File

@ -32,9 +32,18 @@
},
loadPreview: function (model, $thumbnailDiv, $thumbnailContainer) {
if (model.get('hasPreview') === false) {
var mimeIcon = OC.MimeType.getIconUrl(model.get('mimetype'));
$thumbnailDiv.removeClass('icon-loading icon-32');
$thumbnailContainer.removeClass('image'); //fall back to regular view
$thumbnailDiv.css({
'background-image': 'url("' + mimeIcon + '")'
});
} else {
var handler = this.getPreviewHandler(model.get('mimetype'));
var fallback = this.fallbackPreview.bind(this, model, $thumbnailDiv, $thumbnailContainer);
handler(model, $thumbnailDiv, $thumbnailContainer, fallback);
}
},
// previews for images and mimetype icons