changeset 496:0924710b666a

browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
author souliane <souliane@mailoo.org>
date Thu, 17 Jul 2014 12:59:33 +0200
parents 587fe75d1b16
children 516b06787c1a
files INSTALL src/browser/public/libervia.css src/browser/sat_browser/panels.py
diffstat 3 files changed, 22 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/INSTALL	Tue Jul 15 18:45:33 2014 +0200
+++ b/INSTALL	Thu Jul 17 12:59:33 2014 +0200
@@ -79,7 +79,7 @@
  port_https=8443
  ssl_certificate=libervia.pem
  redirect_to_https=1
- unsecure_warning=1
+ security_warning=1
 
 Check the wiki for more information: http://wiki.goffi.org/wiki/Configuration/en
 
--- a/src/browser/public/libervia.css	Tue Jul 15 18:45:33 2014 +0200
+++ b/src/browser/public/libervia.css	Thu Jul 17 12:59:33 2014 +0200
@@ -796,6 +796,7 @@
 .selected_widget .selected_entry .mb_entry_header
 {
     background: #cf2828;
+    border-radius: 5px 5px 0px 0px;
 }
 
 .mb_entry_author {
--- a/src/browser/sat_browser/panels.py	Tue Jul 15 18:45:33 2014 +0200
+++ b/src/browser/sat_browser/panels.py	Thu Jul 17 12:59:33 2014 +0200
@@ -482,19 +482,12 @@
 
     def onClick(self, sender):
         if sender == self:
-            try:  # prevent re-selection of the main entry after a comment has been focused
-                if self.__ignoreNextEvent:
-                    self.__ignoreNextEvent = False
-                    return
-            except AttributeError:
-                pass
             self._blog_panel.setSelectedEntry(self)
         elif sender == self.delete_label:
             self._delete()
         elif sender == self.update_label:
             self.edit(True)
         elif sender == self.comment_label:
-            self.__ignoreNextEvent = True
             self._comment()
 
     def __modifiedCb(self, content):
@@ -586,7 +579,7 @@
         """Add an empty entry for a new comment"""
         if self._current_comment:
             self._current_comment.bubble.setFocus(True)
-            self._blog_panel.setSelectedEntry(self._current_comment)
+            self._blog_panel.setSelectedEntry(self._current_comment, True)
             return
         data = {'id': str(time()),
                 'new': True,
@@ -602,7 +595,7 @@
         entry._parent_entry = self
         self._current_comment = entry
         self.edit(True, entry)
-        self._blog_panel.setSelectedEntry(entry)
+        self._blog_panel.setSelectedEntry(entry, True)
 
     def edit(self, edit, entry=None):
         """Toggle the bubble between display and edit mode
@@ -928,24 +921,38 @@
                         self.selected_entry = None
                         break
 
-    def setSelectedEntry(self, entry):
+    def ensureVisible(self, entry):
+        """Scroll to an entry to ensure its visibility
+
+        @param entry (MicroblogEntry): the entry
+        """
         try:
             self.vpanel.getParent().ensureVisible(entry)  # scroll to the clicked entry
         except AttributeError:
             log.warning("FIXME: MicroblogPanel.vpanel should be wrapped in a ScrollPanel!")
-        removeStyle = lambda entry: entry.removeStyleName('selected_entry')
+
+    def setSelectedEntry(self, entry, ensure_visible=False):
+        """Select an entry.
+
+        @param entry (MicroblogEntry): the entry to select
+        @param ensure_visible (boolean): if True, also scroll to the entry
+        """
+        if ensure_visible:
+            self.ensureVisible(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 timer: removeStyle(clicked_entry))
+            Timer(500, lambda timer: clicked_entry.removeStyleName('selected_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:
-            removeStyle(self.selected_entry)
+            self.selected_entry.removeStyleName('selected_entry')
         if entry:
             log.debug("microblog entry selected (author=%s)" % entry.author)
             entry.addStyleName('selected_entry')