From 3b8d060c293014dd252ef33de8eb0bf6b4d35d32 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 16 Feb 2010 17:09:34 +0100 Subject: Fix to allow any notice item with an attachment to use the overlay view --- js/util.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/util.js b/js/util.js index 639049668..3021872d4 100644 --- a/js/util.js +++ b/js/util.js @@ -404,12 +404,10 @@ var SN = { // StatusNet }, NoticeWithAttachment: function(notice) { - if ($('.attachment', notice).length === 0) { + if (notice.find('.attachment').length === 0) { return; } - var notice_id = notice.attr('id'); - $.fn.jOverlay.options = { method : 'GET', data : '', @@ -429,13 +427,13 @@ var SN = { // StatusNet css : {'max-width':'542px', 'top':'5%', 'left':'32.5%'} }; - $('#'+notice_id+' a.attachment').click(function() { + notice.find('a.attachment').click(function() { $().jOverlay({url: $('address .url')[0].href+'attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); var t; - $("body:not(#shownotice) #"+notice_id+" a.thumbnail").hover( + $("body:not(#shownotice) .notice a.thumbnail").hover( function() { var anchor = $(this); $("a.thumbnail").children('img').hide(); -- cgit v1.2.3-54-g00ecf From 2e258454f396af9f95092b9564eee08179ff6be1 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 16 Feb 2010 17:36:45 +0100 Subject: Minor optimization to only bind an hover event to the notice at hand. --- js/util.js | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'js') diff --git a/js/util.js b/js/util.js index 3021872d4..3623337b9 100644 --- a/js/util.js +++ b/js/util.js @@ -432,30 +432,32 @@ var SN = { // StatusNet return false; }); - var t; - $("body:not(#shownotice) .notice a.thumbnail").hover( - function() { - var anchor = $(this); - $("a.thumbnail").children('img').hide(); - anchor.closest(".entry-title").addClass('ov'); - - if (anchor.children('img').length === 0) { - t = setTimeout(function() { - $.get($('address .url')[0].href+'attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { - anchor.append(data); - }); - }, 500); - } - else { - anchor.children('img').show(); + if ($('#shownotice').length == 0) { + var t; + notice.find('a.thumbnail').hover( + function() { + var anchor = $(this); + $('a.thumbnail').children('img').hide(); + anchor.closest(".entry-title").addClass('ov'); + + if (anchor.children('img').length === 0) { + t = setTimeout(function() { + $.get($('address .url')[0].href+'attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { + anchor.append(data); + }); + }, 500); + } + else { + anchor.children('img').show(); + } + }, + function() { + clearTimeout(t); + $('a.thumbnail').children('img').hide(); + $(this).closest('.entry-title').removeClass('ov'); } - }, - function() { - clearTimeout(t); - $("a.thumbnail").children('img').hide(); - $(this).closest(".entry-title").removeClass('ov'); - } - ); + ); + } }, NoticeDataAttach: function() { -- cgit v1.2.3-54-g00ecf