Skip to content

Commit

Permalink
opening/closing sections is saved.
Browse files Browse the repository at this point in the history
  • Loading branch information
NOTMEE12 committed Jun 3, 2023
1 parent d5d7822 commit fe2cab5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
25 changes: 22 additions & 3 deletions docs/reST/_static/sections.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
const page = document

page.
function toggleSectionVisibility(section){
document.getElementById(section).hidden = ! document.getElementById(section).hidden;
if (document.getElementById(section).hidden === true){
items = localStorage.getItem('hidden');
if (items !== null){
if (!(items.includes(section))){
items = items + '|' + section + '|';
}
localStorage.setItem('hidden', items);
} else {
localStorage.setItem('hidden', section);
}
} else {
items = localStorage.getItem('hidden');
if (items !== null){
if (items.includes(section)){
items = items.replace(section + '|', '')
}
localStorage.setItem('hidden', items);
}
}
}
21 changes: 14 additions & 7 deletions docs/reST/themes/classic/elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h5>pygame-ce documentation</h5>
</div>
</div>
<hr style="color:#424242;border-bottom:none;border-style: solid;border-bottom-style:none;">
<div style="overflow-y: auto; height: 75vh;">
<div style="overflow-y: auto; height: 65vh;">
{#-

We render those sections based on functionality.
Expand All @@ -53,7 +53,7 @@ <h5>pygame-ce documentation</h5>
{%- set hidden = ['Overlay', 'cdrom', 'sdl2_video', 'sdl2_controller'] %}
{%- if pyg_sections %}

<p class="bottom"><b>Window</b><br></p>
<p class="bottom" onclick="toggleSectionVisibility('Window');"><b>Window</b><br></p>
<div class="bottom" id="Window">
{% set sep = joiner("<br>") %}
{%- for section in pyg_sections %}
Expand All @@ -71,7 +71,7 @@ <h5>pygame-ce documentation</h5>
</div>

<hr style="color:#222222;border-bottom:none;border-style: solid;border-bottom-style:none;">
<p class="bottom"><b>Drawing / Surface</b><br></p>
<p class="bottom" onclick="toggleSectionVisibility('Drawing');"><b>Drawing / Surface</b><br></p>
<div class="bottom" id="Drawing">
{% set sep = joiner("<br>") %}
{%- for section in pyg_sections %}
Expand All @@ -89,7 +89,7 @@ <h5>pygame-ce documentation</h5>
</div>

<hr style="color:#222222;border-bottom:none;border-style: solid;border-bottom-style:none;">
<p class="bottom" onclick=""><b>Events/Input</b><br></p>
<p class="bottom" onclick="toggleSectionVisibility('Events');"><b>Events/Input</b><br></p>
<div class="bottom" id="Events">
{% set sep = joiner("<br>") %}
{%- for section in pyg_sections %}
Expand All @@ -107,7 +107,7 @@ <h5>pygame-ce documentation</h5>
</div>

<hr style="color:#222222;border-bottom:none;border-style: solid;border-bottom-style:none;">
<p class="bottom"><b>Collisions</b><br></p>
<p class="bottom" onclick="toggleSectionVisibility('Collisions');"><b>Collisions</b><br></p>
<div class="bottom" id="Collisions">
{% set sep = joiner("<br>") %}
{%- for section in pyg_sections %}
Expand All @@ -125,7 +125,7 @@ <h5>pygame-ce documentation</h5>
</div>

<hr style="color:#222222;border-bottom:none;border-style: solid;border-bottom-style:none;">
<p class="bottom"><b>Music</b><br></p>
<p class="bottom" onclick="toggleSectionVisibility('Music');"><b>Music</b><br></p>
<div class="bottom" id="Music">
{% set sep = joiner("<br>") %}
{%- for section in pyg_sections %}
Expand All @@ -143,7 +143,7 @@ <h5>pygame-ce documentation</h5>
</div>

<hr style="color:#222222;border-bottom:none;border-style: solid;border-bottom-style:none;">
<p class="bottom"><b>Other</b><br></p>
<p class="bottom" onclick="toggleSectionVisibility('Other')"><b>Other</b><br></p>
<div class="bottom" id="Other">
{% set sep = joiner("<br>") %}
{%- for section in pyg_sections %}
Expand Down Expand Up @@ -178,4 +178,11 @@ <h5>pygame-ce documentation</h5>

{%- block relbaritems %}
<script type="text/javascript" src="https://www.pyg ame.org/comment/jquery.plugin.docscomments.js"></script>
<script type="text/javascript">
if (localStorage.getItem('hidden') !== null){
localStorage.getItem('hidden').split("|").forEach(element => {
if (document.getElementById(element) !== null) {document.getElementById(element).hidden = true};
});
}
</script>
{% endblock %}
3 changes: 2 additions & 1 deletion docs/reST/themes/classic/static/pygame.css_t
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ div.header .pagelinks a:hover {
.pagelinks .bottom a {
font-weight: 400;
color: {{ theme_linkcolor2 }};
margin-left: 1em;}
margin-left: 1em;
}
.dark-theme .pagelinks .bottom a {
color: {{ theme_dark_linkcolor2 }};
font-size: 1.1rem;
Expand Down

0 comments on commit fe2cab5

Please sign in to comment.