Commits

Michel Albert committed 90d44c8

Folding *all* DTs.

This should be fine for the default theme.

  • Participants
  • Parent commits 8e67bee

Comments (0)

Files changed (1)

File js/sphinx-folding.js

 goog.require('goog.array');
 goog.require('goog.debug');
 goog.require('goog.debug.Logger');
+goog.require('goog.debug.Console');
 goog.require('goog.dom');
+goog.require('goog.events');
+goog.require('goog.style');
 
 
 /**
   var debugWindow = new goog.debug.FancyWindow('main');
   debugWindow.setEnabled(true);
   debugWindow.init();
+  goog.debug.Console.autoInstall();
 
-  var classes = goog.dom.getElementsByTagNameAndClass('dl', 'class');
+  var classes = goog.dom.getElementsByTagNameAndClass('dt');
   goog.array.forEach(classes, function(obj){
-    SphinxFolding.LOG.info(goog.debug.expose(obj));
+    var container = goog.dom.getNextElementSibling(obj);
+    if (goog.isDefAndNotNull(container)) {
+      goog.style.showElement(container, false);
+    }
+    goog.events.listen(obj, goog.events.EventType.CLICK, function(evt) {
+      SphinxFolding.toggleVisibility(this);
+    });
   });
 };
 
 
+SphinxFolding.toggleVisibility = function(obj) {
+  SphinxFolding.LOG.finer("Toggling visibility of sibling of " + obj.tagName);
+  var container = goog.dom.getNextElementSibling(obj);
+  SphinxFolding.LOG.fine("Sibling is " + container);
+  goog.style.showElement(container, !goog.style.isElementShown(container));
+};
+
+
 /**
  * The class logger
  */