@@ -14,14 +14,14 @@ $(window).on('resize', () => {
1414
1515 let newWidth = $ ( document ) . width ( ) ;
1616
17- if ( Math . abs ( globalData . starting_width - newWidth ) > globalData . tol_resize ) document . location . reload ( true ) ;
17+ if ( Math . abs ( globalData . starting_width - newWidth ) > globalData . tol_resize ) document . location . reload ( ) ;
1818
1919} ) ;
2020
21- function openNotesBox ( ) {
21+ function getNotesTemplate ( ) {
2222
23- let aboutBoxHtml = `
24- <div class="modalbox-class" id="modalbox-notes" role="dialog">
23+ return `
24+ <div class="modalbox-class" id="modalbox-notes" role="dialog" style="display:none;" >
2525
2626 <header class="modalbox-header-class">
2727
@@ -107,77 +107,96 @@ function openNotesBox() {
107107
108108 </div>` ;
109109
110- $ ( "#modalbox-notes" ) . remove ( ) ;
110+ }
111111
112- $ ( "#modalbox-open-div" ) . append ( aboutBoxHtml ) ;
112+ function openNotesBox ( ) {
113113
114- mobileNotesBox ( globalData . modalbox_size ) ;
114+ let $modal = $ ( "#modalbox-notes" ) ;
115115
116- $ ( '.overlay' ) . css ( 'display' , 'block' ) ;
116+ if ( $modal . length === 0 ) {
117+
118+ $ ( "#modalbox-open-div" ) . append ( getNotesTemplate ( ) ) ;
119+
120+ $modal = $ ( "#modalbox-notes" ) ;
121+
122+ }
123+
124+ applyMobileStyles ( $modal ) ;
125+
126+ $modal . show ( ) ;
127+
128+ $ ( '.overlay' ) . show ( ) ;
117129
118130}
119131
120- function mobileNotesBox ( windowSize ) {
132+ function applyMobileStyles ( $element ) {
121133
122134 if ( $ ( window ) . width ( ) <= 768 ) {
123135
124- $ ( "#modalbox-notes" ) . css ( {
136+ $element . css ( {
125137
126138 'marginLeft' : 'unset' ,
127139
128140 'left' : 'unset' ,
129141
130- 'width' : windowSize
142+ 'width' : globalData . modalbox_size
131143
132144 } ) ;
133145
134146 }
135147
136148}
137149
138- // Merci: https://stackoverflow.com/questions/48002147/how-to-activate-and-disable-jquery-click-events-on-an-html-element
139- $ ( '#display-mobile-menu' ) . on ( 'click' , function ( ) {
150+ $ ( document ) . ready ( function ( ) {
151+
152+ $ ( "#notes-btn-id" ) . on ( "click" , openNotesBox ) ;
140153
141- let $this = $ ( this ) ;
154+ $ ( document ) . on ( 'click' , '#close-notes-btn, .overlay' , ( ) => {
142155
143- if ( ! $this . is ( ".active" ) ) {
156+ $ ( '#modalbox-notes' ) . hide ( ) ;
144157
145- $this . addClass ( 'active' ) ;
158+ $ ( '.overlay' ) . hide ( ) ;
146159
147- $this . attr ( 'aria-expanded' , 'true' ) ;
160+ } ) ;
148161
149- $this . attr ( 'aria-label' , 'Fermer le menu de navigation.' ) ;
162+ $ ( "#copyright" ) . text ( new Date ( ) . getFullYear ( ) ) ;
150163
151- $ ( ".menu-dropdown .menu-dropdown-btn" ) . css ( "display" , "block" ) ;
164+ // Merci: https://stackoverflow.com/questions/48002147/how-to-activate-and-disable-jquery-click-events-on-an-html-element
165+ $ ( '#display-mobile-menu' ) . on ( 'click' , function ( ) {
152166
153- $ ( ".menu-item" ) . css ( "display" , "block" ) ;
167+ let $this = $ ( this ) ;
154168
155- $this . html ( '<i class="fa-solid fa-xmark"></i>' ) ;
169+ if ( ! $this . is ( ".active" ) ) {
156170
157- } else {
171+ $this . addClass ( 'active' ) ;
158172
159- $this . removeClass ( 'active ') ;
173+ $this . attr ( 'aria-expanded' , 'true ') ;
160174
161- $this . attr ( 'aria-expanded ' , 'false ' ) ;
175+ $this . attr ( 'aria-label ' , 'Fermer le menu de navigation. ' ) ;
162176
163- $this . attr ( 'aria-label' , 'Ouvrir le menu de navigation.' ) ;
177+ $ ( ". menu-dropdown .menu-dropdown-btn" ) . css ( "display" , "block" ) ;
164178
165- $this . html ( '<i class="fa-solid fa-bars"></i>' ) ;
179+ $ ( ".menu-item" ) . css ( "display" , "block" ) ;
166180
167- $ ( ".menu-dropdown .menu-dropdown-btn" ) . css ( "display" , "none" ) ;
181+ $this . html ( '<i class="fa-solid fa-xmark"></i>' ) ;
168182
169- $ ( ".menu-item" ) . css ( "display" , "none" ) ;
183+ } else {
170184
171- }
185+ $this . removeClass ( 'active' ) ;
172186
173- } ) ;
187+ $this . attr ( 'aria-expanded' , 'false' ) ;
174188
175- $ ( document ) . ready ( function ( ) {
189+ $this . attr ( 'aria-label' , 'Ouvrir le menu de navigation.' ) ;
176190
177- $ ( "#notes-btn-id" ) . on ( "click" , openNotesBox ) ;
191+ $this . html ( '<i class="fa-solid fa-bars"></i>' ) ;
192+
193+ $ ( ".menu-dropdown .menu-dropdown-btn" ) . css ( "display" , "none" ) ;
178194
179- $ ( document ) . on ( 'click' , '#close-notes-btn, .overlay' , ( ) => { $ ( '#modalbox-notes, .overlay' ) . hide ( ) ; } ) ;
195+ $ ( ".menu-item" ) . css ( "display" , "none" ) ;
180196
181- $ ( "#copyright" ) . html ( new Date ( ) . getFullYear ( ) ) ;
197+ }
198+
199+ } ) ;
182200
183201} ) ;
202+
0 commit comments