changeset 3419:d6057ed413e6

show 'Comments' toggling link in edit bar only if the page really contains comments (ported from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 23 Mar 2008 00:02:30 +0100
parents cb22f4c4a0fd
children 28dc1b4b53ad
files MoinMoin/theme/__init__.py wiki/htdocs/common/js/common.js
diffstat 2 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/theme/__init__.py	Sat Mar 22 17:35:34 2008 +0100
+++ b/MoinMoin/theme/__init__.py	Sun Mar 23 00:02:30 2008 +0100
@@ -1099,7 +1099,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" onClick="toggleComments();return false;">%s</a>' % _('Comments'))
+                editbar_actions.append('<a href="#" class="toggleCommentsButton" style="display:none;" 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 Mar 22 17:35:34 2008 +0100
+++ b/wiki/htdocs/common/js/common.js	Sun Mar 23 00:02:30 2008 +0100
@@ -183,6 +183,27 @@
     }
 }
 
+function show_toggleComments() {
+    // Show edit bar item "ToggleComments" if inline comments exist on this page
+    var all = document.getElementsByTagName('*');
+    var count = 0;
+    for (i = 0; i < all.length; i++){
+        el = all[i];
+        if ( el.className.indexOf('comment') >= 0 ){
+            count++;
+        }
+    }
+    if (count > 0) {
+        for (i = 0; i < all.length; i++){
+            el = all[i];
+            if ( el.className == 'toggleCommentsButton' ){
+                el.style.display = 'inline';
+            }
+        }
+    }
+}
+
+
 function load() {
     // Do not name this "onload", it does not work with IE :-)
     // TODO: create separate onload for each type of view and set the
@@ -201,6 +222,9 @@
     // Editor stuff
     show_switch2gui();
 
+    // Enable menu item "ToggleComments" if inline comments exist
+    show_toggleComments();
+ 
     // data browser widget
     dbw_hide_buttons();
 }