-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
189 lines (165 loc) · 5.76 KB
/
script.js
File metadata and controls
189 lines (165 loc) · 5.76 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// Header scroll effect
window.addEventListener('scroll', () => {
const header = document.getElementById('header');
if (window.scrollY > 50) {
header.classList.add('scrolled');
} else {
header.classList.remove('scrolled');
}
});
// Smooth scroll function
function scrollToSection(sectionId) {
const element = document.getElementById(sectionId);
if (element) {
element.scrollIntoView({ behavior: 'smooth' });
}
}
// Mobile menu functionality
const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
const navLinks = document.querySelector('.nav-links');
mobileMenuBtn.addEventListener('click', () => {
navLinks.classList.toggle('mobile-open');
mobileMenuBtn.classList.toggle('active');
});
// Publications filtering
const filterButtons = document.querySelectorAll('.filter-btn');
const publicationCards = document.querySelectorAll('.publication-card');
filterButtons.forEach(button => {
button.addEventListener('click', () => {
// Remove active class from all buttons
filterButtons.forEach(btn => btn.classList.remove('active'));
// Add active class to clicked button
button.classList.add('active');
const filter = button.getAttribute('data-filter');
publicationCards.forEach(card => {
if (filter === 'all' || card.getAttribute('data-type') === filter) {
card.style.display = 'block';
// Add fade-in animation
card.style.opacity = '0';
setTimeout(() => {
card.style.opacity = '1';
}, 50);
} else {
card.style.display = 'none';
}
});
});
});
// Add CSS for mobile menu
const style = document.createElement('style');
style.textContent = `
@media (max-width: 768px) {
.nav-links {
position: absolute;
top: 100%;
left: 0;
right: 0;
background: rgba(17, 24, 39, 0.95);
backdrop-filter: blur(12px);
flex-direction: column;
padding: 24px;
border-top: 1px solid rgba(75, 85, 99, 0.3);
transform: translateY(-100%);
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
}
.nav-links.mobile-open {
transform: translateY(0);
opacity: 1;
visibility: visible;
}
.mobile-menu-btn.active span:nth-child(1) {
transform: rotate(45deg) translate(5px, 5px);
}
.mobile-menu-btn.active span:nth-child(2) {
opacity: 0;
}
.mobile-menu-btn.active span:nth-child(3) {
transform: rotate(-45deg) translate(7px, -6px);
}
}
`;
document.head.appendChild(style);
// Intersection Observer for animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe elements for animation
document.addEventListener('DOMContentLoaded', () => {
const animateElements = document.querySelectorAll('.highlight-card, .publication-card, .contact-item');
animateElements.forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(20px)';
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(el);
});
});
// Navigation function for highlight cards
function navigateToSection(sectionId) {
// Hide all detail sections
const detailSections = document.querySelectorAll('.detail-section');
detailSections.forEach(section => {
section.classList.remove('active');
});
// Show target section
const targetSection = document.getElementById(sectionId);
if (targetSection) {
targetSection.classList.add('active');
// Smooth scroll to section
targetSection.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
// Update URL hash
history.pushState(null, null, `#${sectionId}`);
}
}
// Handle back button and direct URL access
window.addEventListener('load', () => {
const hash = window.location.hash.substring(1);
if (hash && document.getElementById(hash)) {
setTimeout(() => {
navigateToSection(hash);
}, 100);
}
});
window.addEventListener('popstate', () => {
const hash = window.location.hash.substring(1);
if (hash && document.getElementById(hash)) {
navigateToSection(hash);
} else {
// Hide all detail sections if no hash
const detailSections = document.querySelectorAll('.detail-section');
detailSections.forEach(section => {
section.classList.remove('active');
});
}
});
// Add close button functionality
document.addEventListener('DOMContentLoaded', () => {
// Add close buttons to detail sections
const detailSections = document.querySelectorAll('.detail-section');
detailSections.forEach(section => {
const closeButton = document.createElement('button');
closeButton.innerHTML = '× Close';
closeButton.className = 'close-detail-btn';
closeButton.onclick = () => {
section.classList.remove('active');
history.pushState(null, null, window.location.pathname);
};
const container = section.querySelector('.container');
if (container) {
container.insertBefore(closeButton, container.firstChild);
}
});
});