Mercurial > libervia-web
diff browser_side/contact.py @ 370:30d03d9f07e4
browser_side: refactorization of the file tools.py:
- tools.py renamed to html_tools.py
- method setPresenceStyle moved to contact.py
- classes DragLabel and LiberviaDragWidget moved to base_widget.py
- class FilterFileUpload moved to file_tools.py
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 23 Feb 2014 17:01:03 +0100 |
parents | ce5b33f499c5 |
children | 564208366dd6 |
line wrap: on
line diff
--- a/browser_side/contact.py Sun Feb 23 16:20:03 2014 +0100 +++ b/browser_side/contact.py Sun Feb 23 17:01:03 2014 +0100 @@ -29,11 +29,30 @@ from pyjamas import DOM from browser_side.base_panels import PopupMenuPanel +from browser_side.base_widget import DragLabel from browser_side.panels import ChatPanel, MicroblogPanel, WebPanel, UniBoxPanel -from browser_side.tools import DragLabel, html_sanitize, setPresenceStyle +from browser_side.tools import html_sanitize from __pyjamas__ import doc +def setPresenceStyle(element, presence, base_style="contact"): + """ + Set the CSS style of a contact's element according to its presence. + @param item: the UI element of the contact + @param presence: a value in ("", "chat", "away", "dnd", "xa"). + @param base_style: the base name of the style to apply + """ + if not hasattr(element, 'presence_style'): + element.presence_style = None + style = '%s-%s' % (base_style, presence or 'connected') + if style == element.presence_style: + return + if element.presence_style is not None: + element.removeStyleName(element.presence_style) + element.addStyleName(style) + element.presence_style = style + + class GroupLabel(DragLabel, Label, ClickHandler): def __init__(self, host, group): self.group = group