PageSourceSearch

https://thecryfreedomshowwithlisa.com/wp-content/plugins/email-sub…/js/email-subscribers-public.js?ver=5.7.20

js thecryfreedomshowwithlisa.com collected 2026-09-26 09:59:18 UTC 5,126 bytes, 161 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 redirection_url = response['redirection_url'];
72
73        if ( 'undefined' !== typeof redirection_url ) {
74
75            redirection_url = redirection_url.trim();
76            if (typeof(redirection_url) === 'string' && redirection_url != '') {
77                if (!/^https?:\/\//i.test(redirection_url) ) {
78                    redirection_url = "http://"+redirection_url;
79                }
80                window.location.href = redirection_url;
81            }
82
83        } else {
84            var status = response.status;
85            var message_class = 'success';
86            if (status === 'ERROR') {
87                message_class = 'error';
88            }
89
90            var responseText = response['message_text'];
91            var messageContainer = $(form).next('.es_subscription_message');
92            messageContainer.attr('class', 'es_subscription_message ' + message_class);
93            messageContainer.html(responseText);
94            var esSuccessEvent = {
95                detail: {
96                    es_response: message_class,
97                    msg: responseText
98                },
99                bubbles: true,
100                cancelable: true
101            };
102
103            $(form).trigger('es_response', [esSuccessEvent]);
104        }        
105    }
106
107    function handleBindFunction(form, is_ig = false) {
108        form = $(form);
109        var formData = form.serializeObject();
110        formData['es'] = 'subscribe';
111        formData['action'] = 'es_add_subscriber';
112        $.ajax({
113            type: 'POST',
114            url: es_data.es_ajax_url,
115            data: formData,
116            dataType: 'json',
117            beforeSend: function () {
118                form.find('#spinner-image').show();
119                form.find('.es_submit_button').attr('disabled', true);
120            },
121            success: function (response) {
122                if (!is_ig) {
123                    if (response && typeof response.status !== 'undefined' && response.status === "SUCCESS") {
124                        form.slideUp('slow');
125                        form.hide();
126                    } else {
127                        form.find('#spinner-image').hide();
128                    }
129                }
130                form.find('.es_submit_button').attr('disabled', false);
131                jQuery(window).trigger('es.send_response', [form, response]);
132                handleResponse(response, form);
133            },
134            error: function (err) {
135                form.find('#spinner-image').hide();
136                form.find('.es_submit_button').attr('disabled', false);
137                console.log(err, 'error');
138            },
139        });
140
141
142		return false;
143	}
144
145	// Compatibility of ES with IG
146	jQuery( window ).on( "init.icegram", function(e, ig) {
147		if(typeof ig !== 'undefined' && typeof ig.messages !== 'undefined' ) {
148			jQuery('.icegram .es_shortcode_form, .icegram form[data-source="ig-es"]').each(function(i, v){
149				jQuery(v).bind('submit', function (e) {
150					e.preventDefault();
151					e.stopImmediatePropagation();
152					var form = $(this);
153					handleBindFunction(form, true);
154				});
155			});
156		}
157	});
158
159})(jQuery);
160
161

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.