1(function () { 2 const forms = document.querySelectorAll('.js-subscribe-form'); 3 if (!forms.length) return; 4 5 forms.forEach(function(form) { 6 const emailInput = form.querySelector('.js-subscribe-email'); 7 const inputWrap = form.querySelector('.js-input-wrap'); 8 const errors = form.querySelectorAll('.js-subscribe-error'); 9 const btn = form.querySelector('.js-subscribe-btn'); 10 11 function setError(message) { 12 inputWrap.classList.add('error'); 13 errors.forEach(el => el.textContent = message); 14 } 15 16 function clearError() { 17 inputWrap.classList.remove('error'); 18 errors.forEach(el => el.textContent = ''); 19 } 20 21 emailInput.addEventListener('input', clearError); 22 23 form.addEventListener('submit', (e) => { 24 e.preventDefault(); 25 26 const email = emailInput.value.trim(); 27 if (!email) { 28 setError('ÐведиÑе e-mail'); 29 return; 30 } 31 32 // ÐлокиÑÑем ÐºÐ½Ð¾Ð¿ÐºÑ Ð¸ менÑем ÑекÑÑ 33 btn.disabled = true; 34 btn.textContent = 'ÐодпиÑÑваем...'; 35 clearError(); 36 37 BX.ajax.runComponentAction('ilar:subscribe.user', 'subscribe', { 38 mode: 'ajax', 39 data: { email: email }, 40 }) 41 .then(function (response) { 42 // УÑпеÑÐ½Ð°Ñ Ð¿Ð¾Ð´Ð¿Ð¸Ñка 43 btn.textContent = 'ÐÑ Ð¿Ð¾Ð´Ð¿Ð¸ÑÐ°Ð½Ñ â'; 44 emailInput.value = ''; 45 clearError(); 46 47 // ÐÑкÑÑваем модалÑное окно 48 if (typeof modal !== 'undefined' && typeof modal.open === 'function') { 49 modal.close('burger-menu') 50 modal.open('sucsess-subscribe'); 51 } 52 53 // ÐозвÑаÑаем ÐºÐ½Ð¾Ð¿ÐºÑ Ð² иÑÑ Ð¾Ð´Ð½Ð¾Ðµ ÑоÑÑоÑние ÑеÑез 3 ÑекÑÐ½Ð´Ñ 54 setTimeout(() => { 55 btn.disabled = false; 56 btn.textContent = 'ÐодпиÑаÑÑÑÑ'; 57 }, 3000); 58 }) 59 .catch(function (response) { 60 // ÐбÑабоÑка оÑибок 61 let errorMessage = 'ÐÑибка пÑи подпиÑке'; 62 63 if (response.errors && Array.isArray(response.errors)) { 64 errorMessage = response.errors.map(e => e.message).join(', '); 65 } 66 67 setError(errorMessage); 68 btn.disabled = false; 69 btn.textContent = 'ÐодпиÑаÑÑÑÑ'; 70 }); 71 }); 72 }); 73})();
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.