-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
99 lines (85 loc) · 3.9 KB
/
Copy pathscript.js
File metadata and controls
99 lines (85 loc) · 3.9 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
document.addEventListener('DOMContentLoaded', function() {
const mobileMenuBtn = document.getElementById('mobileMenuBtn');
const navLinks = document.getElementById('navLinks');
if (mobileMenuBtn) {
mobileMenuBtn.addEventListener('click', function() {
navLinks.classList.toggle('active');
mobileMenuBtn.classList.toggle('active');
mobileMenuBtn.setAttribute('aria-expanded', navLinks.classList.contains('active'));
mobileMenuBtn.setAttribute('aria-label', navLinks.classList.contains('active') ? 'Close navigation menu' : 'Open navigation menu');
});
}
const navLinkItems = document.querySelectorAll('.nav-links a');
navLinkItems.forEach(link => {
link.addEventListener('click', function() {
if (navLinks.classList.contains('active')) {
navLinks.classList.remove('active');
mobileMenuBtn.classList.remove('active');
mobileMenuBtn.setAttribute('aria-expanded', 'false');
mobileMenuBtn.setAttribute('aria-label', 'Open navigation menu');
}
});
});
const contactForm = document.getElementById('contactForm');
if (contactForm) {
contactForm.addEventListener('submit', function(event) {
event.preventDefault();
const formData = new FormData(contactForm);
const name = formData.get('name').trim();
const email = formData.get('email').trim();
const subject = formData.get('subject').trim();
const message = formData.get('message').trim();
const body = `Name: ${name}\nEmail: ${email}\n\n${message}`;
const contactStatus = document.getElementById('contactStatus');
window.location.href = `mailto:delivosnikos@gmail.com?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
contactStatus.textContent = 'Your email app should open with the message ready to send.';
});
}
const backToTopButton = document.getElementById('backToTop');
if (backToTopButton) {
window.addEventListener('scroll', function() {
if (window.pageYOffset > 300) {
backToTopButton.classList.add('show');
} else {
backToTopButton.classList.remove('show');
}
});
backToTopButton.addEventListener('click', function(e) {
e.preventDefault();
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
}
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
const href = this.getAttribute('href');
if (href === '#' || this.classList.contains('lightbox-close')) {
return;
}
e.preventDefault();
const targetId = href.substring(href.indexOf('#') + 1);
const targetElement = document.getElementById(targetId);
if (targetElement) {
const headerOffset = 80;
const elementPosition = targetElement.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - headerOffset;
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
}
});
});
const header = document.getElementById('header');
if (header) {
window.addEventListener('scroll', function() {
if (window.scrollY > 50) {
header.classList.add('scrolled');
} else {
header.classList.remove('scrolled');
}
});
}
});