Mercurial > libervia-web
view browser_side/notification.py @ 351:c943fd54c90e
browser_side: heavy refactorisation for microblogs:
- RichTextEditor inheritates from BaseTextEditor
- stuff related to display/edition have been moved from MicroblogEntry to LightTextEditor and RichTextEditor. Now the editors has two modes for display/edition and the microblog bubble is actually the editor itself.
- RichTextEditor's display mode uses a LightTextEditor (this will be used for WYSIWYG edition)
- addressing stuff of RichTextEditor have been moved to a child class RichMessageEditor (used for the rich text editor when clicking on the button left to the unibox)
- handle blog titles
TODO:
- fix encode/decode errors when sending special chars
- fix images maximal width in the bubble
- rich content WYSIWYG edition
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 12 Feb 2014 15:17:04 +0100 |
parents | 835a8ae799e7 |
children | f9130176bc8d |
line wrap: on
line source
from __pyjamas__ import JS class Notification(object): """ If the browser supports it, the user allowed it to and the tab is in the background, send desktop notifications on messages. Requires both Web Notifications and Page Visibility API. """ def __init__(self): JS(""" this.enabled = false; if (!('hidden' in document)) document.hidden = false; if (!('Notification' in window)) return; if (Notification.permission === 'granted') this.enabled = true; else if (Notification.permission === 'default') { Notification.requestPermission(function(permission){ if (permission !== 'granted') return; this.enabled = true; }); } """) def notify(self, title, body, icon='/media/icons/apps/48/sat.png'): JS(""" if (this.enabled && document.hidden) { notification = Notification(title, {body: body, icon: icon}); // Probably won’t work, but it doesn’t hurt to try. notification.addEventListener('click', function() { window.focus(); }); } """)