webmcp
changeset 389:a7a335e2db93
Utilize onhashchange event in autodoc output
author | jbe |
---|---|
date | Thu Dec 03 02:32:20 2015 +0100 (2015-12-03) |
parents | 29eeba26ff9f |
children | ed910089a0c5 |
files | doc/autodoc-header.htmlpart framework/bin/autodoc.lua |
line diff
1.1 --- a/doc/autodoc-header.htmlpart Wed Dec 02 09:37:47 2015 +0100 1.2 +++ b/doc/autodoc-header.htmlpart Thu Dec 03 02:32:20 2015 +0100 1.3 @@ -1,13 +1,23 @@ 1.4 <html> 1.5 <head> 1.6 <script type="text/javascript"> 1.7 - window.onload = function() { 1.8 - if (window.location.hash) { 1.9 - var encoded_hash = window.location.hash.replace(/^#/, '').replace(/_/g, '_USC_').replace(/\./g, '_DOT_').replace(/:/g, '_COL_'); 1.10 - var element = document.getElementById('autodoc_details_' + encoded_hash); 1.11 - if (element) element.style.display = ''; 1.12 + var openedSection = null; 1.13 + var setSectionDisplay = function(disp) { 1.14 + var element = document.getElementById('autodoc_details_' + openedSection); 1.15 + if (element) element.style.display = disp; 1.16 + }; 1.17 + var showSection = function() { 1.18 + openedSection = window.location.hash; 1.19 + if (openedSection) { 1.20 + openedSection = openedSection.replace(/^#/, '').replace(/_/g, '_USC_').replace(/\./g, '_DOT_').replace(/:/g, '_COL_'); 1.21 + setSectionDisplay(''); 1.22 } 1.23 - } 1.24 + }; 1.25 + window.onload = showSection; 1.26 + window.onhashchange = function() { 1.27 + setSectionDisplay('none'); 1.28 + showSection(); 1.29 + }; 1.30 </script> 1.31 <style> 1.32 body {
2.1 --- a/framework/bin/autodoc.lua Wed Dec 02 09:37:47 2015 +0100 2.2 +++ b/framework/bin/autodoc.lua Thu Dec 03 02:32:20 2015 +0100 2.3 @@ -187,8 +187,8 @@ 2.4 output('<a name="', anchor, '">') 2.5 output(' <li class="autodoc_entry">\n') 2.6 output( 2.7 - ' <div class="short_synopsis"', 2.8 - ' onclick="document.getElementById(\'autodoc_details_', 2.9 + ' <div class="short_synopsis" onclick="window.onhashchange = null;', 2.10 + ' document.getElementById(\'autodoc_details_', 2.11 ident, 2.12 '\').style.display = document.getElementById(\'autodoc_details_', 2.13 ident,