changeset 322:971e3812903a

browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
author souliane <souliane@mailoo.org>
date Fri, 03 Jan 2014 22:44:59 +0100
parents bfbd9d6eb901
children 0b7934e75e76
files browser_side/panels.py
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/panels.py	Fri Jan 03 22:43:44 2014 +0100
+++ b/browser_side/panels.py	Fri Jan 03 22:44:59 2014 +0100
@@ -470,7 +470,7 @@
 
     def onClick(self, sender):
         if sender == self:
-            self._blog_panel.setSelectedEntry(self if self.comments else None)
+            self._blog_panel.setSelectedEntry(self)
         elif sender == self.delete_label:
             self._delete()
         elif sender == self.update_label:
@@ -851,10 +851,23 @@
                         break
 
     def setSelectedEntry(self, entry):
+        try:
+            self.vpanel.getParent().ensureVisible(entry)  # scroll to the clicked entry
+        except AttributeError:
+            logging.error("FIXME: MicroblogPanel.vpanel should be wrapped in a ScrollPanel!")
+        removeStyle = lambda entry: entry.removeStyleName('selected_entry')
+        if not self.host.uni_box or not entry.comments:
+            entry.addStyleName('selected_entry')  # blink the clicked entry
+            clicked_entry = entry  # entry may be None when the timer is done
+            Timer(500, lambda: removeStyle(clicked_entry))
+        if not self.host.uni_box:
+            return  # unibox is disabled
+        # from here the previous behavior (toggle main item selection) is conserved
+        entry = entry if entry.comments else None
         if self.selected_entry == entry:
             entry = None
         if self.selected_entry:
-            self.selected_entry.removeStyleName('selected_entry')
+            removeStyle(self.selected_entry)
         if entry:
             print "microblog entry selected (author=%s)" % entry.author
             entry.addStyleName('selected_entry')