1- var buttonOpenContainer = $ ( ".navigation__button-open-container" ) ;
2- var hamburgerBar = $ ( ".navigation__hamburger-bar" ) ;
3- var navigationOverlay = $ ( ".navigation__overlay" ) ;
4- var buttonCloseContainer = $ ( ".navigation__button-close-container" ) ;
5- var navigationButtonClose = $ ( ".navigation__button-close" ) ;
6- var scrollPosition = 0 ;
7- var scrollBarWidth = 0 ;
8- var parallelSection = false ;
9- var preventDefaultAction = function ( e ) {
10- e . preventDefault ( ) ;
11- } ;
12-
13-
14- $ ( document ) . ready ( function ( ) {
15- buttonOpenContainer . on ( "click" , openNav ) ;
16- navigationButtonClose . on ( "click" , closeNav ) ;
17- } ) ;
18-
19-
20-
21- function removeChapters ( ) {
22- o
23- }
24-
251// Code for active links and scrolling
262$ ( document ) . ready ( function ( ) {
273 $ ( ".navbar-nav .nav-item .nav-link" ) . on ( "click" , function ( ) {
@@ -42,15 +18,15 @@ $(document).ready(function() {
4218 bottom = top + $ ( this ) . outerHeight ( ) ;
4319
4420 if ( cur_pos >= top && cur_pos <= bottom ) {
45- nav . find ( 'a' ) . removeClass ( 'active' ) ;
46- sections . removeClass ( 'active' ) ;
21+ if ( $ ( window ) . width ( ) >= 992 && this . id === "chapters" ) {
22+ // pass - on large screens events & chapters are parallel,
23+ // ignore chapters section then
24+ } else {
25+ nav . find ( 'a' ) . removeClass ( 'active' ) ;
26+ sections . removeClass ( 'active' ) ;
4727
48- if ( $ ( window ) . width ( ) < 992 ) {
49- $ ( this ) . addClass ( 'active' ) ;
50- nav . find ( 'a[href="#' + $ ( this ) . attr ( 'id' ) + '"]' ) . addClass ( 'active' ) ;
51- } else if ( this . id !== "chapters" ) {
5228 $ ( this ) . addClass ( 'active' ) ;
53- nav . find ( 'a[href="#' + $ ( this ) . attr ( 'id' ) + '"]' ) . addClass ( 'active' ) ;
29+ nav . find ( 'a[href="#' + $ ( this ) . attr ( 'id' ) + '"]' ) . addClass ( 'active' ) ;
5430 }
5531 }
5632 } ) ;
@@ -96,79 +72,3 @@ $(document).ready(function() {
9672
9773
9874
99-
100-
101-
102-
103-
104-
105-
106-
107-
108-
109-
110-
111-
112-
113-
114-
115-
116-
117- function stopBodyScrolling ( bool ) {
118- /**
119- * Required to stop body scrolling on iOS devices (safari ignores
120- * body overflow: hidden in css.
121- */
122- if ( bool === true ) {
123- document . body . addEventListener ( "touchmove" , preventDefaultAction , false ) ;
124- } else {
125- document . body . removeEventListener ( "touchmove" , preventDefaultAction , false ) ;
126- }
127- }
128-
129- function setActiveLink ( ) {
130- var currentURL = window . location . href ;
131- $ ( '.navigation__link, .footer__link' ) . each ( function ( ) {
132- if ( this . href === currentURL ) {
133- $ ( this ) . addClass ( 'active' ) ;
134- }
135- } ) ;
136- }
137-
138- function openNav ( ) {
139- scrollPosition = $ ( window ) . scrollTop ( ) ;
140- scrollBarWidth = ( window . innerWidth - $ ( window ) . width ( ) ) ;
141- $ ( ".body" ) . addClass ( "no-scroll" ) ;
142- stopBodyScrolling ( true ) ;
143- // To prevent content from jumping when scrollbar disappears.
144- $ ( window ) . scrollTop ( scrollPosition ) ;
145- $ ( ".body" ) . css ( "padding-right" , scrollBarWidth + "px" ) ;
146- buttonOpenContainer . css ( "pointer-events" , "none" ) ;
147- buttonOpenContainer . toggle ( 500 , showCloseButton ) ;
148- hamburgerBar . css ( "background-color" , "transparent" ) ;
149- navigationOverlay . css ( "width" , "100%" ) ;
150- }
151-
152- /* Close when someone clicks on the "x" symbol inside the overlay */
153- function closeNav ( ) {
154- $ ( ".body" ) . removeClass ( "no-scroll" ) ;
155- stopBodyScrolling ( false ) ;
156- // To stop content jerking left-right when scrollbar is restored.
157- $ ( ".body" ) . css ( "padding-right" , "" ) ;
158- hamburgerBar . css ( "background-color" , "#ffffff" ) ;
159- navigationOverlay . css ( "width" , "0%" ) ;
160- buttonOpenContainer . css ( "display" , "inline" ) ;
161- buttonOpenContainer . css ( "pointer-events" , "auto" ) ;
162- buttonCloseContainer . css ( "display" , "none" ) ;
163- }
164-
165- function showCloseButton ( ) {
166- buttonCloseContainer . css ( "display" , "inline" ) ;
167- }
168-
169- // Add active class to navigation elements in the navigation overlay and
170- // footer on page load.
171- $ ( setActiveLink ( ) ) ;
172-
173-
174-
0 commit comments