@@ -13,6 +13,32 @@ let activeVideoSrc = "";
1313let activeVideoContext = null ;
1414let activeSelectedSeason = null ; // Track the currently selected season
1515
16+ /**
17+ * Opens media details and syncs route if available.
18+ * @param {Object } item - Media item.
19+ */
20+ function openDetailsWithRoute ( item ) {
21+ if ( typeof window !== 'undefined' && typeof window . openMediaDetails === 'function' ) {
22+ window . openMediaDetails ( item ) ;
23+ } else {
24+ openDetails ( item ) ;
25+ }
26+ }
27+
28+ /**
29+ * Opens actor details and syncs route if available.
30+ * @param {Object } actor - Actor item.
31+ * @param {Object } filmsData - Films data.
32+ * @param {Object } seriesData - Series data.
33+ */
34+ function openActorDetailsWithRoute ( actor , filmsData , seriesData ) {
35+ if ( typeof window !== 'undefined' && typeof window . openActorDetailsRoute === 'function' ) {
36+ window . openActorDetailsRoute ( actor , filmsData , seriesData ) ;
37+ } else {
38+ openActorDetails ( actor , filmsData , seriesData ) ;
39+ }
40+ }
41+
1642/**
1743 * Sets up the hero section with the given media item.
1844 * @param {Object } item - The media item to display in the hero section.
@@ -47,7 +73,7 @@ export function setupHero(item) {
4773
4874 // Set up play button click handler based on media type
4975 newBtn . onclick = ( ) => {
50- openDetails ( item ) ;
76+ openDetailsWithRoute ( item ) ;
5177 if ( isSerie && item . seasons ?. [ "1" ] ?. [ 0 ] ) {
5278 const ctx = {
5379 type : 'series' ,
@@ -72,7 +98,7 @@ export function setupHero(item) {
7298 if ( infoBtn ) {
7399 const newInfoBtn = infoBtn . cloneNode ( true ) ;
74100 infoBtn . parentNode . replaceChild ( newInfoBtn , infoBtn ) ;
75- newInfoBtn . onclick = ( ) => openDetails ( item ) ;
101+ newInfoBtn . onclick = ( ) => openDetailsWithRoute ( item ) ;
76102 }
77103}
78104
@@ -446,7 +472,7 @@ export function createMediaCard(item, extraClasses = "") {
446472 </div>
447473 </div>
448474 ` ;
449- card . onclick = ( ) => openDetails ( item ) ;
475+ card . onclick = ( ) => openDetailsWithRoute ( item ) ;
450476 return card ;
451477}
452478
@@ -791,7 +817,7 @@ export function renderActorsList(actorsData, filmsData = {}, seriesData = {}) {
791817 </div>
792818 ` ;
793819
794- card . onclick = ( ) => openActorDetails ( actor , filmsData , seriesData ) ;
820+ card . onclick = ( ) => openActorDetailsWithRoute ( actor , filmsData , seriesData ) ;
795821 grid . appendChild ( card ) ;
796822 } ) ;
797823
@@ -847,7 +873,7 @@ export function renderActorsListSearch(actorsData, filmsData = {}, seriesData =
847873 </div>
848874 ` ;
849875
850- card . onclick = ( ) => openActorDetails ( actor , filmsData , seriesData ) ;
876+ card . onclick = ( ) => openActorDetailsWithRoute ( actor , filmsData , seriesData ) ;
851877 grid . appendChild ( card ) ;
852878 } ) ;
853879
0 commit comments