@@ -20,8 +20,8 @@ const CTA_TITLES = [
20
20
] ;
21
21
22
22
function 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 => {
25
25
// Skip if already initialized
26
26
if ( container . hasAttribute ( 'data-cta-initialized' ) ) return ;
27
27
@@ -30,10 +30,18 @@ function initializeAllCTAs() {
30
30
// Mark as initialized
31
31
container . setAttribute ( 'data-cta-initialized' , 'true' ) ;
32
32
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' ) ;
34
35
const subtitle = container . querySelector ( '.cta-pun-complaint' ) ;
35
36
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
+ }
37
45
38
46
let currentIndex = 0 ;
39
47
let clickCount = 0 ;
@@ -43,6 +51,12 @@ function initializeAllCTAs() {
43
51
return CTA_TITLES [ currentIndex ] ;
44
52
}
45
53
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
+
46
60
subtitle . addEventListener ( 'click' , ( ) => {
47
61
titleElement . textContent = getNextTitle ( ) ;
48
62
clickCount ++ ;
@@ -71,4 +85,4 @@ if (document.readyState === "loading") {
71
85
document . addEventListener ( "DOMContentLoaded" , initializeAllCTAs ) ;
72
86
} else {
73
87
initializeAllCTAs ( ) ;
74
- }
88
+ }
0 commit comments