PageSourceSearch

https://associationforpublicart.org/wp-content/themes/vast/assets/js/neon-signup.js?ver=1.0.1.1789692224

js associationforpublicart.org collected 2026-09-24 17:39:11 UTC 2,888 bytes, 74 lines download raw bytes

1/**
2 * Footer newsletter signup → NEON CRM.
3 *
4 * Intercepts the footer-a form submit and posts first name / last name / email
5 * to the WordPress AJAX handler (action: vast_neon_signup), which creates the
6 * constituent in NEON. Shows inline success/error states without leaving the page.
7 */
8(function () {
9    'use strict';
10
11    var cfg = window.vastNeon || {};
12    var forms = document.querySelectorAll('[data-vast-neon-form]');
13    if (!forms.length || !cfg.ajaxUrl) return;
14
15    forms.forEach(function (form) {
16        var status = form.querySelector('[data-vast-neon-status]');
17        var submit = form.querySelector('.vast-footer-a__form-submit');
18
19        function val(name) {
20            var el = form.querySelector('[name="' + name + '"]');
21            return el ? el.value.trim() : '';
22        }
23
24        function setStatus(msg, type) {
25            if (!status) return;
26            status.textContent = msg || '';
27            status.className = 'vast-footer-a__form-status' + (type ? ' vast-footer-a__form-status--' + type : '');
28        }
29
30        form.addEventListener('submit', function (e) {
31            e.preventDefault();
32            if (!form.checkValidity()) {
33                form.reportValidity();
34                return;
35            }
36
37            setStatus('', '');
38            form.classList.add('vast-footer-a__form--loading');
39            if (submit) submit.disabled = true;
40
41            var data = new URLSearchParams();
42            data.append('action', 'vast_neon_signup');
43            data.append('nonce', cfg.nonce || '');
44            data.append('first_name', val('first_name'));
45            data.append('last_name', val('last_name'));
46            data.append('email', val('email'));
47
48            fetch(cfg.ajaxUrl, {
49                method: 'POST',
50                credentials: 'same-origin',
51                headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
52                body: data.toString()
53            })
54                .then(function (r) {
55                    return r.json().catch(function () { return { success: false }; });
56                })
57                .then(function (res) {
58                    if (res && res.success) {
59                        setStatus((res.data && res.data.message) || 'Thanks for signing up!', 'success');
60                        form.reset();
61                    } else {
62                        setStatus((res && res.data && res.data.message) || 'Something went wrong. Please try again.', 'error');
63                    }
64                })
65                .catch(function () {
66                    setStatus('Something went wrong. Please try again.', 'error');
67                })
68                .then(function () {
69                    form.classList.remove('vast-footer-a__form--loading');
70                    if (submit) submit.disabled = false;
71                });
72        });
73    });
74})();

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.