|
1 | 1 | /** |
2 | | - * RESTEasy Theme Switcher |
3 | | - * Toggles between light and dark modes using Bootstrap's data-bs-theme |
| 2 | + * RESTEasy Site JavaScript |
| 3 | + * Main JavaScript file containing theme switcher, navigation, and interactive features |
4 | 4 | */ |
5 | 5 |
|
| 6 | +/** |
| 7 | + * Theme Switcher |
| 8 | + * Toggles between light and dark modes using Bootstrap's data-bs-theme |
| 9 | + */ |
6 | 10 | (function() { |
7 | 11 | 'use strict'; |
8 | 12 |
|
|
151 | 155 | }); |
152 | 156 | }); |
153 | 157 | })(); |
| 158 | + |
| 159 | +/** |
| 160 | + * Clickable News Cards |
| 161 | + * Makes entire news/blog cards clickable while maintaining link accessibility |
| 162 | + */ |
| 163 | +(function() { |
| 164 | + 'use strict'; |
| 165 | + |
| 166 | + document.addEventListener('DOMContentLoaded', () => { |
| 167 | + // Select all news/blog cards |
| 168 | + const cards = document.querySelectorAll('.news-list-blocks .card, .blog-post-card'); |
| 169 | + |
| 170 | + cards.forEach(card => { |
| 171 | + // Find the main link (either in title or "Read More") |
| 172 | + const link = card.querySelector('.card-title a, .post-title a, a[href*="/posts/"]'); |
| 173 | + |
| 174 | + if (link) { |
| 175 | + // Make the card clickable |
| 176 | + card.style.cursor = 'pointer'; |
| 177 | + |
| 178 | + card.addEventListener('click', (e) => { |
| 179 | + // Don't trigger if clicking on an actual link (let the link handle it) |
| 180 | + if (e.target.tagName === 'A') { |
| 181 | + return; |
| 182 | + } |
| 183 | + |
| 184 | + // Respect modifier keys (cmd/ctrl click for new tab, etc.) |
| 185 | + if (e.metaKey || e.ctrlKey) { |
| 186 | + window.open(link.href, '_blank'); |
| 187 | + } else { |
| 188 | + window.location.href = link.href; |
| 189 | + } |
| 190 | + }); |
| 191 | + |
| 192 | + // Improve accessibility - make cards keyboard navigable |
| 193 | + card.setAttribute('tabindex', '0'); |
| 194 | + card.setAttribute('role', 'article'); |
| 195 | + |
| 196 | + // Handle keyboard navigation (Enter key) |
| 197 | + card.addEventListener('keydown', (e) => { |
| 198 | + if (e.key === 'Enter') { |
| 199 | + if (e.metaKey || e.ctrlKey) { |
| 200 | + window.open(link.href, '_blank'); |
| 201 | + } else { |
| 202 | + window.location.href = link.href; |
| 203 | + } |
| 204 | + } |
| 205 | + }); |
| 206 | + } |
| 207 | + }); |
| 208 | + }); |
| 209 | +})(); |
0 commit comments