Smarter call for hover events. It now makes a new GET for attachment

thumbnails on mouseover only if it hasn't been requested before on
that notice attachment.
This commit is contained in:
Sarven Capadisli 2009-05-28 22:59:22 +00:00
parent 3d13a44b66
commit f0dc97e4da

View File

@ -261,7 +261,7 @@ function NoticeAttachments() {
url : '', url : '',
color : '#000', color : '#000',
opacity : '0.6', opacity : '0.6',
zIndex : 9999, zIndex : '9999',
center : true, center : true,
imgLoading : $('address .url')[0].href+'theme/base/images/illustrations/illu_progress_loading-01.gif', imgLoading : $('address .url')[0].href+'theme/base/images/illustrations/illu_progress_loading-01.gif',
bgClickToClose : true, bgClickToClose : true,
@ -279,22 +279,22 @@ function NoticeAttachments() {
$("body:not(#shownotice) a.thumbnail").hover( $("body:not(#shownotice) a.thumbnail").hover(
function() { function() {
var anchor = $(this); var anchor = $(this);
$("a.thumbnail").children('img').remove(); $("a.thumbnail").children('img').hide();
anchor.closest(".entry-title").addClass('ov'); anchor.closest(".entry-title").addClass('ov');
setTimeout(function() { if (anchor.children('img').length == 0) {
$.get($('address .url')[0].href+'/attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { setTimeout(function() {
anchor.append(data); $.get($('address .url')[0].href+'/attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) {
}); anchor.append(data);
}, 500); });
}, 500);
setTimeout(function() { }
anchor.children('img').remove(); else {
anchor.closest(".entry-title").removeClass('ov'); anchor.children('img').show();
}, 3000); }
}, },
function() { function() {
$("a.thumbnail").children('img').remove(); $("a.thumbnail").children('img').hide();
$(this).closest(".entry-title").removeClass('ov'); $(this).closest(".entry-title").removeClass('ov');
} }
); );