1- import { markerIdForPOI } from "../map/components/poi-marker" ;
2- import { POITracker } from "../points" ;
1+ import type { POITracker } from "./POI-tracker" ;
32import type { POI } from "../types" ;
43import { debug , getElementOrThrow , info } from "../utils" ;
54import { AudioController } from "./audio-controller" ;
65
76/**
8- * Top-level coordinator for POI popup content .
7+ * Owns the popup UI for the active POI .
98 *
10- * Audio stack breakdown :
11- * - POIController shows and hides popup content for the active POI.
12- * - AudioController owns the custom player UI inside the popup.
13- * - AudioElement wraps the backing HTML audio node and handles media lifecycle.
9+ * Responsibilities :
10+ * - show and hide popup content for the active POI
11+ * - populate popup title and image state
12+ * - coordinate popup audio setup and teardown
1413 *
1514 * Provenance:
1615 * - the current custom POI audio player integration was AI-generated
1716 * - review behavior carefully when changing popup/audio interactions
1817 */
19- export class POIController {
20- constructor ( params : { poiTracker : POITracker } ) {
18+ export class POIPopupController {
19+ constructor ( { poiTracker } : { poiTracker : POITracker } ) {
2120 getElementOrThrow ( { id : "poi-popup-close" } ) . addEventListener (
2221 "click" ,
2322 ( ) => {
2423 // when the user hits close, they're deselecting the active
25- params . poiTracker . deselectActive ( ) ;
24+ poiTracker . deselectActive ( ) ;
2625 } ,
2726 ) ;
2827
@@ -47,9 +46,9 @@ export class POIController {
4746 } ;
4847 this . audioController = new AudioController ( ) ;
4948
50- params . poiTracker . addListener ( ( activePOI ) => {
49+ poiTracker . addListener ( ( activePOI ) => {
5150 debug (
52- `[POIController ] listener for poiTrackerInstance fired: ${ activePOI } ` ,
51+ `[POIPopupController ] listener for poiTrackerInstance fired: ${ activePOI } ` ,
5352 ) ;
5453 if ( activePOI ) {
5554 this . display ( activePOI ) ;
@@ -59,29 +58,21 @@ export class POIController {
5958 } ) ;
6059 }
6160
62- /**
63- * called whenever POITracker sees a switch
64- */
61+ /** Called when POITracker selects or switches to a POI. */
6562 display ( poi : POI ) {
6663 if ( this . active ?. poi && poi . id !== this . active . poi ?. id ) {
6764 info (
68- `[POIController ] switching from ${ this . active . poi ?. id } to ${ poi . id } ` ,
65+ `[POIPopupController ] switching from ${ this . active . poi ?. id } to ${ poi . id } ` ,
6966 ) ;
7067
7168 this . audioController . teardown ( ) ;
7269 }
7370
7471 this . active = { poi : poi } ;
7572
76- // --------- configure marker
77-
78- const poiMarker = getElementOrThrow ( { id : markerIdForPOI ( poi ) } ) ;
79- poiMarker . style . opacity = "0.7" ;
80-
81- // --------- configure popup
82-
8373 this . elements . title . textContent = poi . title ;
8474
75+ // TODO: non optional
8576 if ( poi . imageName ) {
8677 this . elements . image . classList . add ( "poi-popup-image-loading" ) ;
8778 this . elements . image . removeAttribute ( "src" ) ;
@@ -106,7 +97,6 @@ export class POIController {
10697 }
10798
10899 close ( ) {
109- // TODO: hidden check here?
110100 this . elements . container . classList . add ( "hidden" ) ;
111101 this . hidden = true ;
112102
0 commit comments