PageSourceSearch

https://eloket.leopoldsburg.be/js/form-events.js?v=SgI6DiMmkt9d4Aztj4JGZj88BOK_gY3jTMAqPjuGypk

js leopoldsburg.be collected 2026-10-02 14:40:04 UTC 5,050 bytes, 130 lines download raw bytes

1(function () {
2    'use strict';
3
4    var loadingText = (window.Icordis && Icordis.Translations && Icordis.Translations.loading) || '';
5
6    function getButtonText(btn) {
7        var span = btn.querySelector('span');
8        if (span) {
9            return span.textContent;
10        } else if (btn.tagName === 'INPUT') {
11            return btn.value;
12        }
13        return '';
14    }
15
16    function setButtonText(btn, text) {
17        var span = btn.querySelector('span');
18        if (span) {
19            span.textContent = text;
20        } else if (btn.tagName === 'INPUT') {
21            btn.value = text;
22        }
23    }
24
25    function resetForm(form) {
26        delete form.dataset.submitting;
27
28        form.querySelectorAll('button[type="submit"], input[type="submit"]').forEach(function (btn) {
29            btn.classList.remove('is-loading');
30            btn.style.pointerEvents = '';
31            btn.disabled = false;
32
33            if (btn.dataset.originalText !== undefined) {
34                setButtonText(btn, btn.dataset.originalText);
35                delete btn.dataset.originalText;
36            }
37        });
38    }
39
40    var tempSaveEmailDialog = document.getElementById('eloket-tempsave-email');
41
42    document.querySelectorAll('form.form-eloket').forEach(function (form) {
43        var tempSaveEmailInput = form.querySelector('input[name="TempSaveEmail"]');
44        var pendingTempSaveSubmitter = null;
45
46        if (tempSaveEmailDialog && tempSaveEmailInput) {
47            var dialogEmailInput = tempSaveEmailDialog.querySelector('.eloket-tempsave-email__input');
48            var dialogCancelBtn = tempSaveEmailDialog.querySelector('.eloket-tempsave-email__cancel');
49            var dialogConfirmBtn = tempSaveEmailDialog.querySelector('.eloket-tempsave-email__confirm');
50
51            dialogCancelBtn.addEventListener('click', function () {
52                pendingTempSaveSubmitter = null;
53                tempSaveEmailDialog.close();
54            });
55
56            dialogConfirmBtn.addEventListener('click', function () {
57                if (!dialogEmailInput.reportValidity()) {
58                    return;
59                }
60
61                tempSaveEmailInput.value = dialogEmailInput.value;
62                tempSaveEmailDialog.close();
63
64                var submitter = pendingTempSaveSubmitter;
65                pendingTempSaveSubmitter = null;
66
67                if (submitter) {
68                    form.requestSubmit(submitter);
69                }
70            });
71
72            // A TempACMUser has no e-mail on file (blanked server-side), so the
73            // tempsave submit is intercepted here - before the loading-state
74            // handler below runs - to collect one via dialog first. Once
75            // supplied it's stored in the hidden TempSaveEmail field and the
76            // same submit is replayed, this time passing through untouched.
77            form.addEventListener('submit', function (event) {
78                var submitter = event.submitter;
79
80                if (submitter && submitter.dataset.tempSave === '1' && submitter.dataset.tempSaveAskEmail === 'true' && !tempSaveEmailInput.value) {
81                    event.preventDefault();
82                    event.stopImmediatePropagation();
83
84                    pendingTempSaveSubmitter = submitter;
85                    dialogEmailInput.value = '';
86                    tempSaveEmailDialog.showModal();
87                }
88            });
89        }
90
91        form.addEventListener('submit', function (event) {
92            if (form.dataset.submitting === '1') {
93                event.preventDefault();
94                return;
95            }
96            form.dataset.submitting = '1';
97
98            var submitter = event.submitter;
99
100            form.querySelectorAll('button[type="submit"], input[type="submit"]').forEach(function (btn) {
101                btn.classList.add('is-loading');
102
103                if (btn === submitter) {
104                    // Do NOT disable the submitter itself: Firefox drops a disabled
105                    // submitter's name/value pair from the submission (or cancels it
106                    // outright) when disabled synchronously inside the submit handler.
107                    // pointer-events blocks a second click without touching `disabled`.
108                    btn.style.pointerEvents = 'none';
109
110                    if (loadingText) {
111                        btn.dataset.originalText = getButtonText(btn);
112                        setButtonText(btn, loadingText);
113                    }
114                } else {
115                    btn.disabled = true;
116                }
117            });
118        });
119    });
120
121    // A back/forward navigation can restore this page from the bfcache with
122    // the submit buttons still disabled/showing the loading text from the
123    // previous submit. Reset the form state so the user can submit again.
124    window.addEventListener('pageshow', function (event) {
125        if (!event.persisted) {
126            return;
127        }
128        document.querySelectorAll('form.form-eloket').forEach(resetForm);
129    });
130})();

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.