PageSourceSearch

http://haleyhardinwest.com/wp-content/plugins/email-subscribers/li…/js/email-subscribers-public.js?ver=4.7.6

js haleyhardinwest.com collected 2026-10-08 23:07:24 UTC 3,654 bytes, 143 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		$('.es_subscription_form').each(function(){
35			// For the forms which are hidden on page load, we need to use AJAX to handle their submission.
36			if ( $(this).is(':hidden') ) {
37				$(this).on('submit', function(e){
38					e.preventDefault();
39					var form = $(this);
40					handleBindFunction(form);
41				});
42			}
43		});
44
45	});
46
47	function prepareFormData(form, formData) {
48		var list_ids = [];
49		var is_multiple_lists = false;
50		jQuery.each((form.serializeArray() || {}), function (i, field) {
51			// Collect all list ids
52			if(field.name === 'esfpx_lists[]') {
53				list_ids.push(field.value);
54				is_multiple_lists = true;
55			} else {
56				formData[field.name] = field.value;
57			}
58		});
59
60		if(is_multiple_lists) {
61			formData['esfpx_lists[]'] = list_ids;
62		}
63
64
65		return formData;
66	}
67
68	function handleResponse(response, form) {
69
70		var status = response.status;
71
72		var message_class = 'success';
73		if(status === 'ERROR') {
74			message_class = 'error';
75		}
76
77		var responseText = response['message_text'];
78		var messageContainer = $(form).next('.es_subscription_message');
79		messageContainer.attr('class', 'es_subscription_message ' + message_class);
80		messageContainer.html(responseText);
81		var esSuccessEvent = { 
82								detail: { 
83											es_response : message_class, 
84											msg: responseText
85										}, 
86								bubbles: true, 
87								cancelable: true 
88							} ;
89
90		jQuery(form).trigger('es_response', [ esSuccessEvent ]);
91	}
92
93	function handleBindFunction(form, is_ig){
94		var is_ig = is_ig || false;
95		var formData = {};
96		formData = prepareFormData(form, formData);
97		formData['es'] = 'subscribe';
98		formData['action'] = 'es_add_subscriber';
99		var actionUrl = es_data.es_ajax_url;
100		jQuery(form).find('#spinner-image').show();
101		$.ajax({
102			type: 'POST',
103			url: actionUrl,
104			data: formData,
105			dataType: 'json',
106			success: function (response) {
107				if(!is_ig){
108					if( response && typeof response.status !== 'undefined' && response.status === "SUCCESS" ) {
109						jQuery(form).slideUp('slow');
110						jQuery(form).hide();
111					} else {
112						jQuery(form).find('#spinner-image').hide();
113					}
114				}
115				jQuery(window).trigger('es.send_response', [jQuery(form) , response]);
116				handleResponse(response, form);
117			},
118			error: function (err) {
119				jQuery(form).find('#spinner-image').hide();
120				console.log(err, 'error');
121			},
122		});
123
124
125		return false;
126	}
127	
128	// Compatibility of ES with IG
129	jQuery( window ).on( "init.icegram", function(e, ig) {
130		if(typeof ig !== 'undefined' && typeof ig.messages !== 'undefined' ) {
131			jQuery('.icegram .es_shortcode_form, .icegram form[data-source="ig-es"]').each(function(i, v){
132				jQuery(v).bind('submit', function (e) {
133					e.preventDefault();
134					var form = $(this);
135					handleBindFunction(form, true);
136				});
137			});
138		}
139	});
140	
141})(jQuery);
142
143

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.