mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-23 12:27:48 +00:00
[repo] removed image 'thumbnail' & 'preview', bugfix for 'path link'
This commit is contained in:
@@ -1901,40 +1901,6 @@ $('.file-share, .dir-share', context).click(function() {
|
||||
return false;
|
||||
});
|
||||
|
||||
{% if not repo.encrypted and ENABLE_THUMBNAIL %}
|
||||
// get thumbnails for image files
|
||||
$(function() {
|
||||
var img_icons = $('.not-thumbnail');
|
||||
if (img_icons.length == 0) {
|
||||
return;
|
||||
}
|
||||
var get_thumbnail = function(i) {
|
||||
var img_icon = $(img_icons[i]),
|
||||
file_name = img_icon.closest('.file-item').attr('data-name');
|
||||
$.ajax({
|
||||
url: '{% url 'thumbnail_create' repo.id %}?path=' + e(parent_dir + file_name),
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (data) {
|
||||
img_icon.attr("src", data.thumbnail_src).load(function() {
|
||||
$(this).removeClass("not-thumbnail").addClass("thumbnail");
|
||||
});
|
||||
}
|
||||
},
|
||||
complete: function() {
|
||||
// cur_path may be changed. e.g., the user enter another directory
|
||||
if (i < img_icons.length - 1 && parent_dir == cur_path) {
|
||||
get_thumbnail(++i);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
var parent_dir = cur_path;
|
||||
get_thumbnail(0);
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
} //function 'opOnDirent' ends here
|
||||
|
||||
$('#add-new-file-form, #add-new-dir-form, #rename-form, #mv-form').submit(function() {
|
||||
@@ -2391,77 +2357,6 @@ function updateCmt() {
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
{% if not repo.encrypted and ENABLE_THUMBNAIL %}
|
||||
var timer, ajaxRequest = {},
|
||||
default_size = {{PREVIEW_DEFAULT_SIZE}},
|
||||
preview_wrap = $('<div id="preview-wrap"><img id="image-preview" src="" alt=""/><div class="outer-caret right-outer-caret"><div class="inner-caret"></div></div></div>')
|
||||
.appendTo("body")
|
||||
.css({'width':default_size + 'px', 'height':default_size + 'px'})
|
||||
.hide(),
|
||||
image_preview = $("#image-preview"),
|
||||
caret = image_preview.next();
|
||||
|
||||
$("#repo-file-list").on({
|
||||
mouseenter: function() {
|
||||
var thumbnail = $('.thumbnail', $(this)),
|
||||
file_item = thumbnail.closest('.file-item');
|
||||
|
||||
timer = setTimeout(function () {
|
||||
ajaxRequest = $.ajax({
|
||||
url: '{% url 'thumbnail_create' repo.id %}?path=' + e(cur_path+file_item.attr('data-name')) + '&size=' + default_size,
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (data) {
|
||||
image_preview.attr("src", data.thumbnail_src);
|
||||
|
||||
var file_item_offset = file_item.offset(),
|
||||
thumbnail_offset = thumbnail.offset(),
|
||||
|
||||
wrap_width = preview_wrap.outerWidth(),
|
||||
wrap_padding = parseInt(preview_wrap.css('padding-top')),
|
||||
|
||||
caret_width = parseInt(caret.css('border-top-width')),
|
||||
caret_pos_x = (default_size)/2 + wrap_padding - caret_width,
|
||||
caret_pos_y = default_size + 2 * wrap_padding,
|
||||
|
||||
wrap_left = file_item_offset.left - wrap_width - caret_width;
|
||||
|
||||
if (wrap_left >= 0) {
|
||||
caret.removeClass('bottom-outer-caret')
|
||||
.addClass('right-outer-caret')
|
||||
.css({'top':caret_pos_x + 'px', 'left':caret_pos_y + 'px'});
|
||||
|
||||
preview_wrap.css({
|
||||
'top' : (thumbnail_offset.top + (thumbnail.height() - wrap_width)/2) + 'px',
|
||||
'left' : wrap_left + 'px'
|
||||
}).fadeIn();
|
||||
} else {
|
||||
caret.removeClass("right-outer-caret")
|
||||
.addClass("bottom-outer-caret")
|
||||
.css({'top':caret_pos_y + 'px', 'left':caret_pos_x + 'px'});
|
||||
|
||||
preview_wrap.css({
|
||||
'top' : (file_item_offset.top - wrap_width) - caret_width + 'px',
|
||||
'left' : (thumbnail_offset.left + (thumbnail.width() - wrap_width)/2) + 'px'
|
||||
}).fadeIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 200);
|
||||
},
|
||||
mouseleave: function() {
|
||||
if (ajaxRequest.hasOwnProperty('abort')) {
|
||||
ajaxRequest.abort();
|
||||
}
|
||||
clearTimeout(timer);
|
||||
preview_wrap.hide();
|
||||
image_preview.attr('src', ''); // for ff. In ff, when hover, the last preview image would be shown first, then the right one.
|
||||
}
|
||||
}, ".dirent-icon:has('.thumbnail')");
|
||||
{% endif %}
|
||||
|
||||
{% include "snippets/shared_link_js.html" %}
|
||||
{% include "snippets/bottom_bar.html" %} {# moved to the right side. Tue Nov 11 15:47:08 CST 2014 #}
|
||||
</script>
|
||||
|
@@ -107,6 +107,7 @@ $('#shared-links .rm-link').click(function() {
|
||||
}
|
||||
$.ajax({
|
||||
url: ajax_url + '?t=' + e(link_token),
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
op.parents('tr').remove();
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<p class="path fleft">
|
||||
{% for name, link in zipped %}
|
||||
{% if forloop.first or not forloop.last %}
|
||||
<a href="{% url 'view_common_lib_dir' repo.id link|urlencode|strip_slash %}" class="dir-link normal">{{ name }}</a> /
|
||||
<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/?p={{ link|urlencode }}" class="dir-link normal">{{ name }}</a> /
|
||||
{% else %}
|
||||
<span id="cur-dir-name" data-name="{{ name }}">{{ name }}</span> /
|
||||
{% endif %}
|
||||
|
@@ -55,15 +55,9 @@
|
||||
<span title="{% trans 'unstarred' %}" class="icon-star-empty file-star" data-status="unstarred"></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if dirent.allow_generate_thumbnail %}
|
||||
{% if dirent.thumbnail_src %}
|
||||
<td class="dirent-icon"><img class="thumbnail" src="{{ dirent.thumbnail_src }}" alt="{% trans "File"%}" /></td>
|
||||
{% else %}
|
||||
<td class="dirent-icon"><img class="not-thumbnail" src="{{ MEDIA_URL }}img/file/{{ dirent.obj_name|file_icon_filter }}" alt="{% trans "File"%}" /></td>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<td class="dirent-icon"><img src="{{ MEDIA_URL }}img/file/{{ dirent.obj_name|file_icon_filter }}" alt="{% trans "File"%}" /></td>
|
||||
{% endif %}
|
||||
<td class="dirent-icon">
|
||||
<img src="{{ MEDIA_URL }}img/file/{{ dirent.obj_name|file_icon_filter }}" alt="{% trans "File"%}" />
|
||||
</td>
|
||||
<td>
|
||||
{% if repo.encrypted and repo.enc_version == 2 and not server_crypto %}
|
||||
<span class="dirent-name">{{ dirent.obj_name }}</span>
|
||||
|
@@ -297,14 +297,6 @@ def list_dir(request, repo_id):
|
||||
uploadlink = get_uploadlink(repo.id, username, path)
|
||||
dir_shared_upload_link = get_dir_shared_upload_link(uploadlink)
|
||||
|
||||
for f in file_list:
|
||||
file_path = posixpath.join(path, f.obj_name)
|
||||
if allow_generate_thumbnail(request, repo_id, file_path):
|
||||
f.allow_generate_thumbnail = True
|
||||
if os.path.exists(os.path.join(THUMBNAIL_ROOT, str(THUMBNAIL_DEFAULT_SIZE), f.obj_id)):
|
||||
src = get_thumbnail_src(repo.id, THUMBNAIL_DEFAULT_SIZE, file_path)
|
||||
f.encoded_thumbnail_src = urlquote(src)
|
||||
|
||||
ctx = {
|
||||
'repo': repo,
|
||||
'zipped': zipped,
|
||||
@@ -324,7 +316,6 @@ def list_dir(request, repo_id):
|
||||
'enable_upload_folder': settings.ENABLE_UPLOAD_FOLDER,
|
||||
'current_commit': head_commit,
|
||||
'info_commit': info_commit,
|
||||
'ENABLE_THUMBNAIL': ENABLE_THUMBNAIL,
|
||||
}
|
||||
html = render_to_string('snippets/repo_dir_data.html', ctx,
|
||||
context_instance=RequestContext(request))
|
||||
@@ -388,14 +379,6 @@ def list_dir_more(request, repo_id):
|
||||
if dirent_more:
|
||||
more_start = offset + 100
|
||||
|
||||
for f in file_list:
|
||||
file_path = posixpath.join(path, f.obj_name)
|
||||
if allow_generate_thumbnail(request, repo_id, file_path):
|
||||
f.allow_generate_thumbnail = True
|
||||
if os.path.exists(os.path.join(THUMBNAIL_ROOT, str(THUMBNAIL_DEFAULT_SIZE), f.obj_id)):
|
||||
src = get_thumbnail_src(repo.id, THUMBNAIL_DEFAULT_SIZE, file_path)
|
||||
f.encoded_thumbnail_src = urlquote(src)
|
||||
|
||||
ctx = {
|
||||
'repo': repo,
|
||||
'user_perm': user_perm,
|
||||
@@ -405,7 +388,6 @@ def list_dir_more(request, repo_id):
|
||||
'file_list': file_list,
|
||||
'ENABLE_SUB_LIBRARY': ENABLE_SUB_LIBRARY,
|
||||
'sub_lib_enabled': sub_lib_enabled,
|
||||
'ENABLE_THUMBNAIL': ENABLE_THUMBNAIL,
|
||||
}
|
||||
html = render_to_string('snippets/repo_dirents.html', ctx,
|
||||
context_instance=RequestContext(request))
|
||||
|
Reference in New Issue
Block a user