-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
130 lines (101 loc) · 3.52 KB
/
Copy pathscript.js
File metadata and controls
130 lines (101 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
$(document).ready(function(){
//STICKY NAV
let navOffset = $('.about-section').offset().top;
$('nav').wrap('<div class= "nav-placeholder"></div>');
$('.nav-placeholder').height($('nav').outerHeight());
$(window).scroll(function(){
let scrollPos = $(window).scrollTop();
if (scrollPos >= navOffset - 65) {
$('nav').addClass('fixed');
}else {
$('nav').removeClass('fixed');
}
});
//SMOOTH SCROLLING SNIPPET*******************
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(function(event) {
// On-page links
if (
location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
&&
location.hostname == this.hostname
) {
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length) {
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate({
scrollTop: target.offset().top - 60
}, 1000, function() {
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) { // Checking if the target was focused
return false;
} else {
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
};
});
}
}
});
//UNDERLINE NAV LINK ON SCROLL
let scrollLink = $('.scroll');
$(window).scroll(function(){
let scrollBarLocation =$(this).scrollTop();
scrollLink.each(function(){
let sectionOffset = $(this.hash).offset().top;
if (sectionOffset - 65 <= scrollBarLocation) {
$(this).parent().addClass('no-hover');
$(this).parent().siblings().removeClass('no-hover');
$(this).parent().addClass('underline');
$(this).parent().siblings().removeClass('underline');
}
});
});
//MOBILE NAVIGATION
$('.fa-bars').click(function(){
$('.nav-div ul').slideToggle();
let icon = $('#mobile');
if (icon.hasClass('fa-bars')) {
icon.addClass('fa-times');
icon.removeClass('fa-bars');
}else{
icon.addClass('fa-bars');
icon.removeClass('fa-times');
}
});
//BUTTON SUBMIT ALERT
//BUTTON SUBMIT ALERT
$('.submit-btn').click(function(){
const firstName = document.getElementById('first-name').value;
const lastName = document.getElementById('last-name').value;
const email = document.getElementById('email').value;
if (firstName === '' || firstName.match(/\d/)) {
alert('You must input a valid first name');
}else if (lastName === '' || lastName.match(/\d/)) {
alert('You must input a valid last name');
}else if (email === '' || !email.match(/[@]/)) {
alert('You must input a valid email');
}else{
alert('Thank you, we will be contacting you soon!');
$('.first-name').wrap('<form>').closest('form').get(0).reset();
$('.first-name').unwrap();
$('.last-name').wrap('<form>').closest('form').get(0).reset();
$('.last-name').unwrap();
$('.e-mail').wrap('<form>').closest('form').get(0).reset();
$('.e-mail').unwrap();
$('.text-area').wrap('<form>').closest('form').get(0).reset();
$('.text-area').unwrap();
}
});
});