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 / sureforms-pointer.js
sureforms / admin / assets / js Last commit date
notice-response.js 3 months ago sureforms-pointer.js 3 months ago
sureforms-pointer.js
91 lines
1 jQuery( document ).ready( function ( $ ) {
2 // Check with the server if the pointer should be shown
3 $.post(
4 sureformsPointerData.ajaxurl,
5 {
6 action: 'should_show_pointer',
7 pointer_nonce: sureformsPointerData.pointer_nonce,
8 },
9 function ( response ) {
10 if ( ! response || ! response.show ) {
11 return;
12 }
13
14 let $target = $( '#toplevel_page_sureforms_menu' );
15 if ( ! $target.length ) {
16 $target = $( '#menu-plugins' ); // fallback
17 }
18
19 const pointerContent =
20 '<h3>' +
21 response.title +
22 '</h3>' +
23 '<p>' +
24 response.content +
25 '</p>';
26
27 let pointerClosedBy = null; // 'cta' or 'dismiss' or null
28
29 $target
30 .pointer( {
31 content: pointerContent,
32 position: {
33 edge: 'left',
34 align: 'center',
35 },
36 // `_event` is unused but required positionally to access `t`.
37 buttons( _event, t ) {
38 const dismissBtn = $(
39 '<a class="close" href="#" style="margin-left:8px;"></a>'
40 )
41 .text( response.dismiss )
42 .on( 'click.pointer', function ( e ) {
43 e.preventDefault();
44 pointerClosedBy = 'dismiss';
45 t.element.pointer( 'close' );
46 $.post( sureformsPointerData.ajaxurl, {
47 action: 'sureforms_dismiss_pointer',
48 pointer_nonce:
49 sureformsPointerData.pointer_nonce,
50 } );
51 } );
52
53 const ctaBtn = $(
54 '<a class="button button-primary" href="' +
55 response.button_url +
56 '" style="margin-right:8px;">' +
57 response.button_text +
58 '</a>'
59 ).on( 'click.pointer', function () {
60 pointerClosedBy = 'cta';
61 t.element.pointer( 'close' );
62 $.post( sureformsPointerData.ajaxurl, {
63 action: 'sureforms_accept_cta',
64 pointer_nonce:
65 sureformsPointerData.pointer_nonce,
66 } );
67 } );
68
69 // Wrap both buttons in a div and return as a jQuery object
70 return $(
71 '<div style="display:flex;justify-content:space-between;align-items:center;width:100%"></div>'
72 )
73 .append( ctaBtn )
74 .append( dismissBtn );
75 },
76 close() {
77 if ( ! pointerClosedBy ) {
78 // Only run if closed by other means (not by our buttons)
79 $.post( sureformsPointerData.ajaxurl, {
80 action: 'sureforms_dismiss_pointer',
81 pointer_nonce:
82 sureformsPointerData.pointer_nonce,
83 } );
84 }
85 },
86 } )
87 .pointer( 'open' );
88 }
89 );
90 } );
91