]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Realtime/realtimeupdate.js
Ticket #2913: Realtime background update marker no longer triggers false positives...
[quix0rs-gnu-social.git] / plugins / Realtime / realtimeupdate.js
index 18834d03df8dd30b0af16088c173c817043f439d..21938ee1d2cb7d9056d166ae1130a346563ee580 100644 (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
       */