changeset 187:d0503f8f15ef

browser side: scroller added to contacts panel
author Goffi <goffi@goffi.org>
date Sun, 03 Mar 2013 17:37:43 +0100
parents 72bb1d845b6a
children 39936b83da9d
files browser_side/contact.py browser_side/panels.py public/libervia.css
diffstat 3 files changed, 23 insertions(+), 2 deletions(-) [+]
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
--- a/browser_side/panels.py	Sun Mar 03 04:27:39 2013 +0100
+++ b/browser_side/panels.py	Sun Mar 03 17:37:43 2013 +0100
@@ -1036,7 +1036,7 @@
             tab_bar_h = 0
         else:
             tab_bar_h = _elts.item(0).offsetHeight
-        ideal_height = Window.getClientHeight() - DOM.getAbsoluteTop(tab_panel_elt) - tab_bar_h - 5
+        ideal_height = height - DOM.getAbsoluteTop(tab_panel_elt) - tab_bar_h - 5
         ideal_width = width - DOM.getAbsoluteLeft(tab_panel_elt) - 5
         self.setWidth("%s%s" % (ideal_width, "px"));
         self.setHeight("%s%s" % (ideal_height, "px"));
--- a/public/libervia.css	Sun Mar 03 04:27:39 2013 +0100
+++ b/public/libervia.css	Sun Mar 03 17:37:43 2013 +0100
@@ -378,6 +378,7 @@
 div.contactBox {
     margin-left: 20px;
     margin-top: 9px;
+    width: 100%;
 }
 
 .contactTitle {