Mercurial > libervia-web
comparison browser_side/contact.py @ 187:d0503f8f15ef
browser side: scroller added to contacts panel
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 03 Mar 2013 17:37:43 +0100 |
parents | 9763dec220ed |
children | dd27072d8ae0 |
comparison
equal
deleted
inserted
replaced
186:72bb1d845b6a | 187:d0503f8f15ef |
---|---|
19 along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 """ | 20 """ |
21 | 21 |
22 import pyjd # this is dummy in pyjs | 22 import pyjd # this is dummy in pyjs |
23 from pyjamas.ui.SimplePanel import SimplePanel | 23 from pyjamas.ui.SimplePanel import SimplePanel |
24 from pyjamas.ui.ScrollPanel import ScrollPanel | |
24 from pyjamas.ui.VerticalPanel import VerticalPanel | 25 from pyjamas.ui.VerticalPanel import VerticalPanel |
25 from pyjamas.ui.HorizontalPanel import HorizontalPanel | 26 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
26 from pyjamas.ui.Label import Label | 27 from pyjamas.ui.Label import Label |
27 from pyjamas.ui.HTML import HTML | 28 from pyjamas.ui.HTML import HTML |
28 from pyjamas import Window | 29 from pyjamas import Window |
29 from pyjamas import DOM | 30 from pyjamas import DOM |
30 | 31 |
31 from pyjamas.ui.DragWidget import DragWidget, DragContainer | 32 from pyjamas.ui.DragWidget import DragWidget, DragContainer |
32 from browser_side.tools import html_sanitize | 33 from browser_side.tools import html_sanitize |
33 from jid import JID | 34 from jid import JID |
35 from __pyjamas__ import doc | |
34 | 36 |
35 class DragLabel(DragWidget): | 37 class DragLabel(DragWidget): |
36 | 38 |
37 def __init__(self, text, type): | 39 def __init__(self, text, type): |
38 DragWidget.__init__(self) | 40 DragWidget.__init__(self) |
156 class ContactPanel(SimplePanel): | 158 class ContactPanel(SimplePanel): |
157 """Manage the contacts and groups""" | 159 """Manage the contacts and groups""" |
158 | 160 |
159 def __init__(self, host): | 161 def __init__(self, host): |
160 SimplePanel.__init__(self) | 162 SimplePanel.__init__(self) |
163 | |
164 self.scroll_panel = ScrollPanel() | |
165 | |
161 self.host = host | 166 self.host = host |
162 self.groups={} | 167 self.groups={} |
163 self.connected = {} #jid connected as key and their status | 168 self.connected = {} #jid connected as key and their status |
164 | 169 |
165 self.vPanel = VerticalPanel() | 170 self.vPanel = VerticalPanel() |
172 self._groupList.setStyleName('groupList') | 177 self._groupList.setStyleName('groupList') |
173 | 178 |
174 self.vPanel.add(_title) | 179 self.vPanel.add(_title) |
175 self.vPanel.add(self._groupList) | 180 self.vPanel.add(self._groupList) |
176 self.vPanel.add(self._contact_list) | 181 self.vPanel.add(self._contact_list) |
177 self.add(self.vPanel) | 182 self.scroll_panel.add(self.vPanel) |
183 self.add(self.scroll_panel) | |
178 self.setStyleName('contactBox') | 184 self.setStyleName('contactBox') |
185 Window.addWindowResizeListener(self) | |
186 | |
187 def onWindowResized(self, width, height): | |
188 contact_panel_elt = self.getElement() | |
189 _elts = doc().getElementsByClassName('gwt-TabBar') | |
190 if not _elts.length: | |
191 print ("ERROR: no TabBar found, it should exist !") | |
192 tab_bar_h = height | |
193 else: | |
194 tab_bar_h = DOM.getAbsoluteTop( _elts.item(0)) or height #getAbsoluteTop can be 0 if tabBar is hidden | |
195 | |
196 ideal_height = tab_bar_h - DOM.getAbsoluteTop(contact_panel_elt) - 5 | |
197 self.scroll_panel.setHeight("%s%s" % (ideal_height, "px")); | |
198 | |
179 | 199 |
180 def updateContact(self, jid, attributes, groups): | 200 def updateContact(self, jid, attributes, groups): |
181 """Add a contact to the panel if it doesn't exist, update it else | 201 """Add a contact to the panel if it doesn't exist, update it else |
182 @param jid: jid | 202 @param jid: jid |
183 @attributes: cf SàT Bridge API's newContact | 203 @attributes: cf SàT Bridge API's newContact |