PageSourceSearch

https://vanticosmeticos.com.br/wp-content/plugins/wc-waiting-list/assets/js/frontend.js?ver=3.0.0

js vanticosmeticos.com.br collected 2026-10-07 04:22:52 UTC 5,210 bytes, 147 lines download raw bytes

1/**
2 * WC Waiting List - Frontend JavaScript
3 */
4
5(function($) {
6    'use strict';
7
8    var WCWL = {
9        init: function() {
10            this.bindEvents();
11        },
12
13        bindEvents: function() {
14            $(document).on('submit', '.wcwl-subscribe-form', this.handleSubscribe);
15            $(document).on('submit', '.wcwl-unsubscribe-form', this.handleUnsubscribe);
16        },
17
18        handleSubscribe: function(e) {
19            e.preventDefault();
20
21            var $form = $(this);
22            var $container = $form.closest('.wcwl-waitlist-form');
23            var $button = $form.find('.wcwl-button');
24            var $notices = $container.find('.wcwl-notices');
25
26            var productId = $form.find('input[name="wcwl_product_id"]').val();
27            var email = $form.find('input[name="wcwl_email"]').val();
28
29            if (!email) {
30                WCWL.showNotice($notices, wcwl_params.i18n.error, 'error');
31                return;
32            }
33
34            $container.addClass('wcwl-loading');
35            $button.prop('disabled', true).text(wcwl_params.i18n.subscribing);
36            $notices.empty();
37
38            $.ajax({
39                url: wcwl_params.ajax_url,
40                type: 'POST',
41                data: {
42                    action: 'wcwl_subscribe',
43                    nonce: wcwl_params.nonce,
44                    product_id: productId,
45                    email: email
46                },
47                success: function(response) {
48                    if (response.success) {
49                        if (response.data.form_html) {
50                            $container.replaceWith(response.data.form_html);
51                        }
52                        WCWL.showNotice($container.find('.wcwl-notices'), response.data.message, 'success');
53                    } else {
54                        WCWL.showNotice($notices, response.data.message, 'error');
55                    }
56                },
57                error: function() {
58                    WCWL.showNotice($notices, wcwl_params.i18n.error, 'error');
59                },
60                complete: function() {
61                    $container.removeClass('wcwl-loading');
62                    $button.prop('disabled', false).text($button.data('original-text') || $button.text());
63                }
64            });
65        },
66
67        handleUnsubscribe: function(e) {
68            e.preventDefault();
69
70            var $form = $(this);
71            var $container = $form.closest('.wcwl-waitlist-form');
72            var $button = $form.find('.wcwl-button');
73            var $notices = $container.find('.wcwl-notices');
74
75            var productId = $form.find('input[name="wcwl_product_id"]').val();
76            var email = $form.find('input[name="wcwl_email"]').val();
77
78            $container.addClass('wcwl-loading');
79            $button.prop('disabled', true);
80            $notices.empty();
81
82            $.ajax({
83                url: wcwl_params.ajax_url,
84                type: 'POST',
85                data: {
86                    action: 'wcwl_unsubscribe',
87                    nonce: wcwl_params.nonce,
88                    product_id: productId,
89                    email: email
90                },
91                success: function(response) {
92                    if (response.success) {
93                        if (response.data.form_html) {
94                            $container.replaceWith(response.data.form_html);
95                        }
96                    } else {
97                        WCWL.showNotice($notices, response.data.message, 'error');
98                    }
99                },
100                error: function() {
101                    WCWL.showNotice($notices, wcwl_params.i18n.error, 'error');
102                },
103                complete: function() {
104                    $container.removeClass('wcwl-loading');
105                    $button.prop('disabled', false);
106                }
107            });
108        },
109
110        showNotice: function($container, message, type) {
111            var $notice = $('<div class="wcwl-notice wcwl-notice-' + type + '">' + message + '</div>');
112            $container.html($notice);
113
114            // Auto-hide after 5 seconds
115            setTimeout(function() {
116                $notice.fadeOut(function() {
117                    $(this).remove();
118                });
119            }, 5000);
120        }
121    };
122
123    $(document).ready(function() {
124        WCWL.init();
125    });
126
127    // Support for variable products
128    $(document).on('found_variation', function(event, variation) {
129        var $form = $(event.target);
130        var $waitlistForm = $form.closest('.product').find('.wcwl-waitlist-form');
131        
132        if (!variation.is_in_stock) {
133            // Show waitlist form for this variation
134            $waitlistForm.show().attr('data-product-id', variation.variation_id);
135            $waitlistForm.find('input[name="wcwl_product_id"]').val(variation.variation_id);
136        } else {
137            $waitlistForm.hide();
138        }
139    });
140
141    $(document).on('reset_data', function(event) {
142        var $form = $(event.target);
143        var $waitlistForm = $form.closest('.product').find('.wcwl-waitlist-form');
144        $waitlistForm.hide();
145    });
146
147})(jQuery);

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.