summaryrefslogtreecommitdiff
path: root/plugins/Realtime/realtimeupdate.js
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-12-01 01:09:14 +0000
committerBrion Vibber <brion@pobox.com>2010-12-01 01:09:14 +0000
commit18cbdfb49bc2025768b51db7899c897ecadb7072 (patch)
treec0b19100a9ae2327cddef676d17d25c7e416ee90 /plugins/Realtime/realtimeupdate.js
parentc6f5975554db8421bebe52f9d17b5e4801d0a5bc (diff)
Ticket #2913: Realtime background update marker no longer triggers false positives when clearing the marker on switching away from the tab in Firefox 4
We were clearing the counter on the window title in the blur event, which gets fired *after* we switch away, thus triggering Firefox to mark the tab as updated again. Clearing the counter on *focus* instead avoids this, and keeps the counter out of the way as well.
Diffstat (limited to 'plugins/Realtime/realtimeupdate.js')
-rw-r--r--plugins/Realtime/realtimeupdate.js26
1 files changed, 22 insertions, 4 deletions
diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js
index 18834d03d..21938ee1d 100644
--- a/plugins/Realtime/realtimeupdate.js
+++ b/plugins/Realtime/realtimeupdate.js
@@ -84,15 +84,23 @@ RealtimeUpdate = {
RealtimeUpdate._documenttitle = document.title;
- $(window).bind('focus', function(){ RealtimeUpdate._windowhasfocus = true; });
+ $(window).bind('focus', function() {
+ RealtimeUpdate._windowhasfocus = true;
+
+ // Clear the counter on the window title when we focus in.
+ RealtimeUpdate._updatecounter = 0;
+ RealtimeUpdate.removeWindowCounter();
+ });
$(window).bind('blur', function() {
$('#notices_primary .notice').removeClass('mark-top');
$('#notices_primary .notice:first').addClass('mark-top');
- RealtimeUpdate._updatecounter = 0;
- document.title = RealtimeUpdate._documenttitle;
+ // While we're in the background, received messages will increment
+ // a counter that we put on the window title. This will cause some
+ // browsers to also flash or mark the tab or window title bar until
+ // you seek attention (eg Firefox 4 pinned app tabs).
RealtimeUpdate._windowhasfocus = false;
return false;
@@ -209,6 +217,17 @@ RealtimeUpdate = {
},
/**
+ * Clear the background update counter from the window title.
+ *
+ * @access private
+ *
+ * @fixme could interfere with anything else trying similar tricks
+ */
+ removeWindowCounter: function() {
+ document.title = RealtimeUpdate._documenttitle;
+ },
+
+ /**
* Builds a notice HTML block from JSON API-style data.
*
* @param {Object} data: extended JSON API-formatted notice
@@ -507,7 +526,6 @@ RealtimeUpdate = {
* dumping them into the timeline view.
*
* @fixme long timelines are not trimmed here as they are for things received while not paused
- * @fixme Ticket #2913: the queued counter on the window title does not get cleared
*
* @access private
*/