comparison src/browser/sat_browser/chat.py @ 779:fc941d0d97f8

browser_side: fixed ContactsPanel scrolling
author souliane <souliane@mailoo.org>
date Mon, 30 Nov 2015 21:52:41 +0100
parents 78e4a79fbb5e
children f3cd261ea12f
comparison
equal deleted inserted replaced
778:31c682149d52 779:fc941d0d97f8
33 from pyjamas.ui.Label import Label 33 from pyjamas.ui.Label import Label
34 from pyjamas.ui.HTML import HTML 34 from pyjamas.ui.HTML import HTML
35 from pyjamas.ui.KeyboardListener import KEY_ENTER, KeyboardHandler 35 from pyjamas.ui.KeyboardListener import KEY_ENTER, KeyboardHandler
36 from pyjamas.ui.HTMLPanel import HTMLPanel 36 from pyjamas.ui.HTMLPanel import HTMLPanel
37 from pyjamas import DOM 37 from pyjamas import DOM
38 from pyjamas import Window
38 39
39 from datetime import datetime 40 from datetime import datetime
40 from time import time 41 from time import time
41 42
42 import html_tools 43 import html_tools
105 # FIXME: workaround for a pyjamas issue: calling hash on a class method always return a different value if that method is defined directly within the class (with the "def" keyword) 106 # FIXME: workaround for a pyjamas issue: calling hash on a class method always return a different value if that method is defined directly within the class (with the "def" keyword)
106 self.presenceListener = self.onPresenceUpdate 107 self.presenceListener = self.onPresenceUpdate
107 self.host.addListener('presence', self.presenceListener, [C.PROF_KEY_NONE]) 108 self.host.addListener('presence', self.presenceListener, [C.PROF_KEY_NONE])
108 self.avatarListener = self.onAvatarUpdate 109 self.avatarListener = self.onAvatarUpdate
109 host.addListener('avatar', self.avatarListener, [C.PROF_KEY_NONE]) 110 host.addListener('avatar', self.avatarListener, [C.PROF_KEY_NONE])
110 111 Window.addWindowResizeListener(self)
112
111 self._body.add(chat_area) 113 self._body.add(chat_area)
112 self.content = AbsolutePanel() 114 self.content = AbsolutePanel()
113 self.content.setStyleName('chatContent') 115 self.content.setStyleName('chatContent')
114 self.content_scroll = base_panel.ScrollPanelWrapper(self.content) 116 self.content_scroll = base_panel.ScrollPanelWrapper(self.content)
115 chat_area.add(self.content_scroll) 117 chat_area.add(self.content_scroll)
125 self.message_box.addKeyboardListener(self) 127 self.message_box.addKeyboardListener(self)
126 self.vpanel.add(self.message_box) 128 self.vpanel.add(self.message_box)
127 129
128 if type_ == C.CHAT_ONE2ONE: 130 if type_ == C.CHAT_ONE2ONE:
129 self.historyPrint(profile=self.profile) 131 self.historyPrint(profile=self.profile)
132
133 def onWindowResized(self, width=None, height=None):
134 ideal_height = self.content_scroll.getOffsetHeight()
135 self.occupants_panel.setHeight("%s%s" % (ideal_height, "px"))
130 136
131 @property 137 @property
132 def target(self): 138 def target(self):
133 # FIXME: for unknow reason, pyjamas doesn't use the method inherited from QuickChat 139 # FIXME: for unknow reason, pyjamas doesn't use the method inherited from QuickChat
134 # FIXME: must remove this when either pyjamas is fixed, or we use an alternative 140 # FIXME: must remove this when either pyjamas is fixed, or we use an alternative
283 box.states.setHTML(u''.join(states.values())) 289 box.states.setHTML(u''.join(states.values()))
284 290
285 if 'chat_state' in states.keys(): # start/stop sending "composing" state from now 291 if 'chat_state' in states.keys(): # start/stop sending "composing" state from now
286 self.chat_state_machine.started = not not states['chat_state'] 292 self.chat_state_machine.started = not not states['chat_state']
287 293
294 self.onWindowResized() # be sure to set the good height
295
288 def addGamePanel(self, widget): 296 def addGamePanel(self, widget):
289 """Insert a game panel to this Chat dialog. 297 """Insert a game panel to this Chat dialog.
290 298
291 @param widget (Widget): the game panel 299 @param widget (Widget): the game panel
292 """ 300 """