Skip to content

Commit 2b569b3

Browse files
Separated nav links away from each other a bit more.
Removed unused javascript code from site.js Moved unused js code into snippets.js.
1 parent aa671fa commit 2b569b3

File tree

3 files changed

+87
-111
lines changed

3 files changed

+87
-111
lines changed

_sass/style.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,11 @@ a {
254254
}
255255

256256
.navigation__link {
257-
padding-left: 0.5em;
258-
padding-right: 0.5em;
257+
margin-right: 0.5em;
259258
text-decoration: none;
260259
font-size: 1.25em;
261260
font-family: 'Encode Sans Expanded', sans-serif;
262261
color: $nav-link!important;
263-
//display: block;
264262
transition: all 0.5s ease-in-out;
265263
}
266264

@@ -663,7 +661,7 @@ a {
663661
}
664662

665663
.services {
666-
margin-top: 10%;
664+
margin-top: 5%;
667665
padding-left: 10vw;
668666
padding-right: 10vw;
669667
}

static/js/site.js

Lines changed: 7 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
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-

static/js/snippets.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
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+
122
// Responsive background image constructor.
223
class ResponsiveBackgroundImage {
324

@@ -66,3 +87,60 @@ $(document).ready(function () {
6687
removeChapters();
6788
});
6889
});
90+
91+
92+
function stopBodyScrolling (bool) {
93+
/**
94+
* Required to stop body scrolling on iOS devices (safari ignores
95+
* body overflow: hidden in css.
96+
*/
97+
if (bool === true) {
98+
document.body.addEventListener("touchmove", preventDefaultAction, false);
99+
} else {
100+
document.body.removeEventListener("touchmove", preventDefaultAction, false);
101+
}
102+
}
103+
104+
function setActiveLink() {
105+
var currentURL = window.location.href;
106+
$('.navigation__link, .footer__link').each(function () {
107+
if (this.href === currentURL) {
108+
$(this).addClass('active');
109+
}
110+
});
111+
}
112+
113+
function openNav() {
114+
scrollPosition = $(window).scrollTop();
115+
scrollBarWidth = (window.innerWidth - $(window).width());
116+
$(".body").addClass("no-scroll");
117+
stopBodyScrolling(true);
118+
// To prevent content from jumping when scrollbar disappears.
119+
$(window).scrollTop(scrollPosition);
120+
$(".body").css("padding-right", scrollBarWidth + "px");
121+
buttonOpenContainer.css("pointer-events", "none");
122+
buttonOpenContainer.toggle(500, showCloseButton);
123+
hamburgerBar.css("background-color", "transparent");
124+
navigationOverlay.css("width", "100%");
125+
}
126+
127+
/* Close when someone clicks on the "x" symbol inside the overlay */
128+
function closeNav() {
129+
$(".body").removeClass("no-scroll");
130+
stopBodyScrolling(false);
131+
// To stop content jerking left-right when scrollbar is restored.
132+
$(".body").css("padding-right", "");
133+
hamburgerBar.css("background-color", "#ffffff");
134+
navigationOverlay.css("width", "0%");
135+
buttonOpenContainer.css("display", "inline");
136+
buttonOpenContainer.css("pointer-events", "auto");
137+
buttonCloseContainer.css("display", "none");
138+
}
139+
140+
function showCloseButton() {
141+
buttonCloseContainer.css("display", "inline");
142+
}
143+
144+
// Add active class to navigation elements in the navigation overlay and
145+
// footer on page load.
146+
$(setActiveLink());

0 commit comments

Comments
 (0)