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.
This commit is contained in:
Brion Vibber 2010-12-01 01:09:14 +00:00
parent c6f5975554
commit 18cbdfb49b
2 changed files with 23 additions and 5 deletions

View File

@ -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;
@ -208,6 +216,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.
*
@ -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
*/

File diff suppressed because one or more lines are too long