File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
sphinx_togglebutton/_static Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 11/* Visibility of the target */
2- .toggle, div .admonition.toggle .admonition-title ~ * {
2+ .toggle, .admonition.toggle .admonition-title ~ * {
33 transition: opacity .5s, height .5s;
44}
55
1414/* Overrides for admonition toggles */
1515
1616/* Titles should cut off earlier to avoid overlapping w/ button */
17- div .admonition.toggle p.admonition-title {
17+ .admonition.toggle p.admonition-title {
1818 padding-right: 25%;
1919}
2020
2121/* hides all the content of a page until de-toggled */
22- div .admonition.toggle-hidden .admonition-title ~ * {
22+ .admonition.toggle-hidden .admonition-title ~ * {
2323 height: 0;
2424 margin: 0;
2525 float: left; /* so they overlap when hidden */
@@ -32,6 +32,11 @@ div.admonition.toggle-hidden .admonition-title ~ * {
3232 position: relative;
3333}
3434
35+ /* Clicking the title will toggle the admonition, so a pointer makes this clearer */
36+ .toggle.admonition .admonition-title {
37+ cursor: pointer;
38+ }
39+
3540.toggle.admonition.admonition-title:after {
3641 content: "" !important;
3742}
Original file line number Diff line number Diff line change @@ -24,8 +24,15 @@ var initToggleItems = () => {
2424 item . insertAdjacentHTML ( 'beforebegin' , collapseButton ) ;
2525 }
2626
27- thisButton = $ ( `# ${ buttonID } ` ) ;
27+ thisButton = document . getElementById ( buttonID ) ;
2828 thisButton . on ( 'click' , toggleClickHandler ) ;
29+ // If admonition has a single direct-child title make it clickable.
30+ admonitionTitle = document . querySelector ( `#${ toggleID } > .admonition-title` )
31+ if ( admonitionTitle ) {
32+ admonitionTitle . on ( 'click' , toggleClickHandler ) ;
33+ admonitionTitle . dataset . target = toggleID
34+ admonitionTitle . dataset . button = buttonID
35+ }
2936 if ( ! item . classList . contains ( "toggle-shown" ) ) {
3037 toggleHidden ( thisButton [ 0 ] ) ;
3138 }
You can’t perform that action at this time.
0 commit comments