Skip to content

Commit fe9db13

Browse files
committed
foo
1 parent 1d9bf3d commit fe9db13

5 files changed

Lines changed: 113 additions & 14 deletions

File tree

_includes/footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div class="center">
22
<p>© 2025 control-toolbox</p>
3-
</div>
3+
</div>

assets/css/common.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
footer {
22
display: flex !important;
33
justify-content: center;
4-
background-color: #007fa2;
5-
color: #fff;
4+
color: #007fa2;
65
margin-top: 0px;
76
position: relative;
87
z-index: 1;

assets/css/documentation.css

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,43 @@ html, body {
2626

2727
#documenter {
2828
min-height: 100%;
29-
margin-bottom: -55px; /* equal to footer height */
29+
margin-bottom: -25px; /* equal to footer height */
3030
}
3131

3232
#documenter:after {
3333
content: "";
3434
display: block;
3535
}
3636

37-
.ct-footer, #documenter:after {
38-
height: 55px;
37+
.ct-footer {
38+
height: 25px;
3939
}
40+
41+
#documenter:after {
42+
height: 25px;
43+
}
44+
45+
/* Smooth hide and show top menu nav */
46+
#multi-page-nav.show-top-menu {
47+
transform: translateY(0);
48+
}
49+
50+
#multi-page-nav.hide-top-menu {
51+
transform: translateY(-100%);
52+
}
53+
54+
.smooth-show-hide {
55+
transition: 0.3s all ease-in-out !important;
56+
}
57+
58+
.docs-sidebar, .docs-sidebar.show-top-menu {
59+
padding-top: calc(var(--navbar-height) + 1rem) !important;
60+
}
61+
62+
.docs-sidebar.hide-top-menu {
63+
padding-top: 0 !important;
64+
}
65+
66+
.docs-main {
67+
padding-top: calc(var(--navbar-height)) !important;
68+
}

assets/css/multidoc.css

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ html {
88
height: var(--navbar-height);
99
z-index: 10;
1010
padding: 0 1rem;
11-
position: sticky;
11+
position: fixed;
1212
display: flex;
1313
top: 0;
1414
background-color: #282f2f;
@@ -182,17 +182,13 @@ html {
182182
}
183183

184184
/* Documenter css tweaks */
185-
.docs-sidebar {
186-
padding-top: calc(var(--navbar-height) + 1rem) !important;
187-
}
188-
189185
.docs-sidebar {
190186
top: 0;
191187
}
192188

193189
@media screen and (max-width: 1055px) {
194190
#multi-page-nav {
195-
position: sticky;
191+
position: fixed;
196192
top: 0;
197193
padding: 0 1rem;
198194
height: unset;

assets/js/documentation.js

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ function topbarInjector() {
44
/* top bar menu */
55
var navElement = document.createElement('nav');
66
navElement.id = "multi-page-nav";
7+
navElement.className = "show-top-menu smooth-show-hide";
78
navElement.innerHTML = `
89
<a class="brand" href="https://control-toolbox.org/"><img alt="home" src="https://control-toolbox.org/assets/img/ct-logo-white.svg"></a>
910
<div class="hidden-on-mobile" id="nav-items" style="width: inherit;">
@@ -32,6 +33,13 @@ function topbarInjector() {
3233
var elt = document.getElementById("documenter");
3334
elt.insertBefore(navElement, elt.firstChild);
3435

36+
// get class docs-sidebar if exists and add in the classes: show-top-menu and smooth-show-hide
37+
var sidebar = document.getElementsByClassName("docs-sidebar");
38+
if (sidebar.length > 0) {
39+
sidebar[0].classList.add("show-top-menu");
40+
sidebar[0].classList.add("smooth-show-hide");
41+
}
42+
3543
//
3644
document
3745
.getElementById("multidoc-toggler")
@@ -57,16 +65,78 @@ function topbarInjector() {
5765

5866
}
5967

68+
// Function to show the top bar menu
69+
function showTopBar() {
70+
71+
// update top bar
72+
var topbar = document.getElementById("multi-page-nav");
73+
if (topbar) {
74+
topbar.classList.remove("hide-top-menu");
75+
topbar.classList.add("show-top-menu");
76+
}
77+
78+
// update sidebar
79+
var sidebar = document.getElementsByClassName("docs-sidebar");
80+
if (sidebar.length > 0) {
81+
sidebar[0].classList.remove("hide-top-menu");
82+
sidebar[0].classList.add("show-top-menu");
83+
}
84+
85+
}
86+
87+
// Function to hide the top bar menu
88+
function hideTopBar() {
89+
90+
// update top bar
91+
var topbar = document.getElementById("multi-page-nav");
92+
if (topbar) {
93+
topbar.classList.remove("show-top-menu");
94+
topbar.classList.add("hide-top-menu");
95+
}
96+
97+
// update sidebar
98+
var sidebar = document.getElementsByClassName("docs-sidebar");
99+
if (sidebar.length > 0) {
100+
sidebar[0].classList.remove("show-top-menu");
101+
sidebar[0].classList.add("hide-top-menu");
102+
}
103+
104+
}
105+
106+
// ajoute un event listener sur les touches du clavier
107+
function addEventListenerToShowHideTopbar() {
108+
109+
// Ajout d'un écouteur d'événements pour la touche 's'
110+
document.addEventListener('keydown', function(event) {
111+
if (event.key === 's') {
112+
showTopBar();
113+
return false;
114+
}
115+
});
116+
117+
// Ajout d'un écouteur d'événements pour la touche 'h'
118+
document.addEventListener('keydown', function(event) {
119+
if (event.key === 'h') {
120+
hideTopBar();
121+
return false;
122+
}
123+
});
124+
}
125+
126+
//
60127
if (
61128
document.readyState === "complete" ||
62129
document.readyState === "interactive"
63130
) {
64131
// call on next available tick
65132
setTimeout(topbarInjector, 1);
133+
setTimeout(addEventListenerToShowHideTopbar, 1);
66134
} else {
67135
document.addEventListener("DOMContentLoaded", topbarInjector);
136+
document.addEventListener("DOMContentLoaded", addEventListenerToShowHideTopbar);
68137
}
69138

139+
//
70140
window.onload = function() {
71141

72142
/* google analytics */
@@ -88,7 +158,12 @@ window.onload = function() {
88158
fetch('https://raw.githubusercontent.com/control-toolbox/control-toolbox.github.io/main/_includes/footer.html')
89159
.then(response => response.text())
90160
.then(text => footer.innerHTML = text);
91-
document.body.appendChild(footer);
92161

93-
};
162+
var docs_main = document.getElementsByClassName("docs-main");
163+
if (docs_main.length > 0) {
164+
docs_main[0].appendChild(footer);
165+
} else {
166+
document.body.appendChild(footer);
167+
}
94168

169+
};

0 commit comments

Comments
 (0)