Add 'Show All' / 'Hide All' toggle
This adds a global control that does show / hide of all collapseable sections. Which is extremely useful in seeing the entire API at once. Part of bp:api-ref-in-rst Change-Id: I814e6b2c20c25bf3d4cb4e722bc8157ca0aa1b89
This commit is contained in:
parent
19712dccce
commit
e51b8f43e1
@ -65,6 +65,17 @@ class rest_method(nodes.Part, nodes.Element):
|
||||
pass
|
||||
|
||||
|
||||
class rest_expand_all(nodes.Part, nodes.Element):
|
||||
pass
|
||||
|
||||
|
||||
class RestExpandAllDirective(Directive):
|
||||
has_content = True
|
||||
|
||||
def run(self):
|
||||
return [rest_expand_all()]
|
||||
|
||||
|
||||
class RestMethodDirective(Directive):
|
||||
|
||||
# this enables content in the directive
|
||||
@ -295,6 +306,22 @@ def rest_method_html(self, node):
|
||||
raise nodes.SkipNode
|
||||
|
||||
|
||||
def rest_expand_all_html(self, node):
|
||||
tmpl = """
|
||||
<div>
|
||||
<div class=col-md-11></div>
|
||||
<div class=col-md-1>
|
||||
<button id="expand-all"
|
||||
data-toggle="collapse"
|
||||
class="btn btn-info btn-sm btn-expand-all"
|
||||
>Show All</button>
|
||||
</div>
|
||||
</div>"""
|
||||
|
||||
self.body.append(tmpl % node)
|
||||
raise nodes.SkipNode
|
||||
|
||||
|
||||
def resolve_rest_references(app, doctree):
|
||||
for node in doctree.traverse():
|
||||
if isinstance(node, rest_method):
|
||||
@ -330,8 +357,11 @@ def resolve_rest_references(app, doctree):
|
||||
def setup(app):
|
||||
app.add_node(rest_method,
|
||||
html=(rest_method_html, None))
|
||||
app.add_node(rest_expand_all,
|
||||
html=(rest_expand_all_html, None))
|
||||
app.add_directive('rest_parameters', RestParametersDirective)
|
||||
app.add_directive('rest_method', RestMethodDirective)
|
||||
app.add_directive('rest_expand_all', RestExpandAllDirective)
|
||||
app.add_stylesheet('bootstrap.min.css')
|
||||
app.add_stylesheet('api-site.css')
|
||||
app.add_javascript('bootstrap.min.js')
|
||||
|
@ -19,6 +19,21 @@
|
||||
processButton(this, 'close');
|
||||
});
|
||||
|
||||
var expandAllActive = true;
|
||||
// Expand the world
|
||||
$('#expand-all').click(function () {
|
||||
if (expandAllActive) {
|
||||
expandAllActive = false;
|
||||
$('.api-detail').collapse('show');
|
||||
$('#expand-all').attr('data-toggle', '');
|
||||
$(this).text('Hide All');
|
||||
} else {
|
||||
expandAllActive = true;
|
||||
$('.api-detail').collapse('hide');
|
||||
$('#expand-all').attr('data-toggle', 'collapse');
|
||||
$(this).text('Show All');
|
||||
}});
|
||||
|
||||
// Wire up the search button
|
||||
$('#search-btn').on('click', function(e) {
|
||||
searchPage();
|
||||
@ -92,4 +107,4 @@
|
||||
.toggleClass('btn-info')
|
||||
.toggleClass('btn-default');
|
||||
}
|
||||
})();
|
||||
})();
|
||||
|
@ -3,6 +3,9 @@
|
||||
=============
|
||||
Compute API
|
||||
=============
|
||||
|
||||
.. rest_expand_all::
|
||||
|
||||
.. include:: versions.inc
|
||||
.. include:: servers.inc
|
||||
.. include:: servers-multiple-create.inc
|
||||
|
Loading…
x
Reference in New Issue
Block a user