diff options
author | Evan Prodromou <evan@status.net> | 2009-11-18 09:20:31 -0500 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2009-11-18 09:20:31 -0500 |
commit | fa35dab2265aba78f7c704c34eaef4100bddfd70 (patch) | |
tree | d12a78861162672e87e0c1330133d09aff651009 /plugins/Realtime/realtimeupdate.js | |
parent | 1cc10aaef63830ead662d8a962373554a949c951 (diff) | |
parent | 007418fdab8f9f0c718a18568bfbf4377bb85364 (diff) |
Merge branch '0.9.x' into mapstraction
Diffstat (limited to 'plugins/Realtime/realtimeupdate.js')
-rw-r--r-- | plugins/Realtime/realtimeupdate.js | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 9b9991b9e..d1cf1d507 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -34,6 +34,8 @@ RealtimeUpdate = { _favorurl: '', _deleteurl: '', _updatecounter: 0, + _maxnotices: 50, + _windowhasfocus: true, init: function(userid, replyurl, favorurl, deleteurl) { @@ -44,13 +46,16 @@ RealtimeUpdate = { DT = document.title; - $(window).blur(function() { + $(window).bind('focus', function(){ RealtimeUpdate._windowhasfocus = true; }); + + $(window).bind('blur', function() { $('#notices_primary .notice').removeClass('mark-top'); $('#notices_primary .notice:first').addClass('mark-top'); RealtimeUpdate._updatecounter = 0; document.title = DT; + RealtimeUpdate._windowhasfocus = false; return false; }); @@ -58,23 +63,32 @@ RealtimeUpdate = { receive: function(data) { - setTimeout(function() { - id = data.id; + id = data.id; + + // Don't add it if it already exists + if ($("#notice-"+id).length > 0) { + return; + } + + var noticeItem = RealtimeUpdate.makeNoticeItem(data); + $("#notices_primary .notices").prepend(noticeItem); + $("#notices_primary .notice:first").css({display:"none"}); + $("#notices_primary .notice:first").fadeIn(1000); - // Don't add it if it already exists - if ($("#notice-"+id).length > 0) { - return; - } + if ($('#notices_primary .notice').length > RealtimeUpdate._maxnotices) { + $("#notices_primary .notice:last .form_disfavor").unbind('submit'); + $("#notices_primary .notice:last .form_favor").unbind('submit'); + $("#notices_primary .notice:last .notice_reply").unbind('click'); + $("#notices_primary .notice:last").remove(); + } - var noticeItem = RealtimeUpdate.makeNoticeItem(data); - $("#notices_primary .notices").prepend(noticeItem); - $("#notices_primary .notice:first").css({display:"none"}); - $("#notices_primary .notice:first").fadeIn(1000); - SN.U.NoticeReply(); + SN.U.NoticeReply(); + SN.U.NoticeFavor(); + if (RealtimeUpdate._windowhasfocus === false) { RealtimeUpdate._updatecounter += 1; document.title = '('+RealtimeUpdate._updatecounter+') ' + DT; - }, 500); + } }, makeNoticeItem: function(data) @@ -178,9 +192,9 @@ RealtimeUpdate = { }); $('#showstream #notices_primary').css({'margin-top':'18px'}); - RT.click(function() { + RT.bind('click', function() { window.open(url, - timeline, + '', 'toolbar=no,resizable=yes,scrollbars=yes,status=yes,width=500,height=550'); return false; @@ -208,6 +222,12 @@ RealtimeUpdate = { 'left':'auto', 'right':'0' }); + + $('.notices .entry-title a, .notices .entry-content a').bind('click', function() { + window.open(this.href, ''); + + return false; + }); } } |