diff 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
line wrap: on
line diff
--- a/browser_side/contact.py	Sun Mar 03 04:27:39 2013 +0100
+++ b/browser_side/contact.py	Sun Mar 03 17:37:43 2013 +0100
@@ -21,6 +21,7 @@
 
 import pyjd # this is dummy in pyjs
 from pyjamas.ui.SimplePanel import SimplePanel
+from pyjamas.ui.ScrollPanel import ScrollPanel
 from pyjamas.ui.VerticalPanel import VerticalPanel
 from pyjamas.ui.HorizontalPanel import HorizontalPanel
 from pyjamas.ui.Label import Label
@@ -31,6 +32,7 @@
 from pyjamas.ui.DragWidget import DragWidget, DragContainer
 from browser_side.tools import html_sanitize
 from jid import JID
+from __pyjamas__ import doc
 
 class DragLabel(DragWidget):
 
@@ -158,6 +160,9 @@
     
     def __init__(self, host):
         SimplePanel.__init__(self)
+
+        self.scroll_panel = ScrollPanel()
+        
         self.host = host
         self.groups={}
         self.connected = {} #jid connected as key and their status
@@ -174,8 +179,23 @@
         self.vPanel.add(_title)
         self.vPanel.add(self._groupList)
         self.vPanel.add(self._contact_list)
-        self.add(self.vPanel)
+        self.scroll_panel.add(self.vPanel)
+        self.add(self.scroll_panel)
         self.setStyleName('contactBox')
+        Window.addWindowResizeListener(self)
+
+    def onWindowResized(self, width, height):
+        contact_panel_elt = self.getElement()
+        _elts = doc().getElementsByClassName('gwt-TabBar')
+        if not _elts.length:
+            print ("ERROR: no TabBar found, it should exist !")
+            tab_bar_h = height
+        else:
+            tab_bar_h = DOM.getAbsoluteTop( _elts.item(0)) or height #getAbsoluteTop can be 0 if tabBar is hidden
+
+        ideal_height = tab_bar_h - DOM.getAbsoluteTop(contact_panel_elt) - 5
+        self.scroll_panel.setHeight("%s%s" % (ideal_height, "px"));
+        
 
     def updateContact(self, jid, attributes, groups):
         """Add a contact to the panel if it doesn't exist, update it else