PageSourceSearch

https://xn----7sbigdbwnfmr5aeexh.xn--p1ai/wp-content/themes/soglasuem/assets/js/form.js?v=1

js xn----7sbigdbwnfmr5aeexh.xn--p1ai collected 2026-10-04 03:37:06 UTC 4,159 bytes, 132 lines download raw bytes

1jQuery(function($) {
2	
3	$('.form').on('changed, keydown, blur, focusout', 'input, textarea', function(e){
4		if(this.value /*&& !this.value.includes('_')*/){
5			$(this).parent().find('.placeholder').addClass('placeholder_up');
6			$(this).parent().find('.b24-form-control-label').addClass('placeholder_up');
7			$(this).addClass('input_up');
8		}
9		else{
10			$(this).parent().find('.placeholder').removeClass('placeholder_up');
11			$(this).parent().find('.b24-form-control-label').removeClass('placeholder_up');
12			$(this).removeClass('input_up');
13		}
14	});
15	$('.form').on('focus', 'input, textarea', function(e){
16		$(this).parent().find('.placeholder').addClass('placeholder_up');
17		$(this).parent().find('.b24-form-control-label').addClass('placeholder_up');
18		$(this).addClass('input_up');
19	});
20
21});
22
23
24
25
26// всплывающая форма
27let modalShown = false;
28const modal = document.getElementById('modal-cta');
29
30const showModal = () => {
31	if (!modalShown && modal) {
32		// Проверка на открытые модальные окна
33		const openModals = document.querySelectorAll('.modal.show');
34		if (openModals.length > 0) {
35		return;
36		}
37		// Проверка, находится ли фокус в input внутри формы с классом .form
38		const activeElement = document.activeElement;
39		const isFormInputFocused = activeElement && activeElement.closest('.form') && activeElement.tagName === 'INPUT';
40		if (isFormInputFocused) {
41		return;
42		}
43		modalShown = true;
44		new bootstrap.Modal(modal).show();
45	}
46};
47
48setTimeout(showModal, 50000);
49
50window.addEventListener('mouseout', function (e) {
51	if (e.clientY < 0) {
52		showModal();
53	}
54});
55
56
57// маска поля телефона Битрикс24
58document.addEventListener('DOMContentLoaded', function () {
59  const MAX_PHONE_LENGTH = 18;
60
61  function setupPhoneInput(input) {
62    if (input.dataset.masked) return;
63
64    input.dataset.masked = true;
65    input.setAttribute('maxlength', MAX_PHONE_LENGTH);
66
67    input.addEventListener('input', function (e) {
68      let value = e.target.value;
69
70      // Удаляем недопустимые символы
71      value = value.replace(/[^0-9+()\-\s]/g, '');
72
73      // Регулярное выражение для российских номеров: +7 (код) XXX-XXXX или 8 (код) XXX-XXXX
74      const phoneRegex = /^(\+7|8)\s\(\d{0,3}\)\s\d{0,3}-\d{0,4}$/;
75
76      if (value.length > MAX_PHONE_LENGTH) {
77        e.target.value = value.slice(0, MAX_PHONE_LENGTH);
78      } else if (!phoneRegex.test(value) && value !== '') {
79        // Если ввод начинается не с +7 или 8, принудительно добавляем +7
80        if (!value.startsWith('+7') && !value.startsWith('8')) {
81          e.target.value = '+7 ' + value.replace(/^\+?\d?/, '').trim();
82        } else {
83          e.target.value = value;
84        }
85      }
86    });
87
88    input.addEventListener('paste', function (e) {
89      e.preventDefault();
90      const pastedData = (e.clipboardData || window.clipboardData).getData('text');
91      let cleanedData = pastedData.replace(/[^0-9+()\-\s]/g, '').slice(0, MAX_PHONE_LENGTH);
92      // Если вставленный текст не начинается с +7 или 8, добавляем +7
93      if (!cleanedData.startsWith('+7') && !cleanedData.startsWith('8')) {
94        cleanedData = '+7 ' + cleanedData.replace(/^\+?\d?/, '').trim();
95      }
96      e.target.value = cleanedData;
97    });
98
99  }
100
101  const telInputs = document.querySelectorAll('.b24-form input[type="tel"]');
102  telInputs.forEach(setupPhoneInput);
103
104  const observer = new MutationObserver(function (mutations) {
105    mutations.forEach(function (mutation) {
106      if (mutation.addedNodes.length) {
107        mutation.addedNodes.forEach(node => {
108          if (node.nodeType === 1) {
109            const inputs = node.matches('.b24-form input[type="tel"]')
110              ? [node]
111              : node.querySelectorAll('.b24-form input[type="tel"]');
112            inputs.forEach(setupPhoneInput);
113          }
114        });
115      }
116    });
117  });
118
119  observer.observe(document.body, {
120    childList: true,
121    subtree: true
122  });
123});
124
125
126
127
128
129
130
131
132

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.