PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.0.1
GiveWP – Donation Plugin and Fundraising Platform v2.0.1
4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / assets / js / admin / admin-forms.js
give / assets / js / admin Last commit date
tinymce 9 years ago admin-forms.js 8 years ago admin-forms.min.js 8 years ago admin-scripts.js 8 years ago admin-scripts.min.js 8 years ago admin-settings.js 8 years ago admin-settings.min.js 8 years ago admin-shortcodes.js 9 years ago admin-shortcodes.min.js 9 years ago admin-widgets.js 8 years ago admin-widgets.min.js 8 years ago
admin-forms.js
320 lines
1 /*!
2 * Give Admin Forms JS
3 *
4 * @description: The Give Admin Forms scripts. Only enqueued on the give_forms CPT; used to validate fields, show/hide, and other functions
5 * @package: Give
6 * @subpackage: Assets/JS
7 * @copyright: Copyright (c) 2016, WordImpress
8 * @license: http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 */
10
11 jQuery.noConflict();
12 (function ($) {
13 /**
14 * Default Radio Button
15 *
16 * @description: Allow only one radio button to be checked at a time
17 * @since: 1.0
18 */
19 var handle_default_radio = function () {
20 $('body').on( 'change', '.give-give_default_radio_inline', function(){
21 // Unset pre selected default level.
22 $('.give-give_default_radio_inline').prop( 'checked', false );
23
24 // Set level as default.
25 $(this).prop( 'checked', true );
26 });
27
28 // Note: some cases is covered in admin-scripts.js.
29 // For ref: handle_metabox_repeater_field_row_count, handle_metabox_repeater_field_row_remove
30 };
31
32
33 /**
34 * Toggle Conditional Form Fields
35 *
36 * @since: 1.0
37 */
38 var toggle_conditional_form_fields = function () {
39
40 //Price Option
41 var price_option = $('._give_price_option_field input:radio');
42
43 price_option.on('change', function () {
44
45 var price_option_val = $('._give_price_option_field input:radio:checked').val();
46 if (price_option_val === 'set') {
47 //set price shows
48 $('._give_set_price_field').show();
49 $('#_give_donation_levels_field').hide(); // Hide multi-val stuffs.
50 $('._give_display_style_field').hide(); // Hide display style setting.
51
52
53 } else {
54 //multi-value shows
55 $('._give_set_price_field').hide();
56 $('#_give_donation_levels_field').show(); // Show set stuffs.
57 $('._give_display_style_field').show(); // Show display style setting.
58 }
59 }).change();
60
61
62 //Content Option
63 var display_content = $('._give_display_content_field input:radio');
64 display_content.on('change', function () {
65 // Get checked radio button value.
66 var display_content_val = $('._give_display_content_field input:radio:checked').val();
67
68 if ( display_content_val === 'enabled') {
69 $('._give_content_placement_field').show();
70 $('._give_form_content_field').show();
71 } else {
72 $('._give_content_placement_field').hide();
73 $('._give_form_content_field').hide();
74 }
75 }).change();
76
77 //Terms Option
78 var terms_option = $('._give_terms_option_field input:radio');
79 terms_option.on('change', function () {
80 // Get checked radio button value.
81 var terms_option_val = $('._give_terms_option_field input:radio:checked').val();
82
83 if ( terms_option_val === 'enabled' ) {
84 $('._give_agree_label_field').show();
85 $('._give_agree_text_field').show();
86 } else {
87 $('._give_agree_label_field').hide();
88 $('._give_agree_text_field').hide();
89 }
90 }).change();
91
92 //Payment Display
93 var payment_display_option = $('._give_payment_display_field input:radio');
94 payment_display_option.on('change', function () {
95 var payment_display_option_val = $('._give_payment_display_field input:radio:checked').val();
96
97 if (payment_display_option_val === 'onpage') {
98 $('._give_reveal_label_field').hide();
99 } else {
100 $('._give_reveal_label_field').show();
101 }
102 }).change();
103
104 //Custom Amount
105 var custom_amount_option = $('._give_custom_amount_field input:radio');
106 custom_amount_option.on('change', function () {
107 var custom_amount_option_val = $('._give_custom_amount_field input:radio:checked').val();
108 if (custom_amount_option_val === 'disabled') {
109 $('._give_custom_amount_minimum_field').hide();
110 $('._give_custom_amount_text_field').hide();
111 } else {
112 $('._give_custom_amount_minimum_field').show();
113 $('._give_custom_amount_text_field').show();
114 }
115 }).change();
116
117 //Goals
118 var goal_option = $('._give_goal_option_field');
119 //Close Form when Goal Achieved
120 var close_form_when_goal_achieved_option = $('._give_close_form_when_goal_achieved_field input:radio');
121
122 close_form_when_goal_achieved_option.on('change', function () {
123 var close_form_when_goal_achieved_option_val = $('._give_close_form_when_goal_achieved_field input:radio:checked').val();
124 if (close_form_when_goal_achieved_option_val === 'disabled') {
125 $('._give_form_goal_achieved_message_field').hide();
126 } else {
127 $('._give_form_goal_achieved_message_field').show();
128 }
129 }).change();
130
131 goal_option.on('change', function () {
132 var goal_option = $('._give_goal_option_field input:radio:checked').val();
133 if (goal_option === 'disabled') {
134
135 $('._give_set_goal_field').hide();
136 $('._give_goal_format_field').hide();
137 $('._give_goal_color_field').hide();
138 $('._give_close_form_when_goal_achieved_field').hide();
139 $('._give_form_goal_achieved_message_field').hide();
140 $('._give_number_of_donation_goal_field').hide();
141 } else {
142 $('._give_set_goal_field').show();
143 $('._give_goal_format_field').show();
144 $('._give_goal_color_field').show();
145 $('._give_close_form_when_goal_achieved_field').show();
146
147 var close_form_when_goal_achieved_option_val = $('._give_close_form_when_goal_achieved_field input:radio:checked').val();
148
149 if (close_form_when_goal_achieved_option_val === 'enabled') {
150 $('._give_form_goal_achieved_message_field').show();
151 }
152
153 }
154 }).change();
155
156 var goal_format = $('._give_goal_format_field input:radio');
157 goal_format.on('change', function() {
158 var goal_format_val = $('._give_goal_format_field input:radio:checked').val();
159 var goal_option_val = $('._give_goal_option_field input:radio:checked').val();
160
161 if( 'donation' === goal_format_val ) {
162 $('._give_set_goal_field').hide();
163 $('._give_number_of_donation_goal_field').show();
164 } else {
165 ( 'disabled' === goal_option_val ) ? $('._give_set_goal_field').hide() : $('._give_set_goal_field').show();
166 $('._give_number_of_donation_goal_field').hide();
167 }
168 }).change();
169
170 //Offline Donations
171 var offline_customization_option = $('._give_customize_offline_donations_field input:radio');
172 offline_customization_option.on('change', function () {
173 var offline_customization_option_val = $('._give_customize_offline_donations_field input:radio:checked').val();
174 if ( 'enabled' === offline_customization_option_val ) {
175 $('._give_offline_checkout_notes_field').show();
176 $('._give_offline_donation_enable_billing_fields_single_field').show();
177 $('._give_offline_donation_subject_field').show();
178 $('._give_offline_donation_email_field').show();
179 } else {
180 $('._give_offline_checkout_notes_field').hide();
181 $('._give_offline_donation_enable_billing_fields_single_field').hide();
182 $('._give_offline_donation_subject_field').hide();
183 $('._give_offline_donation_email_field').hide();
184 }
185 }).change();
186
187 //Email options.
188 var email_options = $('._give_email_options_field input:radio');
189 email_options.on('change', function () {
190 // Get checked radio button value.
191 var email_options_val = $('._give_email_options_field input:radio:checked').val();
192
193 if ( email_options_val === 'enabled') {
194 $('#email_notification_options .give-field-wrap:not(._give_email_options_field)').show();
195 } else {
196 $('#email_notification_options .give-field-wrap:not(._give_email_options_field)').hide();
197 }
198 }).change();
199 };
200
201 //Handle Repeatable Row ID
202 var handle_repeatable_row_ID = function () {
203
204 //Ensure for new posts that the repeater is filled
205 if ($('.give-level-id').text() === '') {
206 var row_group = $('.cmb-repeatable-grouping');
207 //loop through all repeatable rows and set vals
208 row_group.each(function (index, object) {
209
210 var row_id = $(object).data('iterator') + 1;
211
212 $(object).find('.give-level-id').text(row_id);
213 $(object).find('.give-level-id-input').val(row_id);
214
215 });
216 }
217
218 $('body').on('cmb2_add_row', function (event, row) {
219 set_row_ids(row);
220 });
221 $('body').on('cmb2_shift_rows_complete', function (event, self) {
222
223 var row_group = $('.cmb-repeatable-grouping');
224 //loop through all repeatable rows and set vals
225 row_group.each(function (index, object) {
226
227 var row_id = $(object).find('input.give-level-id-input').val();
228
229 $(object).find('.give-level-id').text(row_id);
230
231 });
232
233 });
234
235
236 /**
237 * Set Row IDs
238 *
239 * @description: Sets values in the Multi-level donation repeatable field
240 * @param row
241 */
242 function set_row_ids(row) {
243
244 var row_count = count_repeatable_rows();
245
246 //Add row ID value to hidden field
247 $(row).find('input.give-level-id-input').val(row_count);
248 //Add row ID to displayed ID
249 $(row).find('.give-level-id').text(row_count);
250
251 }
252
253 /**
254 * Loops through Multi-level repeater rows
255 *
256 * @description: First counts the rows then it compares the row count with the largest iterator count.
257 *
258 * @returns {number}
259 */
260 function count_repeatable_rows() {
261 var row_counter = 0;
262 var row_largest_number = 0;
263 var row_number = 0;
264
265 //Loop through repeatable rows to see what highest ID is currently
266 $('#_give_donation_levels_repeat > .cmb-repeatable-grouping').each(function (index, value) {
267
268 row_number = $(this).find('input.give-level-id-input').val();
269
270 if (row_number > row_largest_number) {
271 row_largest_number = row_number;
272 }
273
274 row_counter++;
275
276 });
277
278 if (typeof row_largest_number !== 'undefined' && row_largest_number >= row_counter) {
279 return (parseInt(row_largest_number) + 1); //ensure no duplicate rows returned
280 } else {
281 return row_counter;
282 }
283
284 }
285
286
287 };
288
289 /**
290 * Misc Cleanup
291 *
292 * @description: Clean up and tweaks
293 * @since: 1.0
294 */
295 function misc_cleanup() {
296
297 //No Value = Placeholders: determine if value is 0.00 and remove if so in favor of placeholders
298 $('.cmb2-text-money').each(function (index, object) {
299 var this_val = parseInt($(object).val());
300 if (!this_val) {
301 $(object).removeAttr('value');
302 }
303 });
304
305 }
306
307
308 //On DOM Ready
309 $(function () {
310
311 handle_default_radio();
312 toggle_conditional_form_fields();
313 handle_repeatable_row_ID();
314 misc_cleanup();
315
316 });
317
318
319 })(jQuery);
320