Некодим логотипНекодим
МодификацииПубликацииНекодИИмЦены
Некодим логотипНекодим

© 2020-2026 Некодим

Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.

Компания

  • Контакты
  • Публичная оферта
  • Политика конфиденциальности
  • Согласие на обработку данных
  • Лицензионное соглашение
  • Реферальная программа

Полезное

  • Модификации
  • Публикации
  • Каталог блоков Tilda
  • MCP для агентов
  • Журнал изменений
  • Доска почёта

Личный кабинет

  • Вход
  • Регистрация
  • Цены
Журнал измененийИстория GitФайлыTilda MCP
Каталог файлов

tilda-contact-method-1.0.js

Код файла
Версия от 04.12.2026, 04:03:55 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
101	 */102	function showContactMethodValueGroup(options) {103		const { contactMethod } = options;104 105		const valueGroup = t_contactMethod__getValueGroup(inputGroup, contactMethod);106		const inputType = t_contactMethod__getDefaultInputTypeForContactMethod(contactMethod);107 108		t_contactMethod__show(valueGroup);109		showValueGroupInput({ group: valueGroup, inputType });110 111		if (t_contactMethod__isHybridValueGroup(valueGroup)) {112
История файла и сравнение версий
  • 04.12.2026, 04:03:55 · 56c3b845
initHybridValueGroup(valueGroup);
113 }
114 }
115
116 /**
117 * @param {{ contactMethod: ContactMethod } & ChangeValueParams} options
118 */
119 function hideContactMethodValueGroup(options) {
120 const { contactMethod, silent } = options;
121 const valueGroup = t_contactMethod__getValueGroup(inputGroup, contactMethod);
122 const { valueHolder, isoHolder, maskHolder } = t_contactMethod__getPhoneInputElements(valueGroup);
123 const usernameInput = t_contactMethod__getInputElement(valueGroup, 'text');
124
125 // Группа может быть скрыта заранее (например, зеро-форма рендерит начальное состояние поля),
126 // но поля маски телефона в ней создаются позже и их все равно нужно отключить
127 if (!t_contactMethod__isHidden(valueGroup)) {
128 t_contactMethod__resetInputValue(valueGroup, 'text', { silent });
129 t_contactMethod__resetInputValue(valueGroup, 'phone', { silent });
130 t_contactMethod__hide(valueGroup);
131 }
132
133 t_contactMethod__disable(usernameInput);
134 t_contactMethod__disable(valueHolder);
135 t_contactMethod__disable(isoHolder);
136 t_contactMethod__disable(maskHolder);
137 }
138
139 /**
140 * @param {{
141 * group: Element,
142 * inputType: InputType,
143 * autoFocus?: boolean
144 * }} options
145 * @returns {{ input: HTMLInputElement, wrapper?: HTMLDivElement }}
146 */
147 function showValueGroupInput(options) {
148 const { group, inputType, autoFocus = false } = options;
149
150 const phoneWrapper = group.querySelector('.t-input-phonemask__wrap');
151 const { valueHolder: phoneValueHolder, maskHolder: phoneMaskHolder, isoHolder: phoneValueISOHolder } = t_contactMethod__getPhoneInputElements(phoneWrapper);
152
153 const phoneInput = t_contactMethod__getInputElement(group, 'phone');
154 const usernameInput = t_contactMethod__getInputElement(group, 'text');
155 const phoneInputContainer = phoneInput ? phoneInput.closest('.t-input-block') : null;
156 const usernameInputContainer = usernameInput ? usernameInput.closest('.t-input-block') : null;
157
158 if (inputType === 'phone' && phoneInput) {
159 t_contactMethod__hide(usernameInputContainer);
160 t_contactMethod__disable(usernameInput);
161
162 t_contactMethod__show(phoneInputContainer);
163 t_contactMethod__enable(phoneValueHolder);
164 t_contactMethod__enable(phoneValueISOHolder);
165 t_contactMethod__enable(phoneMaskHolder);
166 if (autoFocus) {
167 phoneInput.focus();
168 }
169
170 return { wrapper: phoneWrapper, input: phoneInput };
171 }
172
173 if (inputType === 'text' && usernameInput) {
174 t_contactMethod__hide(phoneInputContainer);
175 t_contactMethod__disable(phoneValueHolder);
176 t_contactMethod__disable(phoneValueISOHolder);
177 t_contactMethod__disable(phoneMaskHolder);
178
179 t_contactMethod__show(usernameInputContainer);
180 t_contactMethod__enable(usernameInput);
181 if (autoFocus) {
182 usernameInput.focus();
183 }
184
185 return { input: usernameInput };
186 }
187 }
188
189 function handleResetField() {
190 const defaultContactMethod = defaultContactMethodElement.getAttribute('data-method-type');
191
192 radioInputs.forEach(input => {
193 if (input.value === defaultContactMethod) {
194 input.checked = true;
195 changeSelectedMethod(defaultContactMethod, { silent: true });
196 };
197 });
198
199 const valueGroup = t_contactMethod__getValueGroup(inputGroup, defaultContactMethod);
200 t_contactMethod__resetInputValue(valueGroup, 'text', { silent: true });
Предыдущие 100 строкСледующие 100 строк