Add code to make the inheritance diagrams able to be toggled between shown and hidden.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@72141 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2012-07-19 01:22:28 +00:00
parent 6c4eac60ef
commit 0914614515
6 changed files with 73 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

View File

@@ -0,0 +1,60 @@
/*
* toggle_visibility.js
* --------------------
*
* These functions enable the user to toggle the visibility of a block of
* the document, which is delimited by a <div> tag with an expected id
* attribute. The magic happens via using the id of the object passed to
* toggle visibility to make the id's used to find the other elements that
* will be operated upon.
*/
function hasClass(ele,cls) {
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) {
if (hasClass(ele,cls)) {
var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
ele.className=ele.className.replace(reg,' ');
}
}
function toggleVisibility(linkObj) {
var base = linkObj.getAttribute('id');
var summary = document.getElementById(base + '-summary');
var content = document.getElementById(base + '-content');
var trigger = document.getElementById(base + '-trigger');
var cookieName = base + '-savedState'
if ( hasClass(linkObj,'closed') ) {
summary.style.display = 'none';
content.style.display = 'block';
trigger.src = '_static/images/open.png';
removeClass(linkObj,'closed');
addClass(linkObj,'opened');
$.cookie(cookieName, 'opened');
} else if ( hasClass(linkObj,'opened') ) {
summary.style.display = 'block';
content.style.display = 'none';
trigger.src = '_static/images/closed.png';
removeClass(linkObj,'opened');
addClass(linkObj,'closed');
$.cookie(cookieName, 'closed');
}
return false;
}
function toggleVisibilityOnLoad(linkObj) {
var base = linkObj.getAttribute('id');
var cookieName = base + '-savedState'
var state = $.cookie(cookieName);
if ( state == 'opened' ) {
toggleVisibility(linkObj);
}
}

View File

@@ -181,6 +181,8 @@ def setup(app):
app.add_javascript('javascript/sidebar.js')
app.add_javascript('javascript/jquery.collapse.js')
app.add_javascript('javascript/jquery.cookie.js')
app.add_javascript('javascript/jquery.cookie.js')
app.add_javascript('javascript/toggle_visibility.js')
app.add_config_value('availability_include_availabilities', False, False)

View File

@@ -65,7 +65,7 @@ def SphinxIndexes(sphinxDir):
"""
This is the main function called after the `etg` process has finished.
It class other functions to generate the standalone functions page, the
It calls other functions to generate the standalone functions page, the
main class index and some clean-up/maintenance of the generated ReST
files.
"""

View File

@@ -30,15 +30,21 @@ TEMPLATE_INHERITANCE = '''
|
|class_hierarchy| Inheritance Diagram
=====================================
Inheritance diagram for %s **%s**
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for %s <strong>%s</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/%s" alt="Inheritance diagram of %s" usemap="#dummy" class="inheritance"/></center>
</div>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
%s
</p>