diff options
| author | David Waern <david.waern@gmail.com> | 2011-10-01 01:41:13 +0200 | 
|---|---|---|
| committer | David Waern <david.waern@gmail.com> | 2011-10-01 01:41:13 +0200 | 
| commit | b4915e8f387bdc0e0fb40a67b41de8fbacb32da6 (patch) | |
| tree | 3b1fce6cd5bdc1ba2963b5db05de7bfc4e1997f0 /html | |
| parent | 73a6ed218c59fb778da9b830db1283e005ff2245 (diff) | |
Merge in darcs pach:
  Mon Apr 11 18:09:54 JST 2011  Liyang HU <haddock@liyang.hu>
    * Remember collapsed sections in index.html / haddock-util.js
Diffstat (limited to 'html')
| -rw-r--r-- | 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 4a7e4255..9a6fccf7 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();  } | 
