1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 07:08:55 +00:00

[image] use thumbnail for magnificPopups, file_view page & shared_file_view page

This commit is contained in:
llj
2017-04-18 17:28:29 +08:00
parent 4522201366
commit 2a8e40c3c0
13 changed files with 92 additions and 22 deletions

View File

@@ -222,13 +222,34 @@ define([
updateMagnificPopupOptions: function(options) {
var repo_id = this.dir.repo_id,
path = this.dir.path;
var use_thumbnail = true;
if (!app.pageOptions.enable_thumbnail || this.dir.encrypted) {
use_thumbnail = false;
}
var genItem = function(model) {
var name = model.get('obj_name');
var dirent_path = Common.pathJoin([path, name]);
var url_options = {
'repo_id': repo_id,
'path': Common.encodePath(dirent_path)
};
var item_src;
if (use_thumbnail) {
item_src = Common.getUrl($.extend(url_options, {
'name': 'thumbnail_get',
'size': 1024
}));
} else {
item_src = Common.getUrl($.extend(url_options, {
'name': 'view_raw_file'
}));
}
var item = {
'name': name,
'url': model.getWebUrl(),
'src': app.config.siteRoot + 'repo/' + repo_id + '/raw' + Common.encodePath(dirent_path)
'src': item_src
};
return item;
};

View File

@@ -32,6 +32,16 @@ define([
var tmpl = $(window).width() >= 768 ? this.template : this.mobileTemplate;
this.$el.html(tmpl(data));
if (app.pageOptions.enable_thumbnail) {
this.$('.img-name-link').attr('data-mfp-src', Common.getUrl({
'name': 'thumbnail_get',
'repo_id': data.repo_id,
'size': 1024,
'path': data.encoded_path
}));
}
return this;
},

View File

@@ -94,7 +94,6 @@ define([
render: function() {
this.$el.html(this.template());
$("#right-panel").html(this.$el);
this.$table = this.$('table');
this.$tableBody = this.$('tbody');

View File

@@ -144,10 +144,14 @@ define([
case 'group_discussions': return siteRoot + 'api2/groups/' + options.group_id + '/discussions/';
case 'group_discussion': return siteRoot + 'api2/groups/' + options.group_id + '/discussions/' + options.discussion_id + '/';
// Misc
// thumbnail
case 'thumbnail_create': return siteRoot + 'thumbnail/' + options.repo_id + '/create/';
case 'get_popup_notices': return siteRoot + 'ajax/get_popup_notices/';
case 'thumbnail_get': return siteRoot + 'thumbnail/' + options.repo_id + '/' + options.size + options.path;
// Misc
case 'view_raw_file': return siteRoot + 'repo/' + options.repo_id + '/raw' + options.path;
case 'get_popup_notices': return siteRoot + 'ajax/get_popup_notices/';
case 'notifications': return siteRoot + 'api/v2.1/notifications/';
case 'notification': return siteRoot + 'api/v2.1/notification/';
case 'user_enabled_modules': return siteRoot + 'api/v2.1/user-enabled-modules/';