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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-phone-mask-1.1.js

Код файла
Версия от 04.12.2026, 04:03:55 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
601 * @param {object} countries - object with data about each city602 */603function t_form_phonemask__initSelectEvents(rec, inputGroup, countries) {604	const DEFAULT_ZOOM = 1;605	var input = inputGroup.querySelector('.t-input-phonemask');606	var select = inputGroup.querySelector('.t-input-phonemask__select');607	var selectWrap = document.querySelector('.t-input-phonemask__options-wrap');608	var artboard = rec.querySelector('.t396__artboard');609	var popup = document.querySelector('.t-popup');610 611	var word = '';612
История файла и сравнение версий
  • 04.12.2026, 04:03:55 · 56c3b845
var timeout = '';
613 /**
614 * clear timeout
615 */
616 function resetTimeout() {
617 clearTimeout(timeout);
618 timeout = setTimeout(function () {
619 word = '';
620 }, 1500);
621 }
622
623 function t_form_phonemask__renderSelectOptions() {
624 selectWrap.innerHTML = t_form_phonemask__getDrawSelector(countries);
625 }
626
627 function t_form_phonemask__setSelectOptionsEvents() {
628 const optionItems = selectWrap.querySelectorAll('.t-input-phonemask__options-item');
629 Array.prototype.forEach.call(optionItems, function (option) {
630 option.addEventListener('click', t_form_phonemask__changeOption);
631 });
632 }
633
634 function t_form_phonemask__updateSelectWrapPosition() {
635 const { y: inputY, x: inputX, height: inputHeight, width: inputWidth } = inputGroup.getBoundingClientRect();
636 const { width: selectWidth } = selectWrap.getBoundingClientRect();
637 const { clientWidth } = document.documentElement;
638
639 const canOpenFromLeft = selectWidth + inputX < clientWidth;
640 if (canOpenFromLeft) {
641 selectWrap.style.right = 'unset';
642 selectWrap.style.left = inputX + 'px';
643 } else {
644 const inputRightX = inputX + inputWidth;
645 selectWrap.style.left = 'unset';
646 selectWrap.style.right = clientWidth - inputRightX + 'px';
647 }
648
649 selectWrap.style.top = inputY + inputHeight + 5 + 'px';
650 }
651
652 function t_form_phonemask__getZoom() {
653 if (!artboard) return DEFAULT_ZOOM;
654
655 const recid = artboard.getAttribute('data-artboard-recid');
656 const artboardId = `ab${recid}`;
657 const scaleFactor =
658 window.tn && window.tn[artboardId] ? window.tn[artboardId].scaleFactor : window.tn_scale_factor;
659
660 return scaleFactor || DEFAULT_ZOOM;
661 }
662
663 function t_form_phonemask__fixStylesForSafariAutoscale() {
664 const { top: inputTop, x: inputX, height: inputHeight, width: inputWidth } = inputGroup.getBoundingClientRect();
665 const { top: bodyTop } = document.body.getBoundingClientRect();
666 const { width: selectWidth } = selectWrap.getBoundingClientRect();
667 const { clientWidth } = document.documentElement;
668 const zoom = t_form_phonemask__getZoom();
669 const realInputX = inputX * zoom;
670 const realInputWidth = inputWidth * zoom;
671
672 selectWrap.style.position = 'absolute';
673
674 const canOpenFromLeft = selectWidth + realInputX < clientWidth;
675 if (canOpenFromLeft) {
676 selectWrap.style.right = 'unset';
677 selectWrap.style.left = realInputX + 'px';
678 } else {
679 const inputRightX = realInputX + realInputWidth;
680 selectWrap.style.left = 'unset';
681 selectWrap.style.right = clientWidth - inputRightX + 'px';
682 }
683
684 selectWrap.style.top = (inputTop - bodyTop + inputHeight) * zoom + 5 + 'px';
685 }
686
687 function t_form_phonemask__isAutoscaleFixNeeded() {
688 const zoom = t_form_phonemask__getZoom();
689 const isAutoscale = zoom !== DEFAULT_ZOOM;
690
691 return (window.isiOS || window.isSafari) && isAutoscale && !window.t396__clientRectIncludesZoom;
692 }
693
694 var updateSelectPositionDebounced = function () {
695 return requestAnimationFrame(t_form_phonemask__updateSelectWrapPosition);
696 };
697
698 function t_form_phonemask__addWrapPositionUpdateListeners() {
699 window.addEventListener('resize', updateSelectPositionDebounced);
700 document.addEventListener('scroll', updateSelectPositionDebounced);
Предыдущие 100 строкСледующие 100 строк