comparison libervia.py @ 9:c80b75bf2e91

browser: misc appearance change
author Goffi <goffi@goffi.org>
date Fri, 25 Mar 2011 00:31:27 +0100
parents a663b9955cf3
children 331c093e4eb3
comparison
equal deleted inserted replaced
8:88ae360198ee 9:c80b75bf2e91
160 contact.removeStyleName("selected") 160 contact.removeStyleName("selected")
161 161
162 class EmptyPanel(DropWidget, SimplePanel): 162 class EmptyPanel(DropWidget, SimplePanel):
163 """Empty dropable panel""" 163 """Empty dropable panel"""
164 164
165 def __init__(self): 165 def __init__(self, host, data):
166 SimplePanel.__init__(self) 166 SimplePanel.__init__(self)
167 self.host = host
168 self.data = data
167 _panel = HTMLPanel("&nbsp;") 169 _panel = HTMLPanel("&nbsp;")
168 #_panel.setHeight('100%')
169 #_panel.setWidth('100%')
170 self.add(_panel) 170 self.add(_panel)
171 self.setHeight('100%') 171 self.setHeight('100%')
172 DropWidget.__init__(self) 172 DropWidget.__init__(self)
173 173
174 def onDragEnter(self, event): 174 def onDragEnter(self, event):
175 print "Empty Panel: onDragEnter"
176 self.addStyleName('dragover') 175 self.addStyleName('dragover')
177 DOM.eventPreventDefault(event) 176 DOM.eventPreventDefault(event)
178 177
179 def onDragLeave(self, event): 178 def onDragLeave(self, event):
180 print "Empty Panel: onDragLeave"
181 self.removeStyleName('dragover') 179 self.removeStyleName('dragover')
182 180
183 def onDragOver(self, event): 181 def onDragOver(self, event):
184 print "Empty Panel: onDragOver"
185 DOM.eventPreventDefault(event) 182 DOM.eventPreventDefault(event)
186 183
187 def onDrop(self, event): 184 def onDrop(self, event):
188 print "Empty Panel: onDragOver" 185 print "Empty Panel: onDrop"
189 dt = event.dataTransfer 186 dt = event.dataTransfer
190 #'text', 'text/plain', and 'Text' are equivalent. 187 #'text', 'text/plain', and 'Text' are equivalent.
191 try: 188 try:
192 item = dt.getData("text/plain") 189 item = dt.getData("text/plain")
193 print "message: %s" % item 190 print "message: %s" % item
194 except: 191 except:
195 print "no message found" 192 print "no message found"
193 item='&nbsp;'
196 DOM.eventPreventDefault(event) 194 DOM.eventPreventDefault(event)
195 self.host.mpanels.insert(0,MicroblogPanel(item))
196 self.host.middle_panel.changePanel(self.data,self.host.mpanels[0])
197 197
198 198
199 199
200 class MicroblogEntry(SimplePanel): 200 class MicroblogEntry(SimplePanel):
201 201
213 self.add(panel) 213 self.add(panel)
214 214
215 215
216 class MicroblogPanel(VerticalPanel): 216 class MicroblogPanel(VerticalPanel):
217 217
218 def __init__(self): 218 def __init__(self,title='&nbsp;'):
219 title=title.replace('<','&lt;').replace('>','&gt;')
219 VerticalPanel.__init__(self) 220 VerticalPanel.__init__(self)
221 _class = ['mb_panel_header']
222 if title == '&nbsp;':
223 _class.append('empty_header')
224 self.add(HTMLPanel("<div class='%s'>%s</div>" % (','.join(_class),title)))
220 self.setStyleName('microblogPanel') 225 self.setStyleName('microblogPanel')
221 226
222 def addEntry(self, text, author=None, timestamp=None): 227 def addEntry(self, text, author=None, timestamp=None):
223 """Add an entry to the panel 228 """Add an entry to the panel
224 @param text: main text of the entry 229 @param text: main text of the entry
281 self.contactPanel = ContactPanel(self) 286 self.contactPanel = ContactPanel(self)
282 self.panel = MainPanel(self) 287 self.panel = MainPanel(self)
283 self.middle_panel = self.panel.middle_panel 288 self.middle_panel = self.panel.middle_panel
284 self.mpanels = [MicroblogPanel()] 289 self.mpanels = [MicroblogPanel()]
285 self.middle_panel.changePanel(1,self.mpanels[0]) 290 self.middle_panel.changePanel(1,self.mpanels[0])
286 self.middle_panel.changePanel(0,EmptyPanel()) 291 self.middle_panel.changePanel(0,EmptyPanel(self, 0))
287 self.middle_panel.changePanel(2,EmptyPanel()) 292 self.middle_panel.changePanel(2,EmptyPanel(self, 2))
288 self._dialog = None 293 self._dialog = None
289 RootPanel().add(self.panel) 294 RootPanel().add(self.panel)
290 self._register = RegisterCall() 295 self._register = RegisterCall()
291 self._register.call('isRegistered',self._isRegisteredCB) 296 self._register.call('isRegistered',self._isRegisteredCB)
292 297
339 for panel in self.mpanels: 344 for panel in self.mpanels:
340 if isinstance(panel,MicroblogPanel): 345 if isinstance(panel,MicroblogPanel):
341 content = data['content'] 346 content = data['content']
342 author = data.get('author') 347 author = data.get('author')
343 print "timestamp: %s" % data.get('timestamp') 348 print "timestamp: %s" % data.get('timestamp')
344 timestamp = float(data.get('timestamp'),0) #XXX: int doesn't work here 349 timestamp = float(data.get('timestamp',0)) #XXX: int doesn't work here
345 panel.addEntry(content, author, timestamp) 350 panel.addEntry(content, author, timestamp)
346 351
347 if __name__ == '__main__': 352 if __name__ == '__main__':
348 pyjd.setup("http://localhost:8080/libervia.html") 353 pyjd.setup("http://localhost:8080/libervia.html")
349 app = SatWebFrontend() 354 app = SatWebFrontend()