PluginProbe ʕ •ᴥ•ʔ
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 2.12.1
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v2.12.1
2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8 0.0.9 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.12.3 1.13.0 1.13.1 1.13.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.2 2.6.0
sureforms / admin / assets / js / notice-response.js
sureforms / admin / assets / js Last commit date
notice-response.js 3 months ago sureforms-pointer.js 3 months ago
notice-response.js
69 lines
1 /* global srfmNoticeResponse */
2 ( function () {
3 const notices = {
4 'srfm-getting-started-notice': {
5 primary: 'go_to_dashboard',
6 snooze: 'maybe_later',
7 dismiss: 'dismissed',
8 },
9 'srfm-plugin-review-notice': {
10 primary: 'rate_sureforms',
11 snooze: 'maybe_later',
12 dismiss: 'dismissed',
13 },
14 };
15
16 function getAction( el, noticeId ) {
17 const config = notices[ noticeId ];
18 if ( ! config ) {
19 return null;
20 }
21
22 if (
23 el.classList.contains( 'button-primary' ) ||
24 ( el.classList.contains( 'astra-notice-close' ) &&
25 el.getAttribute( 'target' ) === '_blank' )
26 ) {
27 return config.primary;
28 }
29 if ( el.hasAttribute( 'data-repeat-notice-after' ) ) {
30 return config.snooze;
31 }
32 if ( el.classList.contains( 'astra-notice-close' ) ) {
33 return config.dismiss;
34 }
35 return null;
36 }
37
38 function sendResponse( noticeId, button ) {
39 const body = new FormData();
40 body.append( 'action', 'srfm_notice_response' );
41 body.append( 'nonce', srfmNoticeResponse.nonce );
42 body.append( 'notice_id', noticeId );
43 body.append( 'button', button );
44
45 fetch( srfmNoticeResponse.ajaxurl, { method: 'POST', body } ).catch(
46 () => {}
47 );
48 }
49
50 Object.keys( notices ).forEach( function ( noticeId ) {
51 const container = document.getElementById( noticeId );
52 if ( ! container ) {
53 return;
54 }
55
56 container.addEventListener( 'click', function ( e ) {
57 const link = e.target.closest( 'a' );
58 if ( ! link ) {
59 return;
60 }
61
62 const action = getAction( link, noticeId );
63 if ( action ) {
64 sendResponse( noticeId, action );
65 }
66 } );
67 } );
68 }() );
69