Minor optimization to only bind an hover event to the notice at hand.

This commit is contained in:
Sarven Capadisli 2010-02-16 17:36:45 +01:00
parent 385fb94723
commit 2e258454f3

View File

@ -432,30 +432,32 @@ var SN = { // StatusNet
return false; return false;
}); });
var t; if ($('#shownotice').length == 0) {
$("body:not(#shownotice) .notice a.thumbnail").hover( var t;
function() { notice.find('a.thumbnail').hover(
var anchor = $(this); function() {
$("a.thumbnail").children('img').hide(); var anchor = $(this);
anchor.closest(".entry-title").addClass('ov'); $('a.thumbnail').children('img').hide();
anchor.closest(".entry-title").addClass('ov');
if (anchor.children('img').length === 0) { if (anchor.children('img').length === 0) {
t = 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);
}); });
}, 500); }, 500);
}
else {
anchor.children('img').show();
}
},
function() {
clearTimeout(t);
$('a.thumbnail').children('img').hide();
$(this).closest('.entry-title').removeClass('ov');
} }
else { );
anchor.children('img').show(); }
}
},
function() {
clearTimeout(t);
$("a.thumbnail").children('img').hide();
$(this).closest(".entry-title").removeClass('ov');
}
);
}, },
NoticeDataAttach: function() { NoticeDataAttach: function() {