Show/hide Part Of Text (question/answer) In Sphinx File
I was wondering if there is a method to add a directive to a sphinx document with a hidden section that can be opened with a click. Basically something like you can find https://re
Solution 1:
Here is a working example from the Mastering Plone Training documentation.
And here's the source code.
.. admonition:: Solution
:class: toggle
* Go to the dexterity-controlpanel (http://localhost:8080/Plone/@@dexterity-types)
* Click on *Page* (http://127.0.0.1:8080/Plone/dexterity-types/Document)
* Select the tab *Behaviors* (http://127.0.0.1:8080/Plone/dexterity-types/Document/@@behaviors)
* Check the box next to *Lead Image* and save.
The commit history shows that a custom JavaScript and style were added to the theme.
_static/custom.css
.toggle {
background: none repeat scroll 00#e7f2fa;
}
.toggle.admonition-title {
display: block;
clear: both;
}
.toggle.admonition-title:after {
content: " ▼";
}
.toggle.admonition-title.open:after {
content: " ▲";
}
_templates/page.html
{% set css_files = css_files + ["_static/custom.css"] %}
{%- block extrahead %}
<scripttype="text/javascript">
$(document).ready(function() {
////
$(".toggle > *").hide();
$(".toggle .admonition-title").show();
$(".toggle .admonition-title").click(function() {
$(this).parent().children().not(".admonition-title").toggle(400);
$(this).parent().children(".admonition-title").toggleClass("open");
})
});
</script>
{% endblock %}
Post a Comment for "Show/hide Part Of Text (question/answer) In Sphinx File"