|
| 1 | +// Lightbox functionality for Mermaid diagrams |
| 2 | +document.addEventListener('DOMContentLoaded', function() { |
| 3 | + // Create lightbox modal for Mermaid diagrams |
| 4 | + const lightbox = document.createElement('div'); |
| 5 | + lightbox.id = 'mermaid-lightbox'; |
| 6 | + lightbox.style.cssText = ` |
| 7 | + display: none; |
| 8 | + position: fixed; |
| 9 | + z-index: 9999; |
| 10 | + left: 0; |
| 11 | + top: 0; |
| 12 | + width: 100%; |
| 13 | + height: 100%; |
| 14 | + background-color: rgba(0,0,0,0.9); |
| 15 | + cursor: zoom-out; |
| 16 | + `; |
| 17 | + |
| 18 | + const lightboxContent = document.createElement('div'); |
| 19 | + lightboxContent.style.cssText = ` |
| 20 | + position: absolute; |
| 21 | + top: 50%; |
| 22 | + left: 50%; |
| 23 | + transform: translate(-50%, -50%); |
| 24 | + max-width: 95%; |
| 25 | + max-height: 95%; |
| 26 | + overflow: auto; |
| 27 | + `; |
| 28 | + |
| 29 | + const closeBtn = document.createElement('span'); |
| 30 | + closeBtn.innerHTML = '×'; |
| 31 | + closeBtn.style.cssText = ` |
| 32 | + position: absolute; |
| 33 | + top: 15px; |
| 34 | + right: 35px; |
| 35 | + color: #f1f1f1; |
| 36 | + font-size: 40px; |
| 37 | + font-weight: bold; |
| 38 | + cursor: pointer; |
| 39 | + z-index: 10000; |
| 40 | + `; |
| 41 | + closeBtn.onclick = function() { |
| 42 | + lightbox.style.display = 'none'; |
| 43 | + }; |
| 44 | + |
| 45 | + lightbox.appendChild(closeBtn); |
| 46 | + lightbox.appendChild(lightboxContent); |
| 47 | + document.body.appendChild(lightbox); |
| 48 | + |
| 49 | + // Click outside to close |
| 50 | + lightbox.onclick = function(e) { |
| 51 | + if (e.target === lightbox) { |
| 52 | + lightbox.style.display = 'none'; |
| 53 | + } |
| 54 | + }; |
| 55 | + |
| 56 | + // ESC key to close |
| 57 | + document.addEventListener('keydown', function(e) { |
| 58 | + if (e.key === 'Escape' && lightbox.style.display === 'block') { |
| 59 | + lightbox.style.display = 'none'; |
| 60 | + } |
| 61 | + }); |
| 62 | + |
| 63 | + // Make all Mermaid diagrams clickable |
| 64 | + const mermaidDivs = document.querySelectorAll('.mermaid'); |
| 65 | + mermaidDivs.forEach(function(div) { |
| 66 | + div.style.cursor = 'zoom-in'; |
| 67 | + div.title = 'Click to enlarge'; |
| 68 | + |
| 69 | + div.addEventListener('click', function() { |
| 70 | + const clone = div.cloneNode(true); |
| 71 | + |
| 72 | + // Style the cloned diagram to fill the lightbox |
| 73 | + clone.style.cssText = ` |
| 74 | + cursor: default; |
| 75 | + width: 90vw; |
| 76 | + max-width: 1400px; |
| 77 | + height: auto; |
| 78 | + margin: auto; |
| 79 | + `; |
| 80 | + |
| 81 | + // Find and resize the SVG inside |
| 82 | + const svg = clone.querySelector('svg'); |
| 83 | + if (svg) { |
| 84 | + svg.style.cssText = ` |
| 85 | + width: 100% !important; |
| 86 | + height: auto !important; |
| 87 | + max-width: none !important; |
| 88 | + max-height: 90vh !important; |
| 89 | + `; |
| 90 | + svg.removeAttribute('width'); |
| 91 | + svg.removeAttribute('height'); |
| 92 | + } |
| 93 | + |
| 94 | + lightboxContent.innerHTML = ''; |
| 95 | + lightboxContent.appendChild(clone); |
| 96 | + lightbox.style.display = 'block'; |
| 97 | + }); |
| 98 | + }); |
| 99 | +}); |
| 100 | + |
1 | 101 | // Custom JavaScript to make long parameter lists in class signatures collapsible |
2 | 102 | document.addEventListener('DOMContentLoaded', function() { |
3 | 103 | console.log('Collapsible parameters script loaded'); |
|
0 commit comments