1// Delegated event handlers that map DOM events to ActivityFeed instances. 2// This keeps event wiring out of the class implementation. 3import { closestFeedContainer } from './dom-helpers.js?v=9.3'; 4 5export function setupGlobalEventHandlers() { 6 // follow/unfollow clicks 7 document.addEventListener('click', (e) => { 8 const followBtn = e.target.closest('.activity-center-category-item'); 9 if (followBtn) { 10 const feedContainer = closestFeedContainer(followBtn); 11 if (!feedContainer) { 12 return; 13 } 14 const feedId = feedContainer.dataset.activityFeedId; 15 const instance = window.activityFeeds && window.activityFeeds.get(feedId); 16 if (instance) { 17 instance.handleFollowButtonClick(followBtn); 18 } 19 return; 20 } 21 22 // quick-add term buttons used in "Build your feed" 23 const quickAdd = e.target.closest('.quick-add-term'); 24 if (quickAdd) { 25 const feedContainer = closestFeedContainer(quickAdd); 26 if (!feedContainer) { 27 return; 28 } 29 const feedId = feedContainer.dataset.activityFeedId; 30 const instance = window.activityFeeds && window.activityFeeds.get(feedId); 31 if (instance) { 32 // ensure a popup exists for this instance (create it if missing) 33 let popup = instance.container.querySelector('.ac-subscribe-popup'); 34 if (!popup) { 35 try { 36 popup = instance.createSubscribePopup(); 37 } catch (err) { 38 console.warn( 39 `[ActivityFeed:${instance._id}] createSubscribePopup failed`, 40 err, 41 ); 42 popup = null; 43 } 44 } 45 if (popup) { 46 popup.classList.remove('important:hidden'); 47 } 48 } 49 return; 50 } 51 52 // subscribe popup triggers (data-open-subscribe) 53 const opensub = e.target.closest('[data-open-subscribe]'); 54 if (opensub) { 55 const feedContainer = closestFeedContainer(opensub); 56 if (!feedContainer) { 57 return; 58 } 59 const feedId = feedContainer.dataset.activityFeedId; 60 const instance = window.activityFeeds && window.activityFeeds.get(feedId); 61 if (instance) { 62 instance.createSubscribePopup(); 63 } 64 return; 65 } 66 }); 67}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.