mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 13:50:07 +00:00
[favorites] show thumbnail for image files
This commit is contained in:
@@ -35,12 +35,57 @@ define([
|
||||
this.renderThead();
|
||||
this.starredFiles.each(this.addOne, this);
|
||||
this.$table.show();
|
||||
this.getImageThumbnail();
|
||||
} else {
|
||||
this.$emptyTip.show();
|
||||
this.$table.hide();
|
||||
}
|
||||
},
|
||||
|
||||
getImageThumbnail: function() {
|
||||
if (!app.pageOptions.enable_thumbnail) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var images = this.starredFiles.filter(function(item) {
|
||||
// 'item' is a model
|
||||
return Common.imageCheck(item.get('file_name'));
|
||||
});
|
||||
if (images.length == 0) {
|
||||
return ;
|
||||
}
|
||||
|
||||
var images_len = images.length;
|
||||
var thumbnail_size = app.pageOptions.thumbnail_default_size;
|
||||
|
||||
var get_thumbnail = function(i) {
|
||||
var cur_img = images[i];
|
||||
$.ajax({
|
||||
url: Common.getUrl({
|
||||
name: 'thumbnail_create',
|
||||
repo_id: cur_img.get('repo_id')
|
||||
}),
|
||||
data: {
|
||||
'path': cur_img.get('path'),
|
||||
'size': thumbnail_size
|
||||
},
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
cur_img.set({
|
||||
'encoded_thumbnail_src': data.encoded_thumbnail_src
|
||||
});
|
||||
},
|
||||
complete: function() {
|
||||
if (i < images_len - 1) {
|
||||
get_thumbnail(++i);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
get_thumbnail(0);
|
||||
},
|
||||
|
||||
showStarredFiles: function() {
|
||||
this.$table.hide();
|
||||
this.$loadingTip.show();
|
||||
|
Reference in New Issue
Block a user