t_addClass(body, 't-body_success-popup-showed');
1015 if (t_forms__isIOS()) { 1016 setTimeout(function () { 1017 window.tildaForm.lockBodyScroll(); 1024 * Show new version of success message in popup 1025 * @param {string} text - text in success popup 1026 * @param {string} title – title of success popup 1027 * @param {string} btn – text in button in success popup 1029window.tildaForm.showSuccessPopupNew = function (form, text, title, btn) { 1030 const popupId = 'tildaformsuccesspopup-new'; 1031 const body = document.body; 1032 const successUrl = form.getAttribute('data-success-url'); 1033 const isRedirect = !!successUrl; 1035 // если есть редирект, нет ошибки при редиректе, не заполненны заголовок и текст – не показываем попап 1036 if (!window.isRedirectError && isRedirect && !text && !title) return; 1038 // редирект не произошёл из-за ошибки, текст и заголовок не заполнены 1039 const isPopupAfterRedirectError = window.isRedirectError && isRedirect && !text && !title; 1040 const isEmptyContent = !title && !text; 1042 const successPopup = initPopup(); 1044 updatePopupContent(); 1046 restartIconAnimation(); 1048 t_forms__setupCloseHandlers(successPopup, isRedirect); 1052 // a11y ловушка фокуса 1053 setTimeout(function () { 1054 successPopup.focus(); 1055 t_forms__trapFocus(successPopup); 1058 function initPopup() { 1059 let popup = document.getElementById(popupId); 1061 body.insertAdjacentHTML('beforeend', t_forms__drawNewSuccessPopup()); 1062 popup = document.getElementById(popupId); 1068 function showPopup() { 1069 t_fadeIn(successPopup); 1070 t_addClass(body, 't-body_success-popup-showed'); 1071 successPopup.classList.add('t-popup_show'); 1072 resizeSuccessPopup(successPopup); 1073 if (t_forms__isIOS()) { 1074 setTimeout(function () { 1075 window.tildaForm.lockBodyScroll(); 1080 function resizeSuccessPopup() { 1081 const STATIC_POPUP_VERTICAL_PADDING = 120; 1082 const availableWindowHeight = window.innerHeight - STATIC_POPUP_VERTICAL_PADDING; 1083 const popupContainer = successPopup.querySelector('.t-form-success-popup__wrapper'); 1084 const popupContainerStyle = getComputedStyle(popupContainer, null); 1085 const popupContainerPaddingTop = parseInt(popupContainerStyle.paddingTop) || 0; 1086 const popupContainerPaddingBottom = parseInt(popupContainerStyle.paddingBottom) || 0; 1087 const popupContainerHeight = 1088 popupContainer.clientHeight - (popupContainerPaddingTop + popupContainerPaddingBottom); 1090 const height = popupContainerHeight; 1092 // Проверяем, помещается ли попап в доступное пространство окна 1093 const fitsInWindow = height <= availableWindowHeight; 1096 popupContainer.classList.remove('t-popup__container-static'); 1098 popupContainer.classList.add('t-popup__container-static');