Prevents regular hovers over attachment anchors from making a GET

request for the thumbnail. There is 500 ms delay while on mouseover
state before going ahead with the request. Fun.
This commit is contained in:
Sarven Capadisli 2009-05-28 23:16:25 +00:00
parent f0dc97e4da
commit 6612993c1d
1 changed files with 4 additions and 1 deletions

View File

@ -276,6 +276,8 @@ function NoticeAttachments() {
$().jOverlay({url: $('address .url')[0].href+'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); $().jOverlay({url: $('address .url')[0].href+'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'});
return false; return false;
}); });
var t;
$("body:not(#shownotice) a.thumbnail").hover( $("body:not(#shownotice) a.thumbnail").hover(
function() { function() {
var anchor = $(this); var anchor = $(this);
@ -283,7 +285,7 @@ function NoticeAttachments() {
anchor.closest(".entry-title").addClass('ov'); anchor.closest(".entry-title").addClass('ov');
if (anchor.children('img').length == 0) { if (anchor.children('img').length == 0) {
setTimeout(function() { t = setTimeout(function() {
$.get($('address .url')[0].href+'/attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { $.get($('address .url')[0].href+'/attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) {
anchor.append(data); anchor.append(data);
}); });
@ -294,6 +296,7 @@ function NoticeAttachments() {
} }
}, },
function() { function() {
clearTimeout(t);
$("a.thumbnail").children('img').hide(); $("a.thumbnail").children('img').hide();
$(this).closest(".entry-title").removeClass('ov'); $(this).closest(".entry-title").removeClass('ov');
} }