diff --git a/media/css/seahub.css b/media/css/seahub.css index ab91ec7724..40063a7177 100644 --- a/media/css/seahub.css +++ b/media/css/seahub.css @@ -432,6 +432,33 @@ textarea:-moz-placeholder {/* for FF */ position:absolute; top:-11px; } +.right-outer-caret, +.right-outer-caret .inner-caret { + border-width:10px 0 10px 10px; + border-color: transparent transparent transparent #CBCBCB; +} +.right-outer-caret { + position:absolute; + right:-11px; +} +.right-outer-caret .inner-caret { + border-left-color:#fff; + top:-10px; + left:-11px; +} +.bottom-outer-caret, +.bottom-outer-caret .inner-caret { + border-width:10px 10px 0; +} +.bottom-outer-caret { + position:absolute; + bottom:-11px; +} +.bottom-outer-caret .inner-caret { + border-top-color:#fff; + top:-11px; + left:-10px; +} /**** info-item *****/ .info-item { border: 1px solid #eee; @@ -3304,3 +3331,24 @@ textarea:-moz-placeholder {/* for FF */ vertical-align:middle; line-height:16px; } + +/* image thumbnail */ +.file-item .thumbnail { + cursor: pointer; +} +#image-preview { + position:absolute; + top:0; + right:0; + bottom:0; + left:0; + margin:auto; +} +#preview-wrap { + position:absolute; + padding:10px; + border:1px solid #c9c9c9; + border-radius:5px; + background:#fff; + z-index:100; +} diff --git a/seahub/settings.py b/seahub/settings.py index 9fb9c4f168..ddd6aa0c5f 100644 --- a/seahub/settings.py +++ b/seahub/settings.py @@ -537,3 +537,4 @@ THUMBNAIL_ROOT = '%s/seahub/thumbnail/thumb/' % PROJECT_ROOT THUMBNAIL_EXTENSION = 'png' THUMBNAIL_DEFAULT_SIZE = '24' +PREVIEW_DEFAULT_SIZE = '100' diff --git a/seahub/templates/repo.html b/seahub/templates/repo.html index 85a29197b5..5f547d4cc3 100644 --- a/seahub/templates/repo.html +++ b/seahub/templates/repo.html @@ -1265,25 +1265,6 @@ $('.dir-item, .file-item').unbind().hover( // remove previously binded hover han opOnDirent(); -{% if not repo.encrypted and ENABLE_THUMBNAIL %} -// get thumbnails for image files -$(function() { - $('.not-thumbnail').each(function() { - var this_img = $(this), - file_name = $(this).parents('tr.file-item').attr('data-name'); - $.ajax({ - url: '{% url 'thumbnail_create' repo.id %}?path=' + e(cur_path+file_name), - cache: false, - dataType: 'json', - success: function(data) { - this_img.attr("src", data.thumbnail_src); - }, - error: ajaxErrorHandler - }); - }); -}); -{% endif %} - } // function dirOP ends here dirOP(); @@ -1812,6 +1793,27 @@ $('.file-share, .dir-share', context).click(function() { return false; }); +{% if not repo.encrypted and ENABLE_THUMBNAIL %} +// get thumbnails for image files +$(function() { + $('.not-thumbnail').each(function() { + var this_img = $(this), + file_name = $(this).parents('.file-item').attr('data-name'); + $.ajax({ + url: '{% url 'thumbnail_create' repo.id %}?path=' + e(cur_path+file_name), + cache: false, + dataType: 'json', + success: function(data) { + this_img.attr("src", data.thumbnail_src).load(function() { + $(this).removeClass("not-thumbnail").addClass("thumbnail"); + }); + }, + error: ajaxErrorHandler + }); + }); +}); +{% endif %} + } //function 'opOnDirent' ends here $('#add-new-file-form, #add-new-dir-form, #rename-form, #mv-form').submit(function() { @@ -2180,29 +2182,11 @@ $(window).scroll(function() { } else { ele_more.remove(); } - {% if not repo.encrypted and ENABLE_THUMBNAIL %} - // get thumbnails for image files - $(function() { - $('.not-thumbnail').each(function() { - var this_img = $(this), - file_name = $(this).parents('tr.file-item').attr('data-name'); - $.ajax({ - url: '{% url 'thumbnail_create' repo.id %}?path=' + e(cur_path+file_name), - cache: false, - dataType: 'json', - success: function(data) { - this_img.attr("src", data.thumbnail_src); - }, - error: ajaxErrorHandler - }); - }); - }); - {% endif %} }, error: function(xhr, textStatus, errorThrown) { var error; if (xhr.responseText) { - error = $.parseJSON(xhr.responseText).error; + error = $.parseJSON(xhr.responseText).error; } else { error = "{% trans "Failed. Please check the network." %}"; } @@ -2211,7 +2195,8 @@ $(window).scroll(function() { }); } }); - // webkit fires 'onpopstate' when page loads, use 'setTimeout' in 'window.onload' to avoid it. + +// webkit fires 'onpopstate' when page loads, use 'setTimeout' in 'window.onload' to avoid it. window.onload = function() { setTimeout(function () { if (window.history.pushState) { @@ -2234,7 +2219,7 @@ function updateCmt() { return false; }); }, - error: ajaxErrorHandler + error: ajaxErrorHandler }); } @@ -2285,6 +2270,71 @@ function updateCmt() { }); {% endif %} +{% if not repo.encrypted and ENABLE_THUMBNAIL %} +var timer, + default_size = {{PREVIEW_DEFAULT_SIZE}}, + preview_wrap = $('