PageSourceSearch

https://sunandaglobal.com/services/wp-content/plugins/contact-form-7-extras/assets/js/controls.js?ver=0.9.0

js sunandaglobal.com collected 2026-10-07 04:38:54 UTC 4,078 bytes, 147 lines download raw bytes

1/* eslint camelcase: warn */
2
3( function() {
4	var formEventCallback;
5
6	var formEventCallbacks = {
7		wpcf7mailsent: function( form ) {
8			var formConfig;
9
10			if ( form.contactFormId && formEventEnabled( form.contactFormId, 'track-ga' ) ) {
11				formConfig = getFormConfig( form.contactFormId );
12				trackAnalyticsEvent( 'Contact Form', 'Sent', formConfig.title );
13			}
14		},
15		wpcf7mailfailed: function( form ) {
16			var formConfig;
17
18			if ( form.contactFormId && formEventEnabled( form.contactFormId, 'track-ga' ) ) {
19				formConfig = getFormConfig( form.contactFormId );
20				trackAnalyticsEvent( 'Contact Form', 'Error', formConfig.title );
21			}
22		},
23		wpcf7spam: function( form ) {
24			var formConfig;
25
26			if ( form.contactFormId && formEventEnabled( form.contactFormId, 'track-ga' ) ) {
27				formConfig = getFormConfig( form.contactFormId );
28				trackAnalyticsEvent( 'Contact Form', 'Spam', formConfig.title );
29			}
30		},
31		wpcf7submit: function( form ) {
32			var formConfig;
33
34			if ( form.contactFormId && formEventEnabled( form.contactFormId, 'track-ga' ) ) {
35				formConfig = getFormConfig( form.contactFormId );
36				trackAnalyticsEvent( 'Contact Form', 'Submit', formConfig.title );
37			}
38
39			if ( form.contactFormId && 'mail_sent' === form.status && formEventEnabled( form.contactFormId, 'redirect-success' ) ) {
40				formConfig = getFormConfig( form.contactFormId );
41
42				if ( formConfig.redirect_url ) {
43					window.location = formConfig.redirect_url;
44				}
45			}
46		}
47	};
48
49	var jQueryEvents = {
50		'wpcf7:mailsent': function( event, form ) {
51			formCallbacks.wpcf7mailsent( form );
52		},
53		'wpcf7:mailfailed': function( event, form ) {
54			formCallbacks.wpcf7mailfailed( form );
55		},
56		'wpcf7:spam': function( event, form ) {
57			formCallbacks.wpcf7spam( form );
58		},
59		'wpcf7:submit': function( event, form ) {
60			formCallbacks.wpcf7submit( form );
61		}
62	};
63
64	function trackAnalyticsEvent( eventCategory, eventAction, eventTitle ) {
65
66		// Helper method required for the event to be registered by gtag.js.
67		var dataLayerPush = function() {
68			if ( 'object' === typeof window.dataLayer && 'function' === typeof window.dataLayer.push ) {
69				window.dataLayer.push( arguments );
70			}
71		};
72
73		// GA via Google Tag Manager or Global Site Tag (gtag.js).
74		dataLayerPush(
75			'event',
76			eventAction,
77			{
78				'event_category': eventCategory,
79				'event_label': eventTitle
80			}
81		);
82
83		// Universal Google Analytics is available.
84		if ( 'function' === typeof ga ) {
85			ga( 'send', 'event', eventCategory, eventAction, eventTitle );
86		}
87
88		// Classic Google Analytics is available.
89		if ( 'object' === typeof _gaq && 'function' === typeof _gaq.push ) {
90			_gaq.push( [ '_trackEvent', eventCategory, eventAction, eventTitle ] );
91		}
92
93		// Matomo (formerly Piwik) is available.
94		if ( 'undefined' !== typeof _paq && 'function' === typeof _paq.push ) {
95			_paq.push( [ 'trackEvent', eventCategory, eventAction, eventTitle ] );
96		}
97
98		// Facebook Pixel contact event.
99		if ( 'function' === typeof fbq ) {
100			fbq( 'track', 'Contact', {
101				content_category: eventAction,
102				content_name: eventTitle
103			} );
104		}
105	};
106
107	function formEventEnabled( formId, eventName ) {
108		formId = parseInt( formId );
109
110		if ( ! formId || ! window.cf7_extras.events[ eventName ] ) {
111			return false;
112		}
113
114		if ( -1 !== window.cf7_extras.events[ eventName ].indexOf( formId ) ) {
115			return true;
116		}
117
118		return false;
119	};
120
121	function getFormConfig( formId ) {
122		formId = parseInt( formId );
123
124		if ( window.cf7_extras.forms && window.cf7_extras.forms[ formId ] ) {
125			return window.cf7_extras.forms[ formId ];
126		}
127
128		return false;
129	};
130
131	// We need the event config for each form to do anything.
132	if ( ! window.cf7_extras ) {
133		return;
134	}
135
136	// Register the new JS events in CF7 version 5.2 and above.
137	if ( 'function' === typeof document.addEventListener ) {
138		for ( formEventCallback in formEventCallbacks ) {
139			document.addEventListener( formEventCallback, function( event ) {
140				if ( event.type in formEventCallbacks ) {
141					formEventCallbacks[ event.type ].call( event, event.detail );
142				}
143			} );
144		}
145	}
146
147}() );

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.