@@ -20,8 +20,8 @@ const CTA_TITLES = [
2020] ;
2121
2222function initializeAllCTAs ( ) {
23- // Find CTA container
24- document . querySelectorAll ( '.cta-container:not([data-cta-initialized])' ) . forEach ( container => {
23+ // Find CTA container, looking for both the old class and potential new classes
24+ document . querySelectorAll ( '.cta-container:not([data-cta-initialized]), .cta-section:not([data-cta-initialized]) ' ) . forEach ( container => {
2525 // Skip if already initialized
2626 if ( container . hasAttribute ( 'data-cta-initialized' ) ) return ;
2727
@@ -30,10 +30,18 @@ function initializeAllCTAs() {
3030 // Mark as initialized
3131 container . setAttribute ( 'data-cta-initialized' , 'true' ) ;
3232
33- const titleElement = container . querySelector ( '#rotating-cta-title' ) ;
33+ // Try both ID and class selectors for title element
34+ const titleElement = container . querySelector ( '#rotating-cta-title, .cta-title' ) ;
3435 const subtitle = container . querySelector ( '.cta-pun-complaint' ) ;
3536
36- if ( ! titleElement || ! subtitle ) return ;
37+ if ( ! titleElement || ! subtitle ) {
38+ console . log ( "[Initialize] CTA - Missing elements" , {
39+ titleElement : ! ! titleElement ,
40+ subtitle : ! ! subtitle ,
41+ container : container . className
42+ } ) ;
43+ return ;
44+ }
3745
3846 let currentIndex = 0 ;
3947 let clickCount = 0 ;
@@ -43,6 +51,12 @@ function initializeAllCTAs() {
4351 return CTA_TITLES [ currentIndex ] ;
4452 }
4553
54+ // Set initial title if not already set
55+ if ( ! titleElement . dataset . initialized ) {
56+ titleElement . textContent = CTA_TITLES [ currentIndex ] ;
57+ titleElement . dataset . initialized = "true" ;
58+ }
59+
4660 subtitle . addEventListener ( 'click' , ( ) => {
4761 titleElement . textContent = getNextTitle ( ) ;
4862 clickCount ++ ;
@@ -71,4 +85,4 @@ if (document.readyState === "loading") {
7185 document . addEventListener ( "DOMContentLoaded" , initializeAllCTAs ) ;
7286} else {
7387 initializeAllCTAs ( ) ;
74- }
88+ }
0 commit comments