/** * Файл отвечает за отображение страницы профиля */ /* exported tmst_profile__initPage */ /* exported tmst_profile__redirectToProfilePage */ /** * Флаг для отслеживания изменений в форме */ var isFormChanged = false; /** * Отслеживает изменения в форме * @param {HTMLElement} formElement - элемент формы */ function setupFormChangeTracking(formElement) { formElement.addEventListener('input', function () { isFormChanged = true; }); } /** * Настраивает предупреждение при попытке закрыть страницу */ function setupBeforeUnloadWarning() { window.addEventListener('beforeunload', function (event) { if (isFormChanged) { event.preventDefault(); event.returnValue = ''; } }); } /** * Инициализирует страницу */ function tmst_profile__initPage() { tmst_profile__initializeProfileContainer(); tmst_profile__initializeUserbarWidget(); tmst__addHeaderFooter(); tmst__applyStyles(); tmst__installCart(); tmst__addBgIfNeeded(); var path = tma__getPath(); if (!path[2]) { tmst_profile__renderProfilePage(); } else if (path[2] === 'password') { tmst_profile__renderPasswordPage(); } else { document.location.replace('/members/profile'); } tma__showDocumentReady(); } /** * Рендерит страницу профиля */ function tmst_profile__renderProfilePage() { document.title = tma__translate('{{form_edit_profile_title}}', 'userbar_dict'); tmst_profile__drawBreadcrumbs(); tmst_profile__drawProfilePageContent(); tmst_profile__initPhoneMask(); tma__profile__initTooltips(); tmst_profile__setupDropdownHandlers(); tmst_profile__setupFormSubmitHandler(); tmst_profile__setupInvalidPhoneHandler(); tmst_profile__setupLanguageSelectorHandler(); var formElement = document.getElementById('form-change-profile'); if (formElement) { setupFormChangeTracking(formElement); setupBeforeUnloadWarning(); } } /** * Рендерит страницу смены пароля */ function tmst_profile__renderPasswordPage() { document.title = tma__translate('{{change_password_title}}', 'userbar_dict'); tmst_profile__drawBreadcrumbs(true); tmst_profile__drawPasswordPageContent(); tmst_profile__setupPasswordToggleHandlers(); tmst_profile__setupPasswordFormSubmitHandler(); } /** * Рисует контент страницы смены пароля */ function tmst_profile__drawPasswordPageContent() { var rootEl = document.querySelector('.tmst-profile'); if (!rootEl) return; var html = ''; html += '