-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwatch.html
More file actions
431 lines (371 loc) · 11.6 KB
/
watch.html
File metadata and controls
431 lines (371 loc) · 11.6 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
---
layout: default
title: Watch Wallpapers
social_image: /wallpapers/watch/368x448/024.jpg
social_image_alt: Watch wallpaper from Visual Studio wallpapers collection
---
<h2>Watch Wallpapers</h2>
<div class="grid" id="wallpapers" role="list" aria-label="Watch wallpapers grid">
{% assign all_images = site.static_files | where: "extname", ".jpg" %}
{% assign watch_images = "" | split: "" %}
{% for image in all_images %}
{% if image.path contains 'wallpapers/watch/368x448' %}
{% assign watch_images = watch_images | push: image %}
{% endif %}
{% endfor %}
{% assign watch_images = watch_images | sort: "basename" | reverse %}
{% for image in watch_images %}
<div class="card"
role="listitem"
tabindex="0"
onclick="showPreviewModal('{{ image.basename }}{{ image.extname }}')"
onkeydown="if(event.key === 'Enter' || event.key === ' ') { event.preventDefault(); showPreviewModal('{{ image.basename }}{{ image.extname }}'); }"
aria-label="Preview watch wallpaper {{ image.basename }}">
<div class="image-container">
<img src="{{ site.baseurl }}/wallpapers/watch/368x448/{{ image.basename }}{{ image.extname }}" alt="Wallpaper {{ image.basename }}">
</div>
<div class="card-content">
<span class="hint">Click to preview</span>
</div>
</div>
{% endfor %}
</div>
<div id="previewModal" class="modal" role="dialog" aria-modal="true" aria-labelledby="previewModalTitle" hidden>
<div class="modal-content preview-content">
<div class="preview-layout">
<button class="nav-arrow prev-arrow" onclick="showPreviousWallpaper()" aria-label="Show previous wallpaper"><</button>
<div class="preview-image-container">
<img id="previewImage" src="" alt="Wallpaper Preview" aria-describedby="currentImageDesc">
<p id="currentImageDesc" class="sr-only"></p>
</div>
<button class="nav-arrow next-arrow" onclick="showNextWallpaper()" aria-label="Show next wallpaper">></button>
<div class="preview-sidebar">
<h3 id="previewModalTitle">Download Options</h3>
<div class="size-buttons preview-sizes" role="group" aria-label="Download size options">
<a href="#" class="button size-button" data-size="368x448" role="button">Download 368x448</a>
</div>
<div class="preview-settings">
<label class="checkbox-label">
<input type="checkbox" id="openInNewWindow" checked aria-describedby="openInNewWindowDesc">
Open in new window
</label>
<span id="openInNewWindowDesc" class="sr-only">Choose whether to open downloads in a new window or download directly</span>
</div>
<button class="button close-button" onclick="hidePreviewModal()" aria-label="Close preview">Close</button>
</div>
</div>
</div>
</div>
<style>
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 2rem;
padding: 1rem;
}
.card {
background: white;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
transition: transform 0.2s;
cursor: pointer;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.card img {
width: 100%;
height: auto;
display: block;
}
.card-content {
padding: 1rem;
text-align: center;
}
.button {
display: inline-block;
background-color: var(--primary);
color: white;
padding: 0.5rem 1rem;
border-radius: 20px;
text-decoration: none;
transition: background-color 0.3s;
border: none;
cursor: pointer;
}
.button:hover {
background-color: var(--secondary);
}
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1000;
justify-content: center;
align-items: center;
}
.modal-content {
background-color: white;
padding: 1rem;
border-radius: 15px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
text-align: center;
width: 95%;
max-width: 400px;
}
.preview-content {
width: 95%;
max-width: 1200px;
max-height: 95vh;
padding: 1rem;
}
@media (min-width: 768px) {
.modal-content {
padding: 2rem;
}
}
.preview-layout {
display: flex;
gap: 2rem;
align-items: flex-start;
flex-direction: column;
}
.preview-image-container {
width: 100%;
max-width: 600px;
margin: 0 auto;
}
.preview-image-container img {
width: 100%;
height: auto;
max-height: 400px;
object-fit: contain;
border-radius: 8px;
}
@media (min-width: 768px) {
.preview-image-container img {
max-height: 85vh;
}
}
.preview-sidebar {
width: 100%;
max-width: 600px;
margin: 0 auto;
}
@media (min-width: 1024px) {
.preview-layout {
flex-direction: row;
align-items: flex-start;
}
.preview-image-container {
margin: 0;
}
.preview-sidebar {
width: 250px;
margin: 0;
}
}
.preview-sidebar h3 {
margin-top: 0;
margin-bottom: 1rem;
}
.preview-sizes {
display: flex;
flex-direction: column;
gap: 0.5rem;
margin-bottom: 1.5rem;
}
.size-buttons {
display: grid;
gap: 1rem;
margin: 1.5rem 0;
}
.size-button {
display: block;
width: 100%;
}
.preview-settings {
margin-bottom: 1.5rem;
text-align: left;
}
.checkbox-label {
display: flex;
align-items: center;
gap: 0.5rem;
cursor: pointer;
font-size: 0.9rem;
color: #666;
}
.checkbox-label input[type="checkbox"] {
width: 16px;
height: 16px;
cursor: pointer;
}
.hint {
color: #666;
font-size: 0.9rem;
opacity: 0.8;
}
.nav-arrow {
position: absolute;
top: 50%;
transform: translateY(-50%);
background: rgba(0, 0, 0, 0.3);
color: white;
border: none;
width: 40px;
height: 40px;
border-radius: 50%;
font-size: 24px;
cursor: pointer;
transition: background-color 0.3s;
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
}
.nav-arrow:hover {
background: rgba(0, 0, 0, 0.5);
}
.prev-arrow {
left: 20px;
}
.next-arrow {
right: 20px;
}
@media (max-width: 768px) {
.nav-arrow {
width: 32px;
height: 32px;
font-size: 20px;
}
.prev-arrow {
left: 10px;
}
.next-arrow {
right: 10px;
}
}
</style>
<script>
let currentImage = '';
// Load user preference for opening in new window
const openInNewWindow = document.getElementById('openInNewWindow');
openInNewWindow.checked = localStorage.getItem('openInNewWindow') !== 'false'; // Default to true
// Save preference when checkbox is changed
openInNewWindow.addEventListener('change', function() {
localStorage.setItem('openInNewWindow', this.checked);
updateDownloadButtons();
});
// Array to store all wallpapers
let wallpapers = [];
let currentWallpaperIndex = 0;
// Initialize wallpapers array when the page loads
document.addEventListener('DOMContentLoaded', function() {
wallpapers = Array.from(document.querySelectorAll('.card'))
.map(card => card.querySelector('img').src.split('/').pop());
});
function updateDownloadButtons() {
const sizeButtons = document.querySelectorAll('.size-button');
const openInNew = openInNewWindow.checked;
sizeButtons.forEach(button => {
const size = button.dataset.size;
if (openInNew) {
button.target = '_blank';
button.removeAttribute('download');
} else {
button.removeAttribute('target');
const newFileName = `watch_${size}_${currentImage}`;
button.setAttribute('download', newFileName);
}
});
}
let focusedElementBeforeModal;
const focusableElements = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
function showPreviewModal(image) {
// Store last focused element
focusedElementBeforeModal = document.activeElement;
currentImage = image;
currentWallpaperIndex = wallpapers.indexOf(image);
const previewImage = document.getElementById('previewImage');
previewImage.src = `{{ site.baseurl }}/wallpapers/watch/368x448/${image}`;
const modal = document.getElementById('previewModal');
modal.hidden = false;
modal.style.display = 'flex';
// Set aria description
document.getElementById('currentImageDesc').textContent = `Watch wallpaper ${image.split('.')[0]}`;
// Setup download buttons
const sizeButtons = modal.querySelectorAll('.size-button');
sizeButtons.forEach(button => {
const size = button.dataset.size;
const downloadUrl = `{{ site.baseurl }}/wallpapers/watch/${size}/${currentImage}`;
button.href = downloadUrl;
button.removeAttribute('download');
});
updateDownloadButtons();
// Focus first focusable element
const focusable = modal.querySelectorAll(focusableElements);
if (focusable.length) focusable[0].focus();
}
function hidePreviewModal() {
const modal = document.getElementById('previewModal');
modal.style.display = 'none';
modal.hidden = true;
// Restore focus
if (focusedElementBeforeModal) {
focusedElementBeforeModal.focus();
}
}
// Add focus trap to modal
document.getElementById('previewModal').addEventListener('keydown', function(e) {
if (this.style.display !== 'flex') return;
const focusable = this.querySelectorAll(focusableElements);
const firstFocusable = focusable[0];
const lastFocusable = focusable[focusable.length - 1];
// Handle tab key
if (e.key === 'Tab') {
if (e.shiftKey) {
if (document.activeElement === firstFocusable) {
e.preventDefault();
lastFocusable.focus();
}
} else {
if (document.activeElement === lastFocusable) {
e.preventDefault();
firstFocusable.focus();
}
}
}
// Handle escape key
if (e.key === 'Escape') {
hidePreviewModal();
}
});
function showPreviousWallpaper() {
currentWallpaperIndex = (currentWallpaperIndex - 1 + wallpapers.length) % wallpapers.length;
showPreviewModal(wallpapers[currentWallpaperIndex]);
}
function showNextWallpaper() {
currentWallpaperIndex = (currentWallpaperIndex + 1) % wallpapers.length;
showPreviewModal(wallpapers[currentWallpaperIndex]);
}
// Add keyboard navigation
document.addEventListener('keydown', function(event) {
const modal = document.getElementById('previewModal');
if (modal.style.display === 'flex') {
if (event.key === 'ArrowLeft' || event.key === 'a') {
showPreviousWallpaper();
} else if (event.key === 'ArrowRight' || event.key === 'd') {
showNextWallpaper();
} else if (event.key === 'Escape') {
hidePreviewModal();
}
}
});
</script>