From f98bc95b8ce940f93fdcd11ac06bbee18e70ef1c Mon Sep 17 00:00:00 2001 From: llj Date: Tue, 9 Dec 2014 15:15:40 +0800 Subject: [PATCH] [repo] image thumbnail & preview: bug fix & improvements --- seahub/templates/repo.html | 15 ++++++++------- seahub/thumbnail/utils.py | 6 +++--- seahub/thumbnail/views.py | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/seahub/templates/repo.html b/seahub/templates/repo.html index 5f547d4cc3..96433b0c8f 100644 --- a/seahub/templates/repo.html +++ b/seahub/templates/repo.html @@ -1807,8 +1807,7 @@ $(function() { this_img.attr("src", data.thumbnail_src).load(function() { $(this).removeClass("not-thumbnail").addClass("thumbnail"); }); - }, - error: ajaxErrorHandler + } }); }); }); @@ -2282,7 +2281,7 @@ var timer, $("#repo-file-list").on({ mouseenter: function() { - var thumbnail = $(this), + var thumbnail = $('.thumbnail', $(this)), file_item = thumbnail.closest('.file-item'); timer = setTimeout(function () { @@ -2306,8 +2305,9 @@ $("#repo-file-list").on({ wrap_left = file_item_offset.left - wrap_width - caret_width; if (wrap_left >= 0) { - caret.removeClass("bottom-outer-caret").addClass("right-outer-caret"); - caret.css({'top':caret_pos_x + 'px', 'left':caret_pos_y + 'px'}); + 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', @@ -2326,13 +2326,14 @@ $("#repo-file-list").on({ }, error: ajaxErrorHandler }); - }, 500); + }, 200); }, mouseleave: function() { 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. } -}, ".thumbnail"); +}, ".dirent-icon:has('.thumbnail')"); {% endif %} {% include "snippets/shared_link_js.html" %} diff --git a/seahub/thumbnail/utils.py b/seahub/thumbnail/utils.py index 5a20c90147..81f90c1fe4 100644 --- a/seahub/thumbnail/utils.py +++ b/seahub/thumbnail/utils.py @@ -1,5 +1,5 @@ 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): - return os.path.join(get_site_scheme_and_netloc(), "thumbnail", repo_id, - obj_id, size) + return os.path.join(get_service_url(), "thumbnail", repo_id, + obj_id, size, '') diff --git a/seahub/thumbnail/views.py b/seahub/thumbnail/views.py index b2ee55ec63..0ad0b33a54 100644 --- a/seahub/thumbnail/views.py +++ b/seahub/thumbnail/views.py @@ -63,7 +63,7 @@ def thumbnail_create(request, repo_id): image.save(thumbnail_file, THUMBNAIL_EXTENSION) except IOError, 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) return HttpResponse(json.dumps(result), content_type=content_type)