comparison src/browser/sat_browser/blog.py @ 769:5b28bca05d23

browser_side (blog): fixes focusing new comment box + click listener
author souliane <souliane@mailoo.org>
date Wed, 25 Nov 2015 18:40:37 +0100
parents 6c89dfdba563
children e67d8c13ba22
comparison
equal deleted inserted replaced
768:6c89dfdba563 769:5b28bca05d23
168 return label 168 return label
169 169
170 if self.item.comments: 170 if self.item.comments:
171 self.comment_label = addIcon(u"↶", "Comment this message") 171 self.comment_label = addIcon(u"↶", "Comment this message")
172 self.comment_label.setStyleName('mb_entry_action_larger') 172 self.comment_label.setStyleName('mb_entry_action_larger')
173 else:
174 self.comment_label = None
173 is_publisher = self.item.author_jid == self.blog.host.whoami.bare 175 is_publisher = self.item.author_jid == self.blog.host.whoami.bare
174 if is_publisher: 176 if is_publisher:
175 self.update_label = addIcon(u"✍", "Edit this message") 177 self.update_label = addIcon(u"✍", "Edit this message")
176 # TODO: add delete button if we are the owner of the node 178 # TODO: add delete button if we are the owner of the node
177 self.delete_label = addIcon(u"✗", "Delete this message") 179 self.delete_label = addIcon(u"✗", "Delete this message")
180 else:
181 self.update_label = self.delete_label = None
178 182
179 def _createCommentsPanel(self): 183 def _createCommentsPanel(self):
180 """Create the panel if it doesn't exists""" 184 """Create the panel if it doesn't exists"""
181 if self.comments_panel is None: 185 if self.comments_panel is None:
182 self.comments_panel = VerticalPanel() 186 self.comments_panel = VerticalPanel()
321 325
322 def _onCommentClick(self): 326 def _onCommentClick(self):
323 """Add an empty entry for a new comment""" 327 """Add an empty entry for a new comment"""
324 if self._current_comment is None: 328 if self._current_comment is None:
325 if not self.item.comments_service or not self.item.comments_node: 329 if not self.item.comments_service or not self.item.comments_node:
326 log.warning("Invalid service and node for comments, can pcreate a comment") 330 log.warning("Invalid service and node for comments, can't create a comment")
327 self._current_comment = self.addEntry(editable=True, service=self.item.comments_service, node=self.item.comments_node) 331 self._current_comment = self.addEntry(editable=True, service=self.item.comments_service, node=self.item.comments_node)
328 self.blog.setSelectedEntry(self._current_comment, True) 332 self.blog.setSelectedEntry(self._current_comment, True)
329 333
330 def _changeMode(self, original_content, text): 334 def _changeMode(self, original_content, text):
331 self.mode = C.ENTRY_MODE_RICH if self.mode == C.ENTRY_MODE_TEXT else C.ENTRY_MODE_TEXT 335 self.mode = C.ENTRY_MODE_RICH if self.mode == C.ENTRY_MODE_TEXT else C.ENTRY_MODE_TEXT
495 parent = current.getParent() 499 parent = current.getParent()
496 if parent is None: 500 if parent is None:
497 log.warning("Can't find any parent ScrollPanel") 501 log.warning("Can't find any parent ScrollPanel")
498 return 502 return
499 elif isinstance(parent, ScrollPanel): 503 elif isinstance(parent, ScrollPanel):
500 parent.ensureVisible(current) 504 parent.ensureVisible(entry)
501 return 505 return
502 else: 506 else:
503 current = parent 507 current = parent
504 508
505 def setSelectedEntry(self, entry, ensure_visible=False): 509 def setSelectedEntry(self, entry, ensure_visible=False):