1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-20 19:08:21 +00:00

[repo] image thumbnail & preview: bug fix & improvements

This commit is contained in:
llj
2014-12-09 15:15:40 +08:00
parent c8cde80e7d
commit f98bc95b8c
3 changed files with 12 additions and 11 deletions

View File

@@ -1807,8 +1807,7 @@ $(function() {
this_img.attr("src", data.thumbnail_src).load(function() { this_img.attr("src", data.thumbnail_src).load(function() {
$(this).removeClass("not-thumbnail").addClass("thumbnail"); $(this).removeClass("not-thumbnail").addClass("thumbnail");
}); });
}, }
error: ajaxErrorHandler
}); });
}); });
}); });
@@ -2282,7 +2281,7 @@ var timer,
$("#repo-file-list").on({ $("#repo-file-list").on({
mouseenter: function() { mouseenter: function() {
var thumbnail = $(this), var thumbnail = $('.thumbnail', $(this)),
file_item = thumbnail.closest('.file-item'); file_item = thumbnail.closest('.file-item');
timer = setTimeout(function () { timer = setTimeout(function () {
@@ -2306,8 +2305,9 @@ $("#repo-file-list").on({
wrap_left = file_item_offset.left - wrap_width - caret_width; wrap_left = file_item_offset.left - wrap_width - caret_width;
if (wrap_left >= 0) { if (wrap_left >= 0) {
caret.removeClass("bottom-outer-caret").addClass("right-outer-caret"); caret.removeClass('bottom-outer-caret')
caret.css({'top':caret_pos_x + 'px', 'left':caret_pos_y + 'px'}); .addClass('right-outer-caret')
.css({'top':caret_pos_x + 'px', 'left':caret_pos_y + 'px'});
preview_wrap.css({ preview_wrap.css({
'top' : (thumbnail_offset.top + (thumbnail.height() - wrap_width)/2) + 'px', 'top' : (thumbnail_offset.top + (thumbnail.height() - wrap_width)/2) + 'px',
@@ -2326,13 +2326,14 @@ $("#repo-file-list").on({
}, },
error: ajaxErrorHandler error: ajaxErrorHandler
}); });
}, 500); }, 200);
}, },
mouseleave: function() { mouseleave: function() {
clearTimeout(timer); clearTimeout(timer);
preview_wrap.hide(); 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.
} }
}, ".thumbnail"); }, ".dirent-icon:has('.thumbnail')");
{% endif %} {% endif %}
{% include "snippets/shared_link_js.html" %} {% include "snippets/shared_link_js.html" %}

View File

@@ -1,5 +1,5 @@
import os import os
from seahub.utils import get_site_scheme_and_netloc from seahub.utils import get_service_url
def get_thumbnail_src(repo_id, obj_id, size): def get_thumbnail_src(repo_id, obj_id, size):
return os.path.join(get_site_scheme_and_netloc(), "thumbnail", repo_id, return os.path.join(get_service_url(), "thumbnail", repo_id,
obj_id, size) obj_id, size, '')

View File

@@ -63,7 +63,7 @@ def thumbnail_create(request, repo_id):
image.save(thumbnail_file, THUMBNAIL_EXTENSION) image.save(thumbnail_file, THUMBNAIL_EXTENSION)
except IOError, e: except IOError, e:
logger.error(e) logger.error(e)
return HttpResponse(json.dumps({'success': False}), content_type=content_type) return HttpResponse(json.dumps({'success': False}), status=500, content_type=content_type)
result['thumbnail_src'] = get_thumbnail_src(repo_id, obj_id, size) result['thumbnail_src'] = get_thumbnail_src(repo_id, obj_id, size)
return HttpResponse(json.dumps(result), content_type=content_type) return HttpResponse(json.dumps(result), content_type=content_type)