Repository : ssh://darcs.haskell.org//srv/darcs/haddock

On branches: development,master

http://hackage.haskell.org/trac/ghc/changeset/b4915e8f387bdc0e0fb40a67b41de8fbacb32da6

>---------------------------------------------------------------

commit b4915e8f387bdc0e0fb40a67b41de8fbacb32da6
Author: David Waern <[email protected]>
Date:   Sat Oct 1 01:41:13 2011 +0200

    Merge in darcs pach:
    
      Mon Apr 11 18:09:54 JST 2011  Liyang HU <[email protected]>
        * Remember collapsed sections in index.html / haddock-util.js

>---------------------------------------------------------------

 html/haddock-util.js |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/html/haddock-util.js b/html/haddock-util.js
index 4a7e425..9a6fccf 100644
--- a/html/haddock-util.js
+++ b/html/haddock-util.js
@@ -50,11 +50,43 @@ toggleCollapser = makeClassToggle("collapser", "expander");
 
 function toggleSection(id)
 {
-  var b = toggleShow(document.getElementById("section." + id))
-  toggleCollapser(document.getElementById("control." + id), b)
+  var b = toggleShow(document.getElementById("section." + id));
+  toggleCollapser(document.getElementById("control." + id), b);
+  rememberCollapsed(id, b);
   return b;
 }
 
+var collapsed = {};
+function rememberCollapsed(id, b)
+{
+  if(b)
+    delete collapsed[id]
+  else
+    collapsed[id] = null;
+
+  var sections = [];
+  for(var i in collapsed)
+  {
+    if(collapsed.hasOwnProperty(i))
+      sections.push(i);
+  }
+  // cookie specific to this page; don't use setCookie which sets path=/
+  document.cookie = "collapsed=" + escape(sections.join('+'));
+}
+
+function restoreCollapsed()
+{
+  var cookie = getCookie("collapsed");
+  if(!cookie)
+    return;
+
+  var ids = cookie.split('+');
+  for(var i in ids)
+  {
+    if(document.getElementById("section." + ids[i]))
+      toggleSection(ids[i]);
+  }
+}
 
 function setCookie(name, value) {
   document.cookie = name + "=" + escape(value) + ";path=/;";
@@ -307,5 +339,6 @@ function pageLoad() {
   addStyleMenu();
   adjustForFrames();
   resetStyle();
+  restoreCollapsed();
 }
 



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to