@@ -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+ //
60127if (
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+ //
70140window . 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