diff src/browser/sat_browser/notification.py @ 714:03e9fe91081c

browser_side: use favico.js to display alerts counter
author souliane <souliane@mailoo.org>
date Mon, 20 Jul 2015 10:18:02 +0200
parents e11e34ac0f67
children 2491898b3041
line wrap: on
line diff
--- a/src/browser/sat_browser/notification.py	Wed Jul 15 13:34:17 2015 +0200
+++ b/src/browser/sat_browser/notification.py	Mon Jul 20 10:18:02 2015 +0200
@@ -5,6 +5,7 @@
 
 from pyjamas import Window
 from pyjamas.Timer import Timer
+import favico.min.js
 
 import dialog
 
@@ -120,3 +121,20 @@
         if self.isHidden():
             self._notify(title, body, icon)
             self.highlightTab()
+
+
+class FaviconCounter(object):
+    """Display numbers over the favicon to signal e.g. waiting messages"""
+
+    def __init__(self):
+        # XXX: the file favico.min.js is loaded from public/libervia.html because I get NS_ERROR_FAILURE when it's loaded with Pyjamas. It sounds like a context issue, with the favicon not being found.
+
+        JS("""
+        self.counter = new top.Favico({
+            animation : 'slide',
+            bgColor: '#5CB85C',
+        });
+        """)
+
+    def update(self, count):
+        self.counter.badge(count)