PageSourceSearch

https://nomad.tours/nomadcms/plugins/wp-crowdfunding/assets/js/dist/crowdfunding-front.js?ver=2.1.11

js nomad.tours collected 2026-10-02 14:01:19 UTC 22,428 bytes, 602 lines download raw bytes

1// Crowdfunding Scripts
2
3jQuery(document).ready(function ($) {
4
5    var count = 0;
6    var numItems = $('.wpneo-block').length;
7    if (numItems != 0) { count = numItems; }
8    $.fn.createNewForm = function (count) {
9        return this.each(function () {
10            $(this).find('input,textarea,select').each(function () {
11                var $that = $(this);
12                $that.attr('name', this.name.replace(/\d/, count));
13                $that.val('');
14            });
15        });
16    };
17    $('.add-new').on('click', function (e) {
18        var $form = $('.wpneo-block').last(),
19            $cloned = $form.clone();
20        $cloned.createNewForm(count);
21        $('#wpneo-clone .add-new').before($($cloned));
22        count = count + 1;
23    });
24    $(document).on('click', '.remove-button', function (events) {
25        if ($('.wpneo-block').length > 1) {
26            $(this).parent('.wpneo-block').remove();
27        }
28    });
29    $('#wpneo_form_start_date, #wpneo_form_end_date, .update-datepicker').datepicker({
30        dateFormat: 'dd-mm-yy'
31    });
32
33    $('.wpneo_donate_button').on('click', function (e) {
34        const data = $('.wpneo_donate_amount_field').val();
35        if (!data) {
36            e.preventDefault();
37            $('.wpneo-tooltip-empty').css({ 'visibility': 'visible' });
38        } else {
39            $('.wpneo-tooltip-empty').css({ 'visibility': 'hidden' });
40        }
41    });
42
43    // Pie Chart
44    $('.crowdfound-pie-chart').easyPieChart({
45        barColor: 'var(--wpcf-primary-color)',
46        trackColor: '#f5f5f5',
47        scaleColor: false,
48        lineWidth: 5,
49    });
50
51    $('.datepickers_1').datepicker({
52        dateFormat: 'yy-mm-dd'
53    });
54    $('.datepickers_2').datepicker({
55        dateFormat: 'yy-mm-dd'
56    });
57
58    // Insert Campaign Post Data
59    $('#wpneofrontenddata').submit(submit_frontend);
60    function submit_frontend() {
61        tinyMCE.triggerSave();
62        var front_end_data = $(this).serialize();
63        $.ajax({
64            type: "POST",
65            url: wpcf_ajax_object.ajax_url,
66            data: front_end_data,
67            success: function (data) {
68                var parseData = JSON.parse(data);
69
70                if (!parseData.success) {
71                    //Reset reCaptcha if failed
72                    if ((typeof grecaptcha !== 'undefined') && ($('.g-recaptcha').length !== 0)) {
73                        grecaptcha.reset();
74                    }
75                }
76                if (wpcf_modal(data)) { }
77            },
78            error: function (jqXHR, textStatus, errorThrown) {
79                wpcf_modal({ 'success': 0, 'message': 'Error sending data' })
80            }
81        });
82        return false;
83    }
84
85    $(document).on('click', '.wpcf-print-button', function (e) {
86        window.print();
87    });
88
89    // Common Modal Function
90    function wpcf_modal(data, print = false) {
91        var data = JSON.parse(data);
92        var html = '<div class="wpneo-modal-wrapper"> ' +
93            '<div class="wpneo-modal-content"> ' +
94            '<div class="wpneo-modal-wrapper-head">' +
95            '<span id="wpcf_modal_title">Message</span><a href="javascript:;" class="wpneo-modal-close">&times;</a>';
96        if (print) {
97            html += '</div><span class="wpcf-print-button button wpneo-edit-btn">print</span>';
98        }
99        html += '<div class="wpneo-modal-content-inner"><div id="wpcf_modal_message"></div></div></div></div>';
100        if ($('.wpneo-modal-wrapper').length == 0) {
101            $('body').append(html);
102            if (data.redirect) {
103                if ($('#wpneo_crowdfunding_redirect_url').length == 0) {
104                    $('body').append('<input type="hidden" id="wpneo_crowdfunding_redirect_url" value="' + data.redirect + '" />');
105                }
106            }
107        }
108        if (data.success == 1) {
109            if (data.message) {
110                $('.wpneo-modal-wrapper #wpcf_modal_message').html(data.message);
111            }
112            if (data.title) {
113                $('.wpneo-modal-wrapper #wpcf_modal_title').html(data.title);
114            }
115            $('.wpneo-modal-wrapper').css({ 'display': 'block' });
116            if ($('#wpneofrontenddata').length > 0) {
117                $("#wpneofrontenddata")[0].reset();
118            }
119            return true;
120        } else {
121            $('.wpneo-modal-wrapper #wpcf_modal_message').html(data.message);
122            $('.wpneo-modal-wrapper').css({ 'display': 'block' });
123            return false;
124        }
125    }
126    window.wpcf_modal = wpcf_modal; //make global function
127
128    function wpcf_image_gallery_upload(button_class) {
129
130        var file_frame; // variable for the wp.media file_frame
131
132        $('body').on('click', button_class, function (event) {
133            event.preventDefault();
134            var gallery_image_ids = $(".gallery-image-ids");
135            var gallery_image_id_show = $(".gallery-image-id-show");
136            if (file_frame) {
137                file_frame.open();
138                return;
139            }
140            file_frame = wp.media.frames.file_frame = wp.media({
141                title: $(this).data('uploader_title'),
142                button: {
143                    text: $(this).data('uploader_button_text'),
144                },
145                multiple: true,
146            });
147            file_frame.on('select', function () {
148                var image_ids = [];
149                attachments = file_frame.state().get('selection').toJSON();
150                gallery_image_ids.val('');
151                gallery_image_id_show.val('');
152                attachments.forEach(function (attachment) {
153                    image_ids.push(attachment.id);
154                });
155                gallery_image_ids.val(image_ids);
156                gallery_image_id_show.val(image_ids);
157            });
158            file_frame.open();
159        });
160
161    }
162
163    wpcf_image_gallery_upload('.wpneo-upload-image-gallery');
164
165    // Image Upload Function
166    function wpcf_upload_image(button_class) {
167        var _custom_media = true,
168            _orig_send_attachment = wp.media.editor.send.attachment;
169        $('body').on('click', button_class, function (e) {
170            var button_id = '#' + $(this).attr('id');
171            var button = $(button_id);
172            _custom_media = true;
173            wp.media.editor.send.attachment = function (props, attachment) {
174                if (_custom_media) {
175                    var attachment_url = attachment.url;
176                    $('.wpneo-form-image-url').val(attachment_url);
177                    $('.wpneo-form-image-id').val(attachment.id);
178                } else {
179                    return _orig_send_attachment.apply(button_id, [props, attachment]);
180                }
181            };
182            wp.media.editor.open(button);
183            return false;
184        });
185    }
186    wpcf_upload_image('.wpneo-image-upload');
187    $(document).on('click', '.add_media', function () {
188        _custom_media = false;
189    });
190
191    // Login Toggle Add (Frontend Submit Form)
192    $('.wpneoShowLogin').on('click', function (e) {
193        e.preventDefault();
194        $('.wpneo_login_form_div').slideToggle();
195    });
196
197    // Repeatable Rewards
198    function countRemovesBtn(btn) {
199        var rewards_count = $(btn).length;
200        if (rewards_count > 1) {
201            $(btn).show();
202        } else {
203            $(btn).hide();
204            if (btn == '.removeCampaignRewards') {
205                $('.reward_group').show();
206            }
207            if (btn == '.removecampaignupdate') {
208                $('#campaign_update_field').show();
209            }
210        }
211        $(btn).first().hide();
212    }
213
214    //Add Rewards
215    $('#addreward').on('click', function (e) {
216        e.preventDefault();
217        var rewards_fields = $('.reward_group').html();
218        $('#rewards_addon_fields').append(rewards_fields).hide().show('slow');
219        $('#rewards_addon_fields .campaign_rewards_field_copy:last-child').find('input,textarea,select').each(function () {
220            if (($(this).attr('name') != 'remove_rewards') && ($(this).attr('type') != 'button')) {
221                $(this).val('');
222            }
223        });
224        countRemovesBtn('.removeCampaignRewards');
225    });
226
227    // Remove Campaign Reward
228    $('body').on('click', '.removeCampaignRewards', function (e) {
229        e.preventDefault();
230        const topPosition = $(this).closest('#reward_options').offset().top;
231        $(this).closest('.campaign_rewards_field_copy').html('');
232        $("html, body").animate({ scrollTop: topPosition - 100 }, 100);
233        countRemovesBtn('.removeCampaignRewards');
234    });
235    countRemovesBtn('.removeCampaignRewards');
236
237    //Add More Campaign Update Field
238    $('#addcampaignupdate').on('click', function (e) {
239        e.preventDefault();
240        var update_fields = $('#campaign_update_field').html();
241        $('#campaign_update_addon_field').append(update_fields);
242        countRemovesBtn('.removecampaignupdate');
243    });
244
245    // Remove Campaign Update
246    $('body').on('click', '.removecampaignupdate', function (e) {
247        e.preventDefault();
248        $(this).closest('.campaign_update_field_copy').html('').hide();
249        countRemovesBtn('.removecampaignupdate');
250    });
251    countRemovesBtn('.removecampaignupdate');
252
253    // Dashboard Edit Form
254    $('#wpneo_active_edit_form').on('click', function (e) {
255        e.preventDefault();
256        $('#wpneo_update_display_wrapper').hide();
257        $('#wpneo_update_form_wrapper').fadeIn('slow');
258    });
259
260    // Edit Enable
261    $('#wpneo-edit').on('click', function (e) {
262        e.preventDefault();
263        $('#wpneo-edit').hide();
264        $('.wpneo-content input,.wpneo-content textarea,.wpneo-content select').not('.wpneo-content input[name="username"]').removeAttr("disabled").css("border", "1px solid #dfe1e5");
265        $('.wpneo-save-btn').delay(100).fadeIn('slow');
266        $('.wpneo-cancel-btn').delay(100).fadeIn('slow');
267        $('button.wpneo-image-upload').show();
268    });
269
270    // Dashboard Data Save
271    function wpcf_dashboard_data_save() {
272        var return_data;
273        var postdata = $('#wpneo-dashboard-form').serializeArray();
274        $.ajax({
275            async: false,
276            url: wpcf_ajax_object.ajax_url,
277            type: "POST",
278            data: postdata,
279            success: function (data, textStatus, jqXHR) {
280                wpcf_modal(data);
281                return_data = data;
282            },
283            error: function (jqXHR, textStatus, errorThrown) {
284                wpcf_modal({ 'success': 0, 'message': 'Error sending data' })
285            }
286        });
287        $('.wpneo-content input,.wpneo-content textarea,.wpneo-content select').attr("disabled", "disabled").css("border", "none");
288        $('.wpneo-cancel-btn').hide();
289        $('#wpneo-edit').delay(100).fadeIn('slow');
290        return return_data;
291    }
292
293    // Dashboard Cancel Button
294    $('.wpneo-cancel-btn').on('click', function (e) {
295        e.preventDefault();
296        $('.wpneo-content input,.wpneo-content textarea,.wpneo-content select').attr("disabled", "disabled").css("border", "none");
297        $('.wpneo-cancel-btn').hide();
298        $('#wpneo-dashboard-save').hide();
299        $('#wpneo-profile-save').hide();
300        $('#wpneo-contact-save').hide();
301        $('button.wpneo-image-upload').hide();
302        $('#wpneo-edit').delay(100).fadeIn('slow');
303    });
304
305    // Dashboard Froentend ( Dashboard )
306    $('#wpneo-dashboard-save').on('click', function (e) {
307        e.preventDefault(); //STOP default action
308        var postdata = $('#wpneo-dashboard-form').serializeArray();
309        wpcf_dashboard_data_save();
310    });
311
312    // Dashboard Froentend ( Profile )
313    $('#wpneo-profile-save').on('click', function (e) {
314        e.preventDefault(); //STOP default action
315        wpcf_dashboard_data_save();
316    });
317
318    // Dashboard Froentend ( Contact )
319    $('#wpneo-contact-save').on('click', function (e) {
320        e.preventDefault(); //STOP default action
321        wpcf_dashboard_data_save();
322    });
323
324    // Dashboard Froentend ( Password )
325    $('#wpneo-password-save').on('click', function (e) {
326        e.preventDefault(); //STOP default action
327        wpcf_dashboard_data_save();
328    });
329
330    // Dashboard Froentend ( Update )
331    $('#wpneo-update-save').on('click', function (e) {
332        e.preventDefault(); //STOP default action
333        var return_respone = wpcf_dashboard_data_save();
334        wpcf_modal(return_respone);
335    });
336
337    // Tab Menu Action (Product Single)
338    $('.wpneo-tabs-menu a').on("click", (function (e) {
339        e.preventDefault();
340        $('.wpneo-tabs-menu li').removeClass('wpneo-current');
341        $(this).parent().addClass('wpneo-current');
342        var currentTab = $(this).attr('href');
343        $('.wpneo-tab-content').hide();
344        $(currentTab).fadeIn();
345        return false;
346    }));
347    $($('.wpneo-current a').attr('href')).fadeIn();
348
349    // Modal Bio in Product details
350    $('.wpneo-fund-modal-btn').on('click', function (e) {
351        e.preventDefault();
352        var author = $(this).data('author');
353        $.ajax({
354            type: "POST",
355            url: wpcf_ajax_object.ajax_url,
356            data: { 'action': 'wpcf_bio_action', 'author': author },
357            success: function (data) {
358                wpcf_modal(data);
359            },
360            error: function (jqXHR, textStatus, errorThrown) { wpcf_modal({ 'success': 0, 'message': 'Error' }) }
361        });
362    });
363
364    // Modal Close Option
365    $(document).on('click', '.wpneo-modal-close', function () {
366        $('.wpneo-modal-wrapper').css({ 'display': 'none' });
367        if ($('#wpneo_crowdfunding_redirect_url').length > 0) {
368            location.href = $('#wpneo_crowdfunding_redirect_url').val();
369        }
370    });
371
372    // Donate Field Add Max & Min Amount
373    $('input[name="wpneo_donate_amount_field"]').on('blur change paste', function () {
374        var input_price = $(this).val();
375        var min_price = $(this).data('min-price');
376        var max_price = $(this).data('max-price');
377        if (input_price < min_price) {
378            if (min_price) {
379                $(this).val(min_price);
380                $('.wpneo-tooltip-min').css({ 'visibility': 'visible' });
381            }
382        } else if (max_price < input_price) {
383            if (max_price) {
384                $(this).val(max_price);
385                $('.wpneo-tooltip-max').css({ 'visibility': 'visible' });
386            }
387        } else {
388            $('.wpneo-tooltip-min,.wpneo-tooltip-max').css({ 'visibility': 'hidden' });
389        }
390    });
391
392    // Add Love Campaign
393    $(document).on('click', '#love_this_campaign', function () {
394        var campaign_id = $(this).data('campaign-id');
395        $.ajax({
396            type: "POST",
397            url: wpcf_ajax_object.ajax_url,
398            data: { 'action': 'love_campaign_action', 'campaign_id': campaign_id },
399            success: function (data) {
400                data = JSON.parse(data);
401                if (data.success == 1) {
402                    $('#campaign_loved_html').html(data.return_html);
403                }
404            },
405            error: function (jqXHR, textStatus, errorThrown) {
406                wpcf_modal({ 'success': 0, 'message': 'Error' })
407            }
408        });
409    });
410
411    // Remove Love Campaign
412    $(document).on('click', '#remove_from_love_campaign', function () {
413        var campaign_id = $(this).data('campaign-id');
414        $.ajax({
415            type: "POST",
416            url: wpcf_ajax_object.ajax_url,
417            data: { 'action': 'remove_love_campaign_action', 'campaign_id': campaign_id },
418            success: function (data) {
419                data = JSON.parse(data);
420                $('#campaign_loved_html').html(data.return_html);
421            },
422            error: function (jqXHR, textStatus, errorThrown) {
423                wpcf_modal({ 'success': 0, 'message': 'Error' })
424            }
425        });
426    });
427
428    $(document).on('click', '#user-registration-btn', function (e) {
429        e.preventDefault();
430        var registration_form_data = $(this).closest('form').serialize();
431        $.ajax({
432            type: "POST",
433            url: wpcf_ajax_object.ajax_url,
434            data: registration_form_data,
435            success: function (data) {
436                wpcf_modal(data);
437                data = JSON.parse(data);
438                if (data.success) {
439                    location.href = data.redirect;
440                } else {
441                    if (typeof grecaptcha !== 'undefined') {
442                        grecaptcha.reset();
443                    }
444                }
445            },
446            error: function (jqXHR, textStatus, errorThrown) {
447                wpcf_modal({ 'success': 0, 'message': 'Error' });
448            }
449        });
450    });
451
452    var image = $('input[name=wpneo-form-image-url]').val();
453    if (image != '') {
454        $('#wpneo-image-show').html('<img width="150" src="' + image 
454+ '" />');
455    }
456    $(document).on('click', '.media-button-insert', function (e) {
457        var image = $('input[name=wpneo-form-image-url]').val();
458        if ($('.profile-form-img').length > 0) {
459            $('.profile-form-img').attr('src', image);
460        } else {
461            if (image != '') {
462                $('#wpneo-image-show').html('<img width="150" src="' + image + '" />');
463            }
464        }
465    });
466
467    // Hide Billing and Shipping Information
468    if ($('body.woocommerce-checkout').length >= 1) {
469        if ($('#billing_email').length < 1) {
470            $('#customer_details').css({ 'display': 'none' });
471        }
472    }
473
474    // Form Reward Image Upload
475    $('body').on('click', '.wpneo-image-upload-btn', function (e) {
476        e.preventDefault();
477        var that = $(this);
478
479        var image = wp.media({
480            title: 'Upload Image',
481            multiple: false
482        }).open()
483            .on('select', function (e) {
484                var uploaded_image = image.state().get('selection').first();
485                var uploaded_url = uploaded_image.toJSON().url;
486                uploaded_image = uploaded_image.toJSON().id;
487                $(that).parent().find('.wpneo_rewards_image_field').val(uploaded_image);
488                $(that).parent().find('.wpneo_rewards_image_field_url').val(uploaded_url);
489            });
490    });
491    $('body').on('click', '.wpneo-image-remove', function (e) {
492        var that = $(this);
493        $(that).parent().find('wpneo_rewards_image_field_url').val('');
494        $(that).parent().find('.wpneo_rewards_image_field').val('');
495    });
496
497    // Reward On Click
498    $('body').on('click', '.price-value-change', function (e) {
499        e.preventDefault();
500        var reward = $(this).data('reward-amount');
501        $("html, body").animate({ scrollTop: 0 }, 600,
502            function () {
503                setTimeout(function () {
504                    $(".wpneo_donate_amount_field").addClass("wpneosplash");
505                }, 100);
506                setTimeout(function () {
507                    $(".wpneo_donate_amount_field").val(reward);
508                    $(".wpneo_donate_amount_field").removeClass("wpneosplash");
509                }, 1000);
510            });
511    });
512    $(document).on('click', 'table.reward_table_dashboard tr', function (e) {
513        $(this).find('.reward_description').slideToggle();
514    });
515
516    // Order View (Dashboard Page)
517    $(document).on('click', '.wpcf-order-view', function (e) {
518        e.preventDefault();
519        var orderid = $(this).data('orderid');
520        $.ajax({
521            type: "POST",
522            url: wpcf_ajax_object.ajax_url,
523            data: { 'action': 'wpcf_order_action', 'orderid': orderid },
524            success: function (data) {
525                wpcf_modal(data, true);
526            },
527            error: function (jqXHR, textStatus, errorThrown) {
528                wpcf_modal({ 'success': 0, 'message': 'Error' })
529            }
530        });
531    });
532
533    // Embed Popup (Single Page)
534    $(document).on('click', '.wpneo-icon-embed', function (e) {
535        e.preventDefault();
536        var postid = $(this).data('postid');
537        $.ajax({
538            type: "POST",
539            url: wpcf_ajax_object.ajax_url,
540            data: { 'action': 'wpcf_embed_action', 'postid': postid },
541            success: function (data) {
542                wpcf_modal(data);
543            },
544            error: function (jqXHR, textStatus, errorThrown) { wpcf_modal({ 'success': 0, 'message': 'Error' }) }
545        });
546    });
547
548    // $(document).on('click', '.wpcf-export-data', function (e) {
549    //     e.preventDefault();
550    //     //var postid = $(this).data('postid');
551    //     console.log('Done 2');
552    //     $.ajax({
553    //         type:"POST",
554    //         url: wpcf_ajax_object.ajax_url,
555    //         data: { 'action': 'download_data', 'postid': 222 },
556    //         success:function(data){
557    //             // wpcf_modal(data);
558    //             console.log('Done 1');
559    //         },
560    //         error: function(jqXHR, textStatus, errorThrown){ 
561    //             console.log('1->', jqXHR);
562    //             console.log('2->', textStatus);
563    //             console.log('3->', errorThrown);
564    //         }
565    //     });
566    // });
567
568    /**
569     * Place the predefined price in the donation input value
570     *
571     * @since 10.22
572     */
573    $(document).on('click', 'ul.wpcf_predefined_pledge_amount li a', function () {
574        var price = $(this).attr('data-predefined-price');
575        $('.wpneo_donate_amount_field').val(price);
576    });
577
578    $('select[name="wpneo-form-type"]').on('change', function () {
579        if ($(this).val() == 'never_end') {
580            $('#wpneo_form_start_date').parents('.wpneo-single').hide();
581            $('#wpneo_form_end_date').parents('.wpneo-single').hide();
582        } else {
583            $('#wpneo_form_start_date').parents('.wpneo-single').show();
584            $('#wpneo_form_end_date').parents('.wpneo-single').show();
585        }
586    });
587
588    $('.cloud-zoom').magnificPopup({
589        type: 'image',
590        mainClass: 'product-img-zoomin',
591        gallery: { enabled: true },
592        zoom: {
593            enabled: true, // By default it's false, so don't forget to enable it
594            duration: 400, // duration of the effect, in milliseconds
595            easing: 'ease-in-out', // CSS transition easing function
596            opener: function(openerElement) {
597                return openerElement.is('img') ? openerElement : openerElement.find('img');
598            }
599        }
600    });
601
602});

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.