comparison browser_side/contact.py @ 290:3216c8d5432b

browser_side: set the ideal height for the contact panel size when displayed in the unibox panel
author souliane <souliane@mailoo.org>
date Tue, 10 Dec 2013 10:27:58 +0100
parents 2d6bd975a72d
children 2ab513a47e3b
comparison
equal deleted inserted replaced
289:20a9aedc60b5 290:3216c8d5432b
28 from pyjamas.ui.HTML import HTML 28 from pyjamas.ui.HTML import HTML
29 from jid import JID 29 from jid import JID
30 from pyjamas import Window 30 from pyjamas import Window
31 from pyjamas import DOM 31 from pyjamas import DOM
32 32
33 from browser_side.panels import ChatPanel, MicroblogPanel, PopupMenuPanel, WebPanel 33 from browser_side.panels import ChatPanel, MicroblogPanel, PopupMenuPanel, WebPanel, UniBoxPanel
34 from browser_side.tools import DragLabel, html_sanitize, setPresenceStyle 34 from browser_side.tools import DragLabel, html_sanitize, setPresenceStyle
35 from __pyjamas__ import doc 35 from __pyjamas__ import doc
36 36
37 37
38 class GroupLabel(DragLabel, Label, ClickHandler): 38 class GroupLabel(DragLabel, Label, ClickHandler):
241 self.setStyleName('contactBox') 241 self.setStyleName('contactBox')
242 Window.addWindowResizeListener(self) 242 Window.addWindowResizeListener(self)
243 243
244 def onWindowResized(self, width, height): 244 def onWindowResized(self, width, height):
245 contact_panel_elt = self.getElement() 245 contact_panel_elt = self.getElement()
246 _elts = doc().getElementsByClassName('gwt-TabBar') 246 classname = 'widgetsPanel' if isinstance(self.getParent().getParent(), UniBoxPanel) else'gwt-TabBar'
247 _elts = doc().getElementsByClassName(classname)
247 if not _elts.length: 248 if not _elts.length:
248 print ("ERROR: no TabBar found, it should exist !") 249 print ("ERROR: no element of class %s found, it should exist !" % classname)
249 tab_bar_h = height 250 tab_bar_h = height
250 else: 251 else:
251 tab_bar_h = DOM.getAbsoluteTop(_elts.item(0)) or height # getAbsoluteTop can be 0 if tabBar is hidden 252 tab_bar_h = DOM.getAbsoluteTop(_elts.item(0)) or height # getAbsoluteTop can be 0 if tabBar is hidden
252 253
253 ideal_height = tab_bar_h - DOM.getAbsoluteTop(contact_panel_elt) - 5 254 ideal_height = tab_bar_h - DOM.getAbsoluteTop(contact_panel_elt) - 5
254 self.scroll_panel.setHeight("%s%s" % (ideal_height, "px")); 255 self.scroll_panel.setHeight("%s%s" % (ideal_height, "px"))
255 256
256 def updateContact(self, jid, attributes, groups): 257 def updateContact(self, jid, attributes, groups):
257 """Add a contact to the panel if it doesn't exist, update it else 258 """Add a contact to the panel if it doesn't exist, update it else
258 @param jid: jid userhost as unicode 259 @param jid: jid userhost as unicode
259 @attributes: cf SàT Bridge API's newContact 260 @attributes: cf SàT Bridge API's newContact