PageSourceSearch

https://bialczynski.pl/wp-content/plugins/email-subscribers/lite/p…/js/email-subscribers-public.js?ver=5.3.17

js bialczynski.pl collected 2026-10-02 07:17:23 UTC 4,551 bytes, 148 lines download raw bytes

1(function ($) {
2	'use strict';
3
4	/**
5	 * All of the code for your public-facing JavaScript source
6	 * should reside in this file.
7	 *
8	 * Note: It has been assumed you will write jQuery code here, so the
9	 * $ function reference has been prepared for usage within the scope
10	 * of this function.
11	 *
12	 * This enables you to define handlers, for when the DOM is ready:
13	 *
14	 * $(function() {
15	 *
16	 * });
17	 *
18	 * When the window is loaded:
19	 *
20	 * $( window ).load(function() {
21	 *
22	 * });
23	 *
24	 * ...and/or other possibilities.
25	 *
26	 * Ideally, it is not considered best practise to attach more than a
27	 * single DOM-ready or window-load handler for a particular page.
28	 * Although scripts in the WordPress core, Plugins and Themes may be
29	 * practising this, we should strive to set a better example in our own work.
30	 */
31
32    $(document).ready(function () {
33
34        /**
35         * Extend jQuery to convert form into JSON object
36         * @returns {{}}
37         */
38        $.fn.serializeObject = function () {
39            var output = {};
40            var formData = this.serializeArray();
41            $.each(formData, function () {
42                var fieldName = this.name;
43                var fieldValue = this.value || '';
44                var isArrayField = fieldName.slice(-2) === '[]';
45                if (isArrayField) {
46                    if (output[fieldName]) {
47                        output[fieldName].push(fieldValue);
48                    } else {
49                        output[fieldName] = [fieldValue];
50                    }
51                } else {
52                    output[fieldName] = fieldValue;
53                }
54            });
55            return output;
56        };
57
58        /**
59         * Handle subscription form submission
60         */
61        $('.es_ajax_subscription_form').on('submit', function (e) {
62            var form = $(this);
63            e.preventDefault();
64            handleBindFunction(form);
65        });
66
67    });
68
69    function handleResponse(response, form) {
70
71        var status = response.status;
72
73        var message_class = 'success';
74        if (status === 'ERROR') {
75            message_class = 'error';
76        }
77
78        var responseText = response['message_text'];
79        var messageContainer = $(form).next('.es_subscription_message');
80        messageContainer.attr('class', 'es_subscription_message ' + message_class);
81        messageContainer.html(responseText);
82        var esSuccessEvent = {
83            detail: {
84                es_response: message_class,
85                msg: responseText
86            },
87            bubbles: true,
88            cancelable: true
89        };
90
91        $(form).trigger('es_response', [esSuccessEvent]);
92    }
93
94    function handleBindFunction(form, is_ig = false) {
95        form = $(form);
96        var formData = form.serializeObject();
97        formData['es'] = 'subscribe';
98        formData['action'] = 'es_add_subscriber';
99        $.ajax({
100            type: 'POST',
101            url: es_data.es_ajax_url,
102            data: formData,
103            dataType: 'json',
104            beforeSend: function () {
105                form.find('#spinner-image').show();
106                form.find('.es_submit_button').attr('disabled', true);
107            },
108            success: function (response) {
109                if (!is_ig) {
110                    if (response && typeof response.status !== 'undefined' && response.status === "SUCCESS") {
111                        form.slideUp('slow');
112                        form.hide();
113                    } else {
114                        form.find('#spinner-image').hide();
115                    }
116                }
117                form.find('.es_submit_button').attr('disabled', false);
118                jQuery(window).trigger('es.send_response', [form, response]);
119                handleResponse(response, form);
120            },
121            error: function (err) {
122                form.find('#spinner-image').hide();
123                form.find('.es_submit_button').attr('disabled', false);
124                console.log(err, 'error');
125            },
126        });
127
128
129		return false;
130	}
131
132	// Compatibility of ES with IG
133	jQuery( window ).on( "init.icegram", function(e, ig) {
134		if(typeof ig !== 'undefined' && typeof ig.messages !== 'undefined' ) {
135			jQuery('.icegram .es_shortcode_form, .icegram form[data-source="ig-es"]').each(function(i, v){
136				jQuery(v).bind('submit', function (e) {
137					e.preventDefault();
138					e.stopImmediatePropagation();
139					var form = $(this);
140					handleBindFunction(form, true);
141				});
142			});
143		}
144	});
145
146})(jQuery);
147
148

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.