astro-tractstack 2.0.0-rc.13 → 2.0.0-rc.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-tractstack",
3
- "version": "2.0.0-rc.13",
3
+ "version": "2.0.0-rc.14",
4
4
  "description": "Astro integration for TractStack - redeeming the web from boring experiences",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -400,60 +400,61 @@ const authStatus = {
400
400
  });
401
401
  }
402
402
 
403
- // Admin Modal JavaScript - Only runs when admin elements exist
404
- const heartBtn = document.getElementById('admin-heart-btn');
405
- const modal = document.getElementById('admin-modal');
406
- const closeBtn = document.getElementById('admin-modal-close');
407
- const iframe = document.getElementById('admin-sysop-iframe');
408
-
409
- if (heartBtn && modal && closeBtn && iframe) {
410
- // Open modal when heart icon is clicked
411
- heartBtn.addEventListener('click', function (e) {
403
+ // Admin Modal JavaScript - Use event delegation
404
+ document.addEventListener('click', function (e) {
405
+ if (e.target && (e.target as Element).closest('#admin-heart-btn')) {
412
406
  e.preventDefault();
413
- modal.classList.remove('hidden');
414
- modal.setAttribute('aria-hidden', 'false');
415
-
416
- // Focus management for accessibility
417
- closeBtn.focus();
418
-
419
- // Prevent body scroll when modal is open
420
- document.body.style.overflow = 'hidden';
421
- });
407
+ const modal = document.getElementById('admin-modal');
408
+ const closeBtn = document.getElementById('admin-modal-close');
409
+
410
+ if (modal && closeBtn) {
411
+ modal.classList.remove('hidden');
412
+ modal.setAttribute('aria-hidden', 'false');
413
+ closeBtn.focus();
414
+ document.body.style.overflow = 'hidden';
415
+ }
416
+ return;
417
+ }
422
418
 
423
- // Close modal when X button is clicked
424
- closeBtn.addEventListener('click', function (e) {
419
+ if (e.target && (e.target as Element).closest('#admin-modal-close')) {
425
420
  e.preventDefault();
426
421
  closeModal();
427
- });
422
+ return;
423
+ }
428
424
 
429
- // Close modal when clicking outside the iframe
430
- modal.addEventListener('click', function (e) {
431
- if (e.target === modal) {
432
- closeModal();
433
- }
434
- });
425
+ if (e.target && (e.target as Element).id === 'admin-modal') {
426
+ closeModal();
427
+ return;
428
+ }
429
+ });
435
430
 
436
- // Close modal with Escape key
437
- document.addEventListener('keydown', function (e) {
438
- if (e.key === 'Escape' && !modal.classList.contains('hidden')) {
431
+ document.addEventListener('keydown', function (e) {
432
+ if (e.key === 'Escape') {
433
+ const modal = document.getElementById('admin-modal');
434
+ if (modal && !modal.classList.contains('hidden')) {
439
435
  closeModal();
440
436
  }
441
- });
437
+ }
438
+ });
442
439
 
443
- function closeModal() {
444
- modal?.classList.add('hidden');
445
- modal?.setAttribute('aria-hidden', 'true');
440
+ function closeModal() {
441
+ const modal = document.getElementById('admin-modal');
442
+ const heartBtn = document.getElementById('admin-heart-btn');
446
443
 
447
- // Restore body scroll
448
- document.body.style.overflow = '';
444
+ modal?.classList.add('hidden');
445
+ modal?.setAttribute('aria-hidden', 'true');
446
+ document.body.style.overflow = '';
447
+ heartBtn?.focus();
448
+ }
449
449
 
450
- // Return focus to heart button for accessibility
451
- heartBtn?.focus();
450
+ // iframe error handling
451
+ document.addEventListener('DOMContentLoaded', function () {
452
+ const iframe = document.getElementById('admin-sysop-iframe');
453
+ if (iframe) {
454
+ iframe.addEventListener('error', function () {
455
+ console.error('Failed to load admin panel');
456
+ });
452
457
  }
453
-
454
- iframe.addEventListener('error', function () {
455
- console.error('Failed to load admin panel');
456
- });
457
- }
458
+ });
458
459
  }
459
460
  </script>