webmcp

diff doc/autodoc-header.htmlpart @ 390:ed910089a0c5

Keep track of expanded sections in autodoc reference (and collapse sections on hash change)
author jbe
date Thu Dec 03 18:26:49 2015 +0100 (2015-12-03)
parents a7a335e2db93
children a932b94a8490
line diff
     1.1 --- a/doc/autodoc-header.htmlpart	Thu Dec 03 02:32:20 2015 +0100
     1.2 +++ b/doc/autodoc-header.htmlpart	Thu Dec 03 18:26:49 2015 +0100
     1.3 @@ -1,22 +1,25 @@
     1.4  <html>
     1.5    <head>
     1.6      <script type="text/javascript">
     1.7 -      var openedSection = null;
     1.8 -      var setSectionDisplay = function(disp) {
     1.9 -        var element = document.getElementById('autodoc_details_' + openedSection);
    1.10 -        if (element) element.style.display = disp;
    1.11 -      };
    1.12 -      var showSection = function() {
    1.13 -        openedSection = window.location.hash;
    1.14 -        if (openedSection) {
    1.15 -          openedSection = openedSection.replace(/^#/, '').replace(/_/g, '_USC_').replace(/\./g, '_DOT_').replace(/:/g, '_COL_');
    1.16 -          setSectionDisplay('');
    1.17 +      var expandedSections = {};
    1.18 +      function toggleSection(ident) {
    1.19 +        var element = document.getElementById('autodoc_details_' + ident);
    1.20 +        if (element) {
    1.21 +          if (expandedSections[ident]) {
    1.22 +            element.style.display = 'none';
    1.23 +            delete expandedSections[ident];
    1.24 +          } else {
    1.25 +            element.style.display = '';
    1.26 +            expandedSections[ident] = true;
    1.27 +          }
    1.28          }
    1.29 -      };
    1.30 -      window.onload = showSection;
    1.31 -      window.onhashchange = function() {
    1.32 -        setSectionDisplay('none');
    1.33 -        showSection();
    1.34 +      }
    1.35 +      window.onload = window.onhashchange = function() {
    1.36 +        for (var ident in expandedSections) toggleSection(ident);
    1.37 +        var hash = window.location.hash;
    1.38 +        if (hash) {
    1.39 +          toggleSection(hash.replace(/^#/, ''));
    1.40 +        }
    1.41        };
    1.42      </script>
    1.43      <style>

Impressum / About Us