-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstaff-directory.js
More file actions
42 lines (33 loc) · 1.11 KB
/
Copy pathstaff-directory.js
File metadata and controls
42 lines (33 loc) · 1.11 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
/* staff-directory.js — Staff filtering functionality */
(function () {
const filterBtns = document.querySelectorAll('.filter-btn');
const staffCards = document.querySelectorAll('.staff-card');
if (!filterBtns.length || !staffCards.length) return;
function filterStaff(category) {
staffCards.forEach(card => {
const cardCategory = card.dataset.category;
if (category === 'all' || cardCategory === category) {
card.classList.remove('hidden');
} else {
card.classList.add('hidden');
}
});
}
filterBtns.forEach(btn => {
btn.addEventListener('click', function () {
const category = this.dataset.filter;
// Update active button
filterBtns.forEach(b => b.classList.remove('active'));
this.classList.add('active');
// Filter cards
filterStaff(category);
// Scroll to grid
const grid = document.querySelector('.staff-grid');
if (grid) {
grid.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
});
// Initialize with 'all' category
filterStaff('all');
})();