← Commit history

readme: key-page lightbox only intercepts when embedded; standalone falls back to opening the image

Ray ·a923fb7be9 ·3mo ago ·parent 39acd98
1 file changed +9−3
readme.html+9−3
@@ -85,10 +85,16 @@ td{padding:7px 12px;border-bottom:1px solid var(--border);vertical-align:top}td.   window.addEventListener('resize',ph);   if(window.ResizeObserver)new ResizeObserver(ph).observe(document.body);   setTimeout(ph,250);setTimeout(ph,1000);ph();-  // curated key pages -> full-viewport image via the parent readme-lightbox (Colby, wiki #52);-  // the <a href> is the graceful fallback if the parent doesn't host the overlay.+  // curated key pages -> full-viewport image via the parent readme-lightbox (Colby, wiki #52).+  // Only intercept when embedded; standalone /readme/ (no host overlay) falls back to the <a href>.+  var embedded = window.parent && window.parent !== window;   [].slice.call(document.querySelectorAll('.kp')).forEach(function(a){-    a.addEventListener('click',function(e){e.preventDefault();parent.postMessage({type:'readme-lightbox',src:a.getAttribute('data-full')},'*');});+    a.addEventListener('click',function(e){+      if(!embedded)return; // let the anchor open the image in a new tab+      e.preventDefault();+      parent.postMessage({type:'readme-lightbox',src:a.getAttribute('data-full')},'*');+    });+    a.setAttribute('target','_blank');   }); })(); </script>