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 */ 13jQuery( 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 let blockContainer = $( this ).closest( 'div.convertkit-broadcasts' ); 25 let atts = { 26 display_date: $( blockContainer ).data( 'display-date' ), 27 date_format: $( blockContainer ).data( 'date-format' ), 28 display_image: $( blockContainer ).data( 'display-image' ), 29 display_description: $( blockContainer ).data( 'display-description' ), 30 display_read_more: $( blockContainer ).data( 'display-read-more' ), 31 read_more_label: $( blockContainer ).data( 'read-more-label' ), 32 limit: $( blockContainer ).data( 'limit' ), 33 paginate: $( blockContainer ).data( 'paginate' ), 34 paginate_label_prev: $( blockContainer ).data( 'paginate-label-prev' ), 35 paginate_label_next: $( blockContainer ).data( 'paginate-label-next' ), 36 link_color: $( blockContainer ).data( 'link-color' ), 37 page: $( this ).data( 'page' ), // Page is supplied as a data- attribute on the link clicked, not the container. 38 nonce: $( this ).data( 'nonce' ) // Nonce is supplied as a data- attribute on the link clicked, not the container. 39 }; 40 41 convertKitBroadcastsRender( blockContainer, atts ); 42 43 } 44 ); 45 46 } 47); 48 49/** 50 * Sends an AJAX request to request HTML based on the supplied block attributes, 51 * when pagination is used on a Broadcast block. 52 * 53 * @since 1.9.7.6 54 * 55 * @param object blockContainer DOM object of the block to refresh the HTML in. 56 * @param object atts Block attributes 57 */ 58function convertKitBroadcastsRender( blockContainer, atts ) { 59 60 ( function ( $ ) { 61 62 // Append action. 63 atts.action = convertkit_broadcasts.action; 64 65 if ( convertkit_broadcasts.debug ) { 66 console.log( 'convertKitBroadcastsRender()' ); 67 console.log( atts ); 68 } 69 70 // Show loading indicator. 71 $( blockContainer ).addClass( 'convertkit-broadcasts-loading' ); 72 73 $.ajax( 74 { 75 url: convertkit_broadcasts.ajax_url, 76 type: 'POST', 77 async: true, 78 data: atts, 79 success: function ( result ) { 80 if ( convertkit_broadcasts.debug ) { 81 console.log( result ); 82 } 83 84 // Remove loading indicator. 85 $( blockContainer ).removeClass( 'convertkit-broadcasts-loading' ); 86 87 // Replace block container's HTML with response data. 88 $( blockContainer ).html( result.data ); 89 } 90 } 91 ).fail( 92 function (response) { 93 // Remove loading indicator. 94 $( blockContainer ).removeClass( 'convertkit-broadcasts-loading' ); 95 96 if ( convertkit.debug ) { 97 console.log( response ); 98 } 99 } 100 ); 101 102 } )( jQuery ); 103 104}
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.