-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
138 lines (124 loc) · 4.26 KB
/
Copy pathscript.js
File metadata and controls
138 lines (124 loc) · 4.26 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
// Programming Club - Minimal JavaScript for Interactive Features
// Theme Toggle (light / dark)
document.addEventListener('DOMContentLoaded', function() {
const themeToggle = document.querySelector('.theme-toggle');
const root = document.documentElement;
function applyTheme(theme) {
if (theme === 'light') {
root.setAttribute('data-theme', 'light');
} else {
root.removeAttribute('data-theme');
}
if (themeToggle) {
themeToggle.setAttribute('aria-pressed', theme === 'light');
}
}
const savedTheme = (function() {
try {
const stored = localStorage.getItem('theme');
if (stored) return stored;
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
return 'light';
}
} catch (e) {}
return 'dark';
})();
applyTheme(savedTheme);
if (themeToggle) {
themeToggle.addEventListener('click', function() {
const next = root.getAttribute('data-theme') === 'light' ? 'dark' : 'light';
applyTheme(next);
try { localStorage.setItem('theme', next); } catch (e) {}
});
}
});
// Mobile Menu Toggle
document.addEventListener('DOMContentLoaded', function() {
const menuToggle = document.querySelector('.menu-toggle');
const navMenu = document.querySelector('.nav-menu');
if (menuToggle && navMenu) {
menuToggle.addEventListener('click', function() {
navMenu.classList.toggle('active');
const isExpanded = navMenu.classList.contains('active');
menuToggle.setAttribute('aria-expanded', isExpanded);
});
// Close menu when clicking outside
document.addEventListener('click', function(e) {
if (!e.target.closest('nav')) {
navMenu.classList.remove('active');
menuToggle.setAttribute('aria-expanded', 'false');
}
});
// Close menu when pressing Escape
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape' && navMenu.classList.contains('active')) {
navMenu.classList.remove('active');
menuToggle.setAttribute('aria-expanded', 'false');
}
});
}
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
const href = this.getAttribute('href');
if (href !== '#' && href !== '') {
e.preventDefault();
const target = document.querySelector(href);
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
// Close mobile menu if open
if (navMenu) {
navMenu.classList.remove('active');
if (menuToggle) {
menuToggle.setAttribute('aria-expanded', 'false');
}
}
}
}
});
});
// Add active state to current page in navigation
const currentPage = window.location.pathname.split('/').pop() || 'index.html';
document.querySelectorAll('nav ul a').forEach(link => {
const linkPage = link.getAttribute('href');
if (linkPage === currentPage || (currentPage === '' && linkPage === 'index.html')) {
link.setAttribute('aria-current', 'page');
link.style.color = 'var(--primary-color)';
}
});
// Intersection Observer for fade-in animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe cards and sections for animation
document.querySelectorAll('.card, .member-card').forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(20px)';
el.style.transition = 'opacity 0.6s ease-out, transform 0.6s ease-out';
observer.observe(el);
});
// Add keyboard navigation support for cards
document.querySelectorAll('.card, .member-card').forEach(card => {
card.setAttribute('tabindex', '0');
card.addEventListener('keydown', function(e) {
if (e.key === 'Enter' || e.key === ' ') {
const link = card.querySelector('a');
if (link) {
link.click();
}
}
});
});
});