PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.0.1
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.0.1
3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 All 194 releases
convertkit / resources / frontend / js / broadcasts.js

broadcasts.js in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 2.0.1, at resources/frontend/js/broadcasts.js

101 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Frontend functionality for subscribers and tags.
3 *
4 * @since 1.9.6
5 *
6 * @package ConvertKit
7 * @author ConvertKit
8 */
9
10 /**
11 * Register events
12 */
13 jQuery( document ).ready(
14 function( $ ) {
15
16 $( document ).on(
17 'click',
18 'ul.convertkit-broadcasts-pagination a',
19 function( e ) {
20
21 e.preventDefault();
22
23 // Get block container and build object of data-* attributes.
24 var blockContainer = $( this ).closest( 'div.convertkit-broadcasts' ),
25 atts = {
26 date_format: $( blockContainer ).data( 'date-format' ),
27 limit: $( blockContainer ).data( 'limit' ),
28 paginate: $( blockContainer ).data( 'paginate' ),
29 paginate_label_prev: $( blockContainer ).data( 'paginate-label-prev' ),
30 paginate_label_next: $( blockContainer ).data( 'paginate-label-next' ),
31 link_color: $( blockContainer ).data( 'link-color' ),
32
33 page: $( this ).data( 'page' ), // Page is supplied as a data- attribute on the link clicked, not the container.
34 nonce: $( this ).data( 'nonce' ) // Nonce is supplied as a data- attribute on the link clicked, not the container.
35 };
36
37 convertKitBroadcastsRender( blockContainer, atts );
38
39 }
40 );
41
42 }
43 );
44
45 /**
46 * Sends an AJAX request to request HTML based on the supplied block attributes,
47 * when pagination is used on a Broadcast block.
48 *
49 * @since 1.9.7.6
50 *
51 * @param object blockContainer DOM object of the block to refresh the HTML in.
52 * @param object atts Block attributes
53 */
54 function convertKitBroadcastsRender( blockContainer, atts ) {
55
56 ( function( $ ) {
57
58 // Append action.
59 atts.action = convertkit_broadcasts.action;
60
61 if ( convertkit_broadcasts.debug ) {
62 console.log( 'convertKitBroadcastsRender()' );
63 console.log( atts );
64 }
65
66 // Show loading indicator.
67 $( blockContainer ).addClass( 'convertkit-broadcasts-loading' );
68
69 $.ajax(
70 {
71 url: convertkit_broadcasts.ajax_url,
72 type: 'POST',
73 async: true,
74 data: atts,
75 success: function( result ) {
76 if ( convertkit_broadcasts.debug ) {
77 console.log( result );
78 }
79
80 // Remove loading indicator.
81 $( blockContainer ).removeClass( 'convertkit-broadcasts-loading' );
82
83 // Replace block container's HTML with response data.
84 $( blockContainer ).html( result.data );
85 }
86 }
87 ).fail(
88 function (response) {
89 // Remove loading indicator.
90 $( blockContainer ).removeClass( 'convertkit-broadcasts-loading' );
91
92 if ( convertkit.debug ) {
93 console.log( response );
94 }
95 }
96 );
97
98 } )( jQuery );
99
100 }
101