changeset 4346:dfb09cf670f9

fix editbar hidden comment link cosmetics for sidebar themes (hide the complete list element)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 28 Sep 2008 00:01:41 +0200
parents 5c29df15cd90
children ae088388d645
files MoinMoin/theme/__init__.py wiki/htdocs/common/js/common.js
diffstat 2 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/theme/__init__.py	Sat Sep 27 23:07:09 2008 +0200
+++ b/MoinMoin/theme/__init__.py	Sun Sep 28 00:01:41 2008 +0200
@@ -1094,10 +1094,19 @@
 
         html = self._cache.get('editbar')
         if html is None:
-            # Remove empty items and format as list
-            items = ''.join(['<li>%s</li>' % item
-                             for item in self.editbarItems(page) if item])
-            html = u'<ul class="editbar">%s</ul>\n' % items
+            # Remove empty items and format as list. The item for showing inline comments
+            # is hidden by default. It gets activated through javascript only if inline
+            # comments exist on the page.
+            items = []
+            for item in self.editbarItems(page):
+                if item:
+                    if 'nbcomment' in item:
+                        # hiding the complete list item is cosmetically better than just
+                        # hiding the contents (e.g. for sidebar themes).
+                        items.append('<li class="toggleCommentsButton" style="display:none;">%s</li>' % item) 
+                    else:
+                        items.append('<li>%s</li>' % item)
+            html = u'<ul class="editbar">%s</ul>\n' % ''.join(items)
             self._cache['editbar'] = html
 
         return html
@@ -1144,7 +1153,7 @@
                 # we just use <a> to get same style as other links, but we add some dummy
                 # link target to get correct mouseover pointer appearance. return false
                 # keeps the browser away from jumping to the link target::
-                editbar_actions.append('<a href="#" class="toggleCommentsButton" style="display:none;" onClick="toggleComments();return false;">%s</a>' % _('Comments'))
+                editbar_actions.append('<a href="#" class="nbcomment" onClick="toggleComments();return false;">%s</a>' % _('Comments'))
             elif editbar_item == 'Edit':
                 editbar_actions.append(self.editorLink(page))
             elif editbar_item == 'Info':
--- a/wiki/htdocs/common/js/common.js	Sat Sep 27 23:07:09 2008 +0200
+++ b/wiki/htdocs/common/js/common.js	Sun Sep 28 00:01:41 2008 +0200
@@ -191,13 +191,13 @@
 }
 
 function show_toggleComments() {
-    // Show edit bar item "ToggleComments" if inline comments exist on this page
+    // Show edit bar item for toggling inline comments on/off only if inline comments exist on the page
     comments = getElementsByClassName('comment', null, document);
     if (comments.length > 0) {
         var buttons = getElementsByClassName('toggleCommentsButton', null, document);
         for (i = 0; i < buttons.length; i++){
             el = buttons[i];
-            el.style.display = 'inline';
+            el.style.display = '';
         }
     }
 }