PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.6.60
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.6.60
1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 All 211 releases
charitable / assets / js / charitable-admin-benefactors.js

charitable-admin-benefactors.js in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.6.60, at assets/js/charitable-admin-benefactors.js

91 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function($){
2 var add_campaign_benefactor = function( $el ) {
3 var idx = parseInt( $el.attr( 'data-campaign-benefactor-add' ) ),
4 $block = $( '#campaign_benefactor__' + idx ),
5 extension = $el.data( 'extension' );
6
7 // The block is already there, so show it.
8 $block.show();
9
10 idx = idx + 1;
11
12 // Fetch the next block with AJAX.
13 $.ajax({
14 type: "POST",
15 data: {
16 action: 'charitable_add_benefactor',
17 idx: idx,
18 extension: extension
19 },
20 url: ajaxurl,
21 xhrFields: {
22 withCredentials: true
23 },
24 success: function( response ) {
25 $(response).insertBefore( $el.parent() );
26
27 CHARITABLE_ADMIN.SetupDatepicker( $( '#campaign_benefactor__' + idx + ' .charitable-datepicker' ) );
28 }
29 }).fail(function (data) {
30 if ( window.console && window.console.log ) {
31 console.log( data );
32 }
33 });
34
35 // Update the data attribute so that we will show the next block next time.
36 $el.attr( 'data-campaign-benefactor-add', idx );
37
38 return false;
39 };
40
41 var cancel_new_campaign_benefactor = function( $el ) {
42 $el.parent().remove();
43
44 return false;
45 };
46
47 var delete_campaign_benefactor = function( $el ) {
48 var $block = $el.parents( '.charitable-benefactor' ),
49 data = {
50 action : 'charitable_delete_benefactor',
51 benefactor_id : $el.data( 'campaign-benefactor-delete' ),
52 nonce : $el.data( 'nonce' )
53 };
54
55 $.ajax({
56 type: "POST",
57 data: data,
58 dataType: "json",
59 url: ajaxurl,
60 xhrFields: {
61 withCredentials: true
62 },
63 success: function (response) {
64 if ( response.deleted ) {
65 $block.remove();
66 }
67 }
68 }).fail(function (data) {
69 if ( window.console && window.console.log ) {
70 console.log( 'failure' );
71 console.log( data );
72 }
73 });
74
75 return false;
76 };
77
78 $(document).ready( function() {
79 $('body').on( 'click', '[data-campaign-benefactor-delete]', function() {
80 return delete_campaign_benefactor( $(this) );
81 });
82
83 $('[data-campaign-benefactor-add]').on( 'click', function() {
84 return add_campaign_benefactor( $(this) );
85 });
86
87 $('body').on( 'click', '.charitable-benefactor-form-cancel', function() {
88 return cancel_new_campaign_benefactor( $(this) );
89 });
90 });
91 })( jQuery );